Accept version 0.2 (and similar?) JPK files with channels (vs. channels.list).
authorW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 14:51:08 +0000 (10:51 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 8 Sep 2010 14:51:08 +0000 (10:51 -0400)
I've emailed Michael Haggerty for clarification on this issue, but
this will work until I hear back.

hooke/driver/jpk.py

index c75fad31e7ae994cf16a3a34e207ec36404a0c42..ee78f35350e6011e4e9825cad028d36e69029a6b 100644 (file)
@@ -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