return self._zip_scale_segment(d, path, info)
def _zip_channel(self, zipfile, segment_index, channel_name, chan_info):
+ if chan_info['data']['type'] in ['constant-data', 'raster-data']:
+ return self._zip_calculate_channel(chan_info)
with Closing(zipfile.open(os.path.join(
'segments', str(segment_index),
chan_info['data']['file']['name']), 'r')) as f:
dtype=dtype,)
return data
+ 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']: