def makeDataset(self, data, Naverage=None): """ Helper function """ metadata = {'scantime': str(datetime.datetime.now( )), 'station': self.station.snapshot(), 'allgatevalues': self.station.gates.allvalues()} metadata['Naverage'] = Naverage if hasattr(self.datafunction, 'diff_dir'): metadata['diff_dir'] = self.datafunction.diff_dir if data.ndim == 2: if (data.shape[0] > 1): raise Exception('not yet implemented') data = data[0] alldata, _ = makeDataset_sweep(data, self.sweepparams, self.sweepranges, gates=self.station.gates, loc_record={'label': 'videomode_1d_single'}) alldata.metadata = metadata elif data.ndim == 3: if (data.shape[0] > 1): warnings.warn('getting dataset for multiple dimensions not yet tested') import copy alldata = [None] * len(data) for jj in range(len(data)): datax = data[jj] alldatax, _ = makeDataset_sweep_2D(datax, self.station.gates, self.sweepparams, self.sweepranges, loc_record={ 'label': 'videomode_2d_single'}) alldatax.metadata = copy.copy(metadata) alldata[jj] = alldatax else: raise Exception('makeDataset: data.ndim %d' % data.ndim) return alldata
def create_dataset(self, processed_data, metadata): alldata = [None] * len(processed_data) if processed_data.ndim == 2: for jj, data_block in enumerate(processed_data): dataset, _ = makeDataset_sweep( data_block, self.sweepparams, self.sweepranges[0], gates=self.station.gates, loc_record={'label': 'videomode_1d'}) dataset.metadata = copy.copy(metadata) alldata[jj] = dataset elif processed_data.ndim == 3: for jj, data_block in enumerate(processed_data): dataset, _ = makeDataset_sweep_2D( data_block, self.station.gates, self.sweepparams, self.sweepranges, loc_record={'label': 'videomode_2d'}) dataset.metadata = copy.copy(metadata) alldata[jj] = dataset else: raise Exception('makeDataset: data.ndim %d' % processed_data.ndim) return alldata