diff --git a/geomagio/processing/update_legacy.py b/geomagio/processing/update_legacy.py index 4b483cec03acdeb2bc6b2d7b806c6bc59e0230d8..fbe239dde32c3d248ba7d8405985d82098ce3c4d 100644 --- a/geomagio/processing/update_legacy.py +++ b/geomagio/processing/update_legacy.py @@ -28,15 +28,14 @@ def update_legacy( edge_host: str = os.getenv("EDGE_HOST", "cwbpub.cr.usgs.gov "), edge_port: int = os.getenv("EDGE_PORT", 2061), ): - + # get specified time interval from time that script is ran current_time = datetime.utcnow() current_time_string = current_time.strftime("%Y-%m-%d") endtime = UTCDateTime(current_time_string) - 1 - starttime = endtime - realtime_interval - + # create factory for script outputs timeseries_factory = EdgeFactory(host=edge_host, port=edge_port, interval=interval) - + # request data across time interval output_timeseries = timeseries_factory.get_timeseries( observatory=observatory, starttime=starttime, @@ -44,16 +43,16 @@ def update_legacy( channels=channels, type="variation", ) - + # find gaps in legacy data output_gaps = get_merged_gaps(get_stream_gaps(output_timeseries)) - + # exit script if legacy data is complete if len(output_gaps) == 0: return - + # get input/output deltas for timeseries processing input_interval = get_previous_interval(interval) input_delta = get_delta_from_interval(input_interval) output_delta = get_delta_from_interval(interval) - + # configure controller to process gaps controller = Controller( algorithm=FilterAlgorithm( input_sample_period=input_delta, output_sample_period=output_delta @@ -63,7 +62,7 @@ def update_legacy( ), outputFactory=timeseries_factory, ) - + # gather, process, and write data into legacy gaps for output_gap in output_gaps: controller.run( observatory=(observatory,),