示例#1
0
 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