From: W. Trevor King Date: Wed, 8 Sep 2010 14:51:08 +0000 (-0400) Subject: Accept version 0.2 (and similar?) JPK files with channels (vs. channels.list). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a329c4f3bbd0436fcad10f8509b78d08ac790998;p=hooke.git Accept version 0.2 (and similar?) JPK files with channels (vs. channels.list). I've emailed Michael Haggerty for clarification on this issue, but this will work until I hear back. --- diff --git a/hooke/driver/jpk.py b/hooke/driver/jpk.py index c75fad3..ee78f35 100644 --- a/hooke/driver/jpk.py +++ b/hooke/driver/jpk.py @@ -101,17 +101,26 @@ class JPKDriver (Driver): prop_file.close() expected_shape = (int(prop['force-segment-header']['num-points']),) channels = [] + if 'list' not in prop['channels']: + prop['channels'] = {'list': prop['channels'].split()} for chan in prop['channels']['list']: chan_info = prop['channel'][chan] - channels.append(self._zip_channel(zipfile, index, chan, chan_info)) + channels.append(self._zip_channel( + zipfile, index, chan, chan_info)) if channels[-1].shape != expected_shape: - raise NotImplementedError( - 'Channel %d:%s in %s has strange shape %s != %s' - % (index, chan, zipfile.path, - channels[-1].shape, expected_shape)) + raise NotImplementedError( + 'Channel %d:%s in %s has strange shape %s != %s' + % (index, chan, zipfile.path, + channels[-1].shape, expected_shape)) + if len(channels) > 0: + shape = (len(channels[0]), len(channels)) + dtype = channels[0].dtype + else: # no channels for this data block + shape = (0,0) + dtype = numpy.float32 d = curve.Data( - shape=(len(channels[0]), len(channels)), - dtype=channels[0].dtype, + shape=shape, + dtype=dtype, info=self._zip_translate_segment_params(prop)) for i,chan in enumerate(channels): d[:,i] = chan