Esempio n. 1
0
 def process_step(self, step, stream):
     """Filters stream for one step.
     Filters all traces in stream.
     Parameters
     ----------
     step : array element
         step holding variables for one filtering operation
     stream : obspy.core.Stream
         stream of data to filter
     Returns
     -------
     out : obspy.core.Stream
         stream containing 1 trace per original trace.
     """
     # gather variables from step
     input_sample_period = step["input_sample_period"]
     output_sample_period = step["output_sample_period"]
     window = np.array(step["window"])
     decimation = int(output_sample_period / input_sample_period)
     numtaps = len(window)
     window = window / sum(window)
     out = Stream()
     for trace in stream:
         starttime, data = self.align_trace(step, trace)
         # check that there is still enough data to filter
         if len(data) < numtaps:
             continue
         filtered = self.firfilter(data, window, decimation)
         stats = Stats(trace.stats)
         stats.delta = output_sample_period
         stats.data_interval = step["data_interval"]
         stats.data_interval_type = step["data_interval_type"]
         stats.filter_comments = step["filter_comments"]
         stats.starttime = starttime
         stats.npts = len(filtered)
         trace_out = self.create_trace(stats.channel, stats, filtered)
         out += trace_out
     return out