def fetch(self): """Fetch each channel and combine into a multichannel instance of :py:class:`~pyfusion.data.timeseries.TimeseriesData`. :rtype: :py:class:`~pyfusion.data.timeseries.TimeseriesData` """ ## initially, assume only single channel signals # this base debug breakpoint will apply to all flavours of acquisition debug_(pyfusion.DEBUG, level=2, key='base_multi_fetch') ordered_channel_names = self.ordered_channel_names() data_list = [] channels = ChannelList() timebase = None meta_dict={} if hasattr(self, 't_min') and hasattr(self, 't_max'): t_range = [float(self.t_min), float(self.t_max)] else: t_range = [] for chan in ordered_channel_names: sgn = 1 if chan[0]=='-': sgn = -sgn bare_chan = (chan.split('-'))[-1] fetcher_class = import_setting('Diagnostic', bare_chan, 'data_fetcher') tmp_data = fetcher_class(self.acq, self.shot, config_name=bare_chan).fetch() if len(t_range) == 2: tmp_data = tmp_data.reduce_time(t_range) channels.append(tmp_data.channels) # two tricky things here - tmp.data.channels only gets one channel hhere #config_name for a channel is attached to the multi part - #we need to move it to the particular channel # was channels[-1].config_name = chan channels[-1].config_name = tmp_data.config_name meta_dict.update(tmp_data.meta) #print(tmp_data.signal[-1], sgn) tmp_data.signal = sgn * tmp_data.signal #print(tmp_data.signal[-1], sgn) if timebase == None: timebase = tmp_data.timebase data_list.append(tmp_data.signal) else: if hasattr(self, 'skip_timebase_check') and self.skip_timebase_check == 'true': data_list.append(tmp_data.signal) else: try: assert_array_almost_equal(timebase, tmp_data.timebase) data_list.append(tmp_data.signal) except: raise signal=Signal(data_list) output_data = TimeseriesData(signal=signal, timebase=timebase, channels=channels) #output_data.meta.update({'shot':self.shot}) output_data.meta.update(meta_dict) return output_data
def get_acq_from_config(acq_name): """Return the acquisition class specified by `acq_class` in the `[Acquisition:acq_name]` section of the configuration file. :param acq_name: name of the acquisition configuration section. :returns: acquisition class specified by `acq_class` in the \ `[Acquisition:acq_name]` section of the configuration file """ acq_class = import_setting('Acquisition', acq_name, "acq_class") return acq_class
def fetch(self, interp_if_diff=True): """Fetch each channel and combine into a multichannel instance of :py:class:`~pyfusion.data.timeseries.TimeseriesData`. :rtype: :py:class:`~pyfusion.data.timeseries.TimeseriesData` """ ## initially, assume only single channel signals ordered_channel_names = self.ordered_channel_names() data_list = [] channels = ChannelList() timebase = None meta_dict = {} #from scipy.io import netcdf #home = os.environ['HOME'] #os.system('mkdir -p {}/tmp_pyfusion/'.format(home)) #fname = '{}/tmp_pyfusion/{}.nc'.format(home,self.shot) #if os.path.exists(fname): # NC = netcdf.netcdf_file(fname,'r',version=2) #else: # NC = netcdf.netcdf_file(fname,'w',version=2) for chan in ordered_channel_names: fetcher_class = import_setting('Diagnostic', chan, 'data_fetcher') tmp_data = fetcher_class(self.acq, self.shot, config_name=chan).fetch() channels.append(tmp_data.channels) meta_dict.update(tmp_data.meta) if timebase is None: timebase = tmp_data.timebase data_list.append(tmp_data.signal) else: try: assert_array_almost_equal(timebase, tmp_data.timebase) data_list.append(tmp_data.signal) except: if interp_if_diff: data_list.append( np.interp(timebase, tmp_data.timebase, tmp_data.signal)) else: raise #NC.close() signal = Signal(data_list) output_data = TimeseriesData(signal=signal, timebase=timebase, channels=channels) #output_data.meta.update({'shot':self.shot}) output_data.meta.update(meta_dict) return output_data
def fetch(self, interp_if_diff = True): """Fetch each channel and combine into a multichannel instance of :py:class:`~pyfusion.data.timeseries.TimeseriesData`. :rtype: :py:class:`~pyfusion.data.timeseries.TimeseriesData` """ print('******** hello world ***********') ## initially, assume only single channel signals ordered_channel_names = self.ordered_channel_names() data_list = [] channels = ChannelList() timebase = None meta_dict={} from scipy.io import netcdf fname = '/u/haskeysr/tmp/{}.nc'.format(self.shot) write_cache=False; read_cache=False if os.path.exists(fname): NC = netcdf.netcdf_file(fname,'a',version=2) else: NC = netcdf.netcdf_file(fname,'w',version=2) for chan in ordered_channel_names: fetcher_class = import_setting('Diagnostic', chan, 'data_fetcher') tmp_data = fetcher_class(self.acq, self.shot, config_name=chan, NC=NC).fetch() channels.append(tmp_data.channels) meta_dict.update(tmp_data.meta) if timebase == None: timebase = tmp_data.timebase data_list.append(tmp_data.signal) else: try: assert_array_almost_equal(timebase, tmp_data.timebase) data_list.append(tmp_data.signal) except: if interp_if_diff: data_list.append(np.interp(timebase, tmp_data.timebase, tmp_data.signal)) else: raise NC.close() signal=Signal(data_list) output_data = TimeseriesData(signal=signal, timebase=timebase, channels=channels) #output_data.meta.update({'shot':self.shot}) output_data.meta.update(meta_dict) return output_data
def fetch(self, interp_if_diff=True): """Fetch each channel and combine into a multichannel instance of :py:class:`~pyfusion.data.timeseries.TimeseriesData`. :rtype: :py:class:`~pyfusion.data.timeseries.TimeseriesData` """ ## initially, assume only single channel signals ordered_channel_names = self.ordered_channel_names() data_list = [] channels = ChannelList() timebase = None meta_dict = {} for chan in ordered_channel_names: fetcher_class = import_setting('Diagnostic', chan, 'data_fetcher') tmp_data = fetcher_class(self.acq, self.shot, config_name=chan).fetch() channels.append(tmp_data.channels) meta_dict.update(tmp_data.meta) if timebase == None: timebase = tmp_data.timebase data_list.append(tmp_data.signal) else: try: assert_array_almost_equal(timebase, tmp_data.timebase) data_list.append(tmp_data.signal) except: if interp_if_diff: data_list.append( np.interp(timebase, tmp_data.timebase, tmp_data.signal)) else: raise signal = Signal(data_list) output_data = TimeseriesData(signal=signal, timebase=timebase, channels=channels) #output_data.meta.update({'shot':self.shot}) output_data.meta.update(meta_dict) return output_data
def test_import_setting_with_fakedata_acquisition(self): from pyfusion.conf.utils import import_setting acq_from_config = import_setting('Acquisition', 'test_fakedata', 'acq_class') from pyfusion.acquisition.FakeData.acq import FakeDataAcquisition self.assertEqual(acq_from_config, FakeDataAcquisition)
def fetch(self): """Fetch each channel and combine into a multichannel instance of :py:class:`~pyfusion.data.timeseries.TimeseriesData`. :rtype: :py:class:`~pyfusion.data.timeseries.TimeseriesData` """ ## initially, assume only single channel signals # this base debug breakpoint will apply to all flavours of acquisition debug_(pyfusion.DEBUG, level=2, key='base_multi_fetch') ordered_channel_names = self.ordered_channel_names() data_list = [] channels = ChannelList() timebase = None meta_dict = {} if hasattr(self, 't_min') and hasattr(self, 't_max'): t_range = [float(self.t_min), float(self.t_max)] else: t_range = [] for chan in ordered_channel_names: sgn = 1 if chan[0] == '-': sgn = -sgn bare_chan = (chan.split('-'))[-1] fetcher_class = import_setting('Diagnostic', bare_chan, 'data_fetcher') tmp_data = fetcher_class(self.acq, self.shot, config_name=bare_chan).fetch() if len(t_range) == 2: tmp_data = tmp_data.reduce_time(t_range) channels.append(tmp_data.channels) # two tricky things here - tmp.data.channels only gets one channel hhere #config_name for a channel is attached to the multi part - #we need to move it to the particular channel # was channels[-1].config_name = chan channels[-1].config_name = tmp_data.config_name meta_dict.update(tmp_data.meta) #print(tmp_data.signal[-1], sgn) tmp_data.signal = sgn * tmp_data.signal #print(tmp_data.signal[-1], sgn) if timebase == None: timebase = tmp_data.timebase data_list.append(tmp_data.signal) else: if hasattr(self, 'skip_timebase_check' ) and self.skip_timebase_check == 'true': data_list.append(tmp_data.signal) else: try: assert_array_almost_equal(timebase, tmp_data.timebase) data_list.append(tmp_data.signal) except: raise signal = Signal(data_list) output_data = TimeseriesData(signal=signal, timebase=timebase, channels=channels) #output_data.meta.update({'shot':self.shot}) output_data.meta.update(meta_dict) return output_data