From c072fde53616e09afd15feba678a9e2be7d96526 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Thu, 10 Sep 2020 17:19:54 -0600 Subject: [PATCH] remove call for shift, move shift method below get nearest time --- geomagio/algorithm/FilterAlgorithm.py | 39 +++++++++++++-------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/geomagio/algorithm/FilterAlgorithm.py b/geomagio/algorithm/FilterAlgorithm.py index 3761b9731..dadb0761f 100644 --- a/geomagio/algorithm/FilterAlgorithm.py +++ b/geomagio/algorithm/FilterAlgorithm.py @@ -43,24 +43,6 @@ STEPS = [ ] -def get_step_time_shift(step): - """Calculates the time shift generated in each filtering step - - Parameters - ---------- - step: dict - Dictionary object holding information about a given filter step - Returns - ------- - shift: float - Time shift value - """ - input_sample_period = step["input_sample_period"] - numtaps = len(step["window"]) - shift = input_sample_period * ((numtaps - 1) / 2) - return shift - - def get_nearest_time(step, output_time, left=True): interval_start = output_time - ( output_time.timestamp % step["output_sample_period"] @@ -87,6 +69,24 @@ def get_nearest_time(step, output_time, left=True): } +def get_step_time_shift(step): + """Calculates the time shift generated in each filtering step + + Parameters + ---------- + step: dict + Dictionary object holding information about a given filter step + Returns + ------- + shift: float + Time shift value + """ + input_sample_period = step["input_sample_period"] + numtaps = len(step["window"]) + shift = input_sample_period * ((numtaps - 1) / 2) + return shift + + class FilterAlgorithm(Algorithm): """ Filter Algorithm that filters and downsamples data @@ -257,9 +257,6 @@ class FilterAlgorithm(Algorithm): decimation = int(output_sample_period / input_sample_period) numtaps = len(window) window = window / sum(window) - # first output timestamp is in the center of the filter window for firfilters - # center output timestamp is in the center of the filter window for averages - shift = get_step_time_shift(step) out = Stream() for trace in stream: starttime, data = self.align_trace(step, trace) -- GitLab