+ def _zip_calculate_channel(self, chan_info):
+ type_ = chan_info['data']['type']
+ n = int(chan_info['data']['num-points'])
+ if type_ == 'constant-data':
+ return float(chan_info['data']['value'])*numpy.ones(
+ shape=(n,),
+ dtype=numpy.float32)
+ elif type_ == 'raster-data':
+ start = float(chan_info['data']['start'])
+ step = float(chan_info['data']['step'])
+ return numpy.arange(
+ start=start,
+ stop=start + step*(n-0.5),
+ step=step,
+ dtype=numpy.float32)
+ else:
+ raise ValueError('Unrecognized data format "%s"' % type_)
+
+ def _zip_channel_dtype(self, chan_info):
+ type_ = chan_info['data']['type']
+ if type_ in ['float-data', 'float']:
+ dtype = numpy.dtype(numpy.float32)
+ elif type_ in ['integer-data', 'memory-integer-data']:
+ encoder = chan_info['data']['encoder']['type']
+ if encoder in ['signedinteger', 'signedinteger-limited']:
+ dtype = numpy.dtype(numpy.int32)
+ elif encoder in ['unsignedinteger', 'unsignedinteger-limited']:
+ dtype = numpy.dtype(numpy.uint32)
+ else:
+ raise ValueError('Unrecognized encoder type "%s" for "%s" data'
+ % (encoder, type_))
+ elif type_ in ['short-data', 'short', 'memory-short-data']:
+ encoder = chan_info['data']['encoder']['type']
+ if encoder in ['signedshort', 'signedshort-limited']:
+ dtype = numpy.dtype(numpy.int16)
+ elif encoder in ['unsignedshort', 'unsignedshort-limited']:
+ dtype = numpy.dtype(numpy.uint16)
+ else:
+ raise ValueError('Unrecognized encoder type "%s" for "%s" data'
+ % (encoder, type_))
+ else:
+ raise ValueError('Unrecognized data format "%s"' % type_)
+ byte_order = '>'
+ # '>' (big endian) byte order.
+ # From version 0.3 of JPKForceSpec.txt in the "Binary data" section:
+ # All forms of raw data are stored in chronological order
+ # (the order in which they were collected), and the
+ # individual values are stored in network byte order
+ # (big-endian). The data type used to store the data is
+ # specified by the "channel.*.data.type" property, and is
+ # either short (2 bytes per value), integer (4 bytes), or
+ # float (4 bytes, IEEE format).
+ return dtype.newbyteorder(byte_order)
+
+ def _zip_translate_params(self, params, chan_info, version):