def launch(self, time_series, nfft=None): """ Launch algorithm and build results. """ ##--------- Prepare a CoherenceSpectrum object for result ------------## coherence = CoherenceSpectrum(source=time_series, nfft=self.algorithm.nfft, storage_path=self.storage_path) ##------------- NOTE: Assumes 4D, Simulator timeSeries. --------------## node_slice = [slice(self.input_shape[0]), None, slice(self.input_shape[2]), slice(self.input_shape[3])] ##---------- Iterate over slices and compose final result ------------## small_ts = TimeSeries(use_storage=False) small_ts.sample_rate = time_series.sample_rate partial_coh = None for var in range(self.input_shape[1]): node_slice[1] = slice(var, var + 1) small_ts.data = time_series.read_data_slice(tuple(node_slice)) self.algorithm.time_series = small_ts partial_coh = self.algorithm.evaluate() coherence.write_data_slice(partial_coh) coherence.frequency = partial_coh.frequency coherence.close_file() return coherence
def launch(self, time_series, mother=None, sample_period=None, normalisation=None, q_ratio=None, frequencies='Range', frequencies_parameters=None): """ Launch algorithm and build results. """ ##--------- Prepare a WaveletCoefficients object for result ----------## frequencies_array = numpy.array([]) if self.algorithm.frequencies is not None: frequencies_array = numpy.array(list(self.algorithm.frequencies)) wavelet = WaveletCoefficients(source=time_series, mother=self.algorithm.mother, q_ratio=self.algorithm.q_ratio, sample_period=self.algorithm.sample_period, frequencies=frequencies_array, normalisation=self.algorithm.normalisation, storage_path=self.storage_path) ##------------- NOTE: Assumes 4D, Simulator timeSeries. --------------## node_slice = [slice(self.input_shape[0]), slice(self.input_shape[1]), None, slice(self.input_shape[3])] ##---------- Iterate over slices and compose final result ------------## small_ts = TimeSeries(use_storage=False) small_ts.sample_rate = time_series.sample_rate small_ts.sample_period = time_series.sample_period for node in range(self.input_shape[2]): node_slice[2] = slice(node, node + 1) small_ts.data = time_series.read_data_slice(tuple(node_slice)) self.algorithm.time_series = small_ts partial_wavelet = self.algorithm.evaluate() wavelet.write_data_slice(partial_wavelet) wavelet.close_file() return wavelet
def launch(self, time_series): """ Launch algorithm and build results. :returns: the `ComplexCoherenceSpectrum` built with the given time-series """ shape = time_series.read_data_shape() ##------- Prepare a ComplexCoherenceSpectrum object for result -------## spectra = ComplexCoherenceSpectrum(source=time_series, storage_path=self.storage_path) ##------------------- NOTE: Assumes 4D TimeSeries. -------------------## node_slice = [slice(shape[0]), slice(shape[1]), slice(shape[2]), slice(shape[3])] ##---------- Iterate over slices and compose final result ------------## small_ts = TimeSeries(use_storage=False) small_ts.sample_rate = time_series.sample_rate small_ts.data = time_series.read_data_slice(tuple(node_slice)) self.algorithm.time_series = small_ts partial_result = self.algorithm.evaluate() LOG.debug("got partial_result") LOG.debug("partial segment_length is %s" % (str(partial_result.segment_length))) LOG.debug("partial epoch_length is %s" % (str(partial_result.epoch_length))) LOG.debug("partial windowing_function is %s" % (str(partial_result.windowing_function))) #LOG.debug("partial frequency vector is %s" % (str(partial_result.frequency))) spectra.write_data_slice(partial_result) spectra.segment_length = partial_result.segment_length spectra.epoch_length = partial_result.epoch_length spectra.windowing_function = partial_result.windowing_function #spectra.frequency = partial_result.frequency spectra.close_file() return spectra
def launch(self, time_series, mother=None, sample_period=None, normalisation=None, q_ratio=None, frequencies='Range', frequencies_parameters=None): """ Launch algorithm and build results. """ ##--------- Prepare a WaveletCoefficients object for result ----------## frequencies_array = numpy.array([]) if self.algorithm.frequencies is not None: frequencies_array = numpy.array(list(self.algorithm.frequencies)) wavelet = WaveletCoefficients( source=time_series, mother=self.algorithm.mother, q_ratio=self.algorithm.q_ratio, sample_period=self.algorithm.sample_period, frequencies=frequencies_array, normalisation=self.algorithm.normalisation, storage_path=self.storage_path) ##------------- NOTE: Assumes 4D, Simulator timeSeries. --------------## node_slice = [ slice(self.input_shape[0]), slice(self.input_shape[1]), None, slice(self.input_shape[3]) ] ##---------- Iterate over slices and compose final result ------------## small_ts = TimeSeries(use_storage=False) small_ts.sample_rate = time_series.sample_rate small_ts.sample_period = time_series.sample_period for node in range(self.input_shape[2]): node_slice[2] = slice(node, node + 1) small_ts.data = time_series.read_data_slice(tuple(node_slice)) self.algorithm.time_series = small_ts partial_wavelet = self.algorithm.evaluate() wavelet.write_data_slice(partial_wavelet) wavelet.close_file() return wavelet
def launch(self, time_series): """ Launch algorithm and build results. :returns: the `ComplexCoherenceSpectrum` built with the given time-series """ shape = time_series.read_data_shape() ##------- Prepare a ComplexCoherenceSpectrum object for result -------## spectra = ComplexCoherenceSpectrum(source=time_series, storage_path=self.storage_path) ##------------------- NOTE: Assumes 4D TimeSeries. -------------------## node_slice = [ slice(shape[0]), slice(shape[1]), slice(shape[2]), slice(shape[3]) ] ##---------- Iterate over slices and compose final result ------------## small_ts = TimeSeries(use_storage=False) small_ts.sample_rate = time_series.sample_rate small_ts.data = time_series.read_data_slice(tuple(node_slice)) self.algorithm.time_series = small_ts partial_result = self.algorithm.evaluate() LOG.debug("got partial_result") LOG.debug("partial segment_length is %s" % (str(partial_result.segment_length))) LOG.debug("partial epoch_length is %s" % (str(partial_result.epoch_length))) LOG.debug("partial windowing_function is %s" % (str(partial_result.windowing_function))) #LOG.debug("partial frequency vector is %s" % (str(partial_result.frequency))) spectra.write_data_slice(partial_result) spectra.segment_length = partial_result.segment_length spectra.epoch_length = partial_result.epoch_length spectra.windowing_function = partial_result.windowing_function #spectra.frequency = partial_result.frequency spectra.close_file() return spectra