Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Hooke's igorbinarywave with igor.py, adding fancy structure parsing to both projects. #3

Open
wants to merge 77 commits into
base: master
Choose a base branch
from

Conversation

wking
Copy link

@wking wking commented Jul 21, 2012

This is a pretty major restructuring for both projects, but I believe it's worth it. I think Structure, Field, and their Dynamic* subclasses make it much easier to understand how the parsing is going on. There are also new tests based on examples distributed in the technical notes. I've also added some rough matplotlib plotting.

wking and others added 30 commits July 16, 2012 13:15
It's a utility for the MFP3D driver, not a driver in its own right.
Otherwise an earier switch to a non-native byte ordering will confuse
the current load.
I'm confident in the bytes -> strings conversion, but not entirely
sure how the strings get mapped into multidimensional arrays.
Also moved byte_order to the util module and renamed a few functions
internal to the binarywave module so they start with an underscore.

The loadibw -> load (and saveibw -> save) change is because

  from igor.binarywave import load

gives you enough of an idea about what you're importing.  If you want
to keep it explicit in your client module, use

  from igor.binarywave import load as loadibw

which we do in the test.py module.
We'll be needing it for packed.load, so it's not binarywave-specific.
This makes more sense than storing them as a tuple.

Also, use wave_record.wave_info['bname'] as the name for storing the
wave in the filesystem view returned by packed.load.
wking added 20 commits July 21, 2012 08:54
…ount.

In Python 3, the floating point division lead to:

    Traceback (most recent call last):
      ...
      File ".../igor/struct.py", line 255, in unpack_data
        items = [next(iterator) for i in range(self.arg_count)]
    TypeError: 'numpy.float64' object cannot be interpreted as an integer
…lity.

Python 3 exceptions no longer have a .message attribute.
I don't know if encoding information is embedded in the IGOR files or
not.  Currently the stock parser just leaves everything it reads in in
bytes.  For compatibility, the igorpy module attempts to convert those
byte strings to Unicode, but it just assumes that the encoding used in
the file matches the locale or default encoding used by your system.
This could be a portability issue.  Until commit

  commit fe7006e
  Author: W. Trevor King <wking@tremily.us>
  Date:   Sat Jul 21 07:50:09 2012 -0400

    Replace igor.igorpy parsing with translations from igor.packed.load.

The igorpy parser used sys.getfilesystemencoding() to guess the
encoding, but that encoding is actually used to encode file names, not
file contents.  locale.getpreferredencoding is a better guess, but
it's still just a guess.
The tests pass on Python 2.7, and all the failures on Python 3.2 are
string/bytes display issues.
This improves on the old method of assuming they were scalar if
.item_count was 1.
@pkienzle
Copy link
Member

Your .py files are licensed as LGPL but the overall project is listed as GPL. Much of the python numerics world is BSD licensed, so LGPL is a closer match to the community. Do you mind changing the project to LGPL?

Note that some test files just list "Copyright" as the copyright notice.

wking added 9 commits July 26, 2012 14:23
On Thu, Jul 26, 2012 at 09:25:20AM -0700, Paul Kienzle wrote:
> Your .py files are licensed as LGPL but the overall project is
> listed as GPL.  Much of the python numerics world is BSD licensed,
> so LGPL is a closer match to the community.  Do you mind changing
> the project to LGPL?
The old algorithm collapsed null bytes early on.  The new algorithm
keeps the null bytes until the 32-byte chunks have been read.

Parsing hooke/test/data/vclamp_mfp3d/Line0004Point0001.ibw with the
old algorithm gave labels as

  [[], ['RawDeflLVDT'], [], []]

The new algorithm gives

  [[], ['', 'Raw', 'Defl', 'LVDT'], [], []]
Catch up with 551d9bc (Fix DynamicLabelsField parsing algorithm.,
2012-08-20).
I haven't actually tested all of these, but I doubt I did anything so
magical that support has been dropped in the meantime ;).  It would be
nice to drop the doctests [1], but until then testing Python 3 is
going to be difficult.

[1]: #1 (comment)
Changes since 0.2:

* Add igor.packed.walk for traversing a packed experiment filesystem.
* Add igorpackedexperiment.py to setup.py script list.
* Add -p/--plot option so scripts will plot waves.
* Adjust copyright to LGPLv3+
* Assorted bugfixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants