diff --git a/geomagio/Controller.py b/geomagio/Controller.py index 9d50ceb2a18a17f0c0fad8957d53d13348c6fc78..d9feb299ee03dad412fa23ce82960ec90f18dd95 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -285,8 +285,12 @@ class Controller(object): channels=input_channels, interval=input_interval, ) - if timeseries.count() == 0: - # no data to process + if not algorithm.can_produce_data( + starttime=timeseries[0].stats.starttime, + endtime=timeseries[0].stats.endtime, + stream=timeseries, + ): + # don't process if nothing will be produced return # pre-process if next_starttime and realtime: @@ -416,18 +420,6 @@ class Controller(object): ] ] for output_gap in output_gaps: - input_timeseries = self._get_input_timeseries( - algorithm=algorithm, - observatory=observatory, - starttime=output_gap[0], - endtime=output_gap[1], - channels=input_channels, - interval=input_interval, - ) - if not algorithm.can_produce_data( - starttime=output_gap[0], endtime=output_gap[1], stream=input_timeseries - ): - continue # check for fillable gap at start if output_gap[0] == starttime: # found fillable gap at start, recurse to previous interval @@ -469,7 +461,6 @@ class Controller(object): starttime=gap_starttime, endtime=gap_endtime, input_channels=input_channels, - input_timeseries=input_timeseries, output_channels=output_channels, input_interval=input_interval, output_interval=output_interval, diff --git a/geomagio/algorithm/SqDistAlgorithm.py b/geomagio/algorithm/SqDistAlgorithm.py index 246baa05d87aaf12d2e99fe347f8ccdb3e4d3124..5855ab8737d7b084d3e819c5906936eb6316f41f 100644 --- a/geomagio/algorithm/SqDistAlgorithm.py +++ b/geomagio/algorithm/SqDistAlgorithm.py @@ -306,6 +306,25 @@ class SqDistAlgorithm(Algorithm): out += self.create_trace(channel + "_Sigma", trace.stats, sigmahat) return out + def can_produce_data(self, starttime, endtime, stream): + """Can Produce data + + A stateful algorithm can produce data as long as it starts with a valid + state. Such a check is performed in SqDistAlgorithm.process_one(), so + there is little need to reproduce that here, and we simply return True, + thereby overiding the base Algorithm class's default behavior. + + Parameters + ---------- + starttime: UTCDateTime + start time of requested output + end : UTCDateTime + end time of requested output + stream: obspy.core.Stream + The input stream we want to make certain has data for the algorithm + """ + return True + @classmethod def additive( cls,