From 5c7fcb955607e5809e129524305dffdea50cf805 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Fri, 7 May 2021 13:08:11 -0600 Subject: [PATCH 1/7] update filter entrypoint to produce copied legacy from miniseed --- geomagio/TimeseriesUtility.py | 3 + geomagio/edge/MiniSeedFactory.py | 4 +- geomagio/edge/MiniSeedInputClient.py | 2 +- geomagio/edge/sncl.py | 4 +- geomagio/processing/__init__.py | 5 - geomagio/processing/factory.py | 23 +- geomagio/processing/obsrio.py | 341 --------------------- geomagio/processing/realtime_filter.py | 397 +++++++++++++++++++++++++ setup.py | 2 +- 9 files changed, 420 insertions(+), 361 deletions(-) delete mode 100644 geomagio/processing/obsrio.py create mode 100644 geomagio/processing/realtime_filter.py diff --git a/geomagio/TimeseriesUtility.py b/geomagio/TimeseriesUtility.py index e0729c21b..b192c4bbc 100644 --- a/geomagio/TimeseriesUtility.py +++ b/geomagio/TimeseriesUtility.py @@ -604,6 +604,9 @@ def split_trace(trace: Trace, size: int = 86400) -> Stream: # copy in case original trace changes later stream = Stream() out_trace = trace.copy() + if len(out_trace.data) == 1: + stream += out_trace + return stream for interval in get_intervals( starttime=out_trace.stats.starttime, endtime=out_trace.stats.endtime, diff --git a/geomagio/edge/MiniSeedFactory.py b/geomagio/edge/MiniSeedFactory.py index 99c3b9eec..d809db1c5 100644 --- a/geomagio/edge/MiniSeedFactory.py +++ b/geomagio/edge/MiniSeedFactory.py @@ -67,7 +67,7 @@ class MiniSeedFactory(TimeseriesFactory): self, host="cwbpub.cr.usgs.gov", port=2061, - write_port=7981, + write_port=7905, observatory=None, channels=None, type=None, @@ -132,7 +132,7 @@ class MiniSeedFactory(TimeseriesFactory): if starttime > endtime: raise TimeseriesFactoryException( - 'Starttime before endtime "%s" "%s"' % (starttime, endtime) + 'Endtime before starttime "%s" "%s"' % (starttime, endtime) ) # obspy factories sometimes write to stdout, instead of stderr diff --git a/geomagio/edge/MiniSeedInputClient.py b/geomagio/edge/MiniSeedInputClient.py index a25d31ce8..d2dc2e148 100644 --- a/geomagio/edge/MiniSeedInputClient.py +++ b/geomagio/edge/MiniSeedInputClient.py @@ -25,7 +25,7 @@ class MiniSeedInputClient(object): Floating point precision for output data """ - def __init__(self, host, port=2061, encoding="float32"): + def __init__(self, host, port=2061, encoding="float64"): self.host = host self.port = port self.encoding = encoding diff --git a/geomagio/edge/sncl.py b/geomagio/edge/sncl.py index 5bfa4ff2e..d84bb271f 100644 --- a/geomagio/edge/sncl.py +++ b/geomagio/edge/sncl.py @@ -20,7 +20,9 @@ CHANNEL_FROM_COMPONENT = { "K": "XK", } # reverse lookup of component from channel -COMPONENT_FROM_CHANNEL = dict((v, k) for (k, v) in CHANNEL_FROM_COMPONENT.iteritems()) +COMPONENT_FROM_CHANNEL = { + CHANNEL_FROM_COMPONENT[key]: key for key in CHANNEL_FROM_COMPONENT.keys() +} class SNCLException(Exception): diff --git a/geomagio/processing/__init__.py b/geomagio/processing/__init__.py index be97cfbd5..14dc324f1 100644 --- a/geomagio/processing/__init__.py +++ b/geomagio/processing/__init__.py @@ -5,7 +5,6 @@ and should be considered less stable than other packages in the library. """ from .factory import get_edge_factory, get_miniseed_factory from .observatory import adjusted, average, deltaf, rotate, sqdist_minute -from .obsrio import obsrio_minute, obsrio_second, obsrio_temperatures, obsrio_tenhertz __all__ = [ @@ -14,10 +13,6 @@ __all__ = [ "deltaf", "get_edge_factory", "get_miniseed_factory", - "obsrio_minute", - "obsrio_second", - "obsrio_temperatures", - "obsrio_tenhertz", "rotate", "sqdist_minute", ] diff --git a/geomagio/processing/factory.py b/geomagio/processing/factory.py index d9a065497..cf3240178 100644 --- a/geomagio/processing/factory.py +++ b/geomagio/processing/factory.py @@ -1,27 +1,30 @@ import os +from typing import Literal, Optional from ..TimeseriesFactory import TimeseriesFactory from ..edge import EdgeFactory, MiniSeedFactory def get_edge_factory( - data_type="variation", interval="second", **kwargs + data_type="variation", + host=os.getenv("EDGE_HOST", "127.0.0.1"), + interval="second", + **kwargs ) -> TimeseriesFactory: - return EdgeFactory( - host=os.getenv("EDGE_HOST", "127.0.0.1"), - interval=interval, - type=data_type, - **kwargs - ) + return EdgeFactory(host=host, interval=interval, type=data_type, **kwargs) def get_miniseed_factory( - data_type="variation", interval="second", **kwargs + convert_channels=None, + data_type="variation", + host=os.getenv("EDGE_HOST", "127.0.0.1"), + interval="second", + **kwargs ) -> TimeseriesFactory: return MiniSeedFactory( - convert_channels=("U", "V", "W"), - host=os.getenv("EDGE_HOST", "127.0.0.1"), + host=host, interval=interval, type=data_type, + convert_channels=convert_channels, **kwargs ) diff --git a/geomagio/processing/obsrio.py b/geomagio/processing/obsrio.py deleted file mode 100644 index bf0acf2b8..000000000 --- a/geomagio/processing/obsrio.py +++ /dev/null @@ -1,341 +0,0 @@ -from typing import Optional - -import typer - -from ..algorithm import Algorithm, FilterAlgorithm -from ..edge import EdgeFactory, MiniSeedFactory -from ..Controller import ( - Controller, - get_realtime_interval, -) -from ..TimeseriesFactory import TimeseriesFactory -from .factory import get_edge_factory, get_miniseed_factory - - -def main(): - typer.run(obsrio_filter) - - -def obsrio_filter( - interval: str, - observatory: str, - input_factory: Optional[str] = None, - host: str = "127.0.0.1", - port: str = 2061, - output_factory: Optional[str] = None, - output_port: int = typer.Option( - 2061, help="Port where output factory writes data." - ), - output_read_port: int = typer.Option( - 2061, help="Port where output factory reads data" - ), - realtime_interval: int = 600, - update_limit: int = 10, -): - if interval == "realtime": - filter_realtime( - observatory=observatory, - input_factory=input_factory, - host=host, - port=port, - output_factory=output_factory, - output_port=output_port, - output_read_port=output_read_port, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - elif interval in ["hour", "day"]: - input_factory = EdgeFactory(host=host, port=port) - output_factory = MiniSeedFactory( - host=host, port=output_read_port, write_port=output_port - ) - if interval == "hour": - obsrio_hour( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - elif interval == "day": - obsrio_day( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - else: - raise ValueError("Invalid interval") - - -def filter_realtime( - observatory: str, - input_factory: Optional[str] = None, - host: str = "127.0.0.1", - port: str = 2061, - output_factory: Optional[str] = None, - output_port: int = typer.Option( - 2061, help="Port where output factory writes data." - ), - output_read_port: int = typer.Option( - 2061, help="Port where output factory reads data" - ), - realtime_interval: int = 600, - update_limit: int = 10, -): - """Filter 10Hz miniseed, 1 second, one minute, and temperature data. - Defaults set for realtime processing; can also be implemented to update legacy data""" - if input_factory == "miniseed": - input_factory = MiniSeedFactory(host=host, port=port) - elif input_factory == "edge": - input_factory = EdgeFactory(host=host, port=port) - if output_factory == "miniseed": - output_factory = MiniSeedFactory( - host=host, port=output_read_port, write_port=output_port - ) - elif output_factory == "edge": - output_factory = EdgeFactory( - host=host, port=output_read_port, write_port=output_port - ) - - obsrio_tenhertz( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - obsrio_second( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - obsrio_minute( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - obsrio_temperatures( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - - -def obsrio_day( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 86400, - update_limit: int = 7, -): - """Filter 1 second edge H,E,Z,F to 1 day miniseed U,V,W,F.""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory or get_edge_factory(), - inputInterval="minute", - outputFactory=output_factory or get_miniseed_factory(), - outputInterval="day", - ) - renames = {"H": "U", "E": "V", "Z": "W", "F": "F"} - for input_channel in renames.keys(): - output_channel = renames[input_channel] - controller.run_as_update( - algorithm=FilterAlgorithm( - input_sample_period=60.0, - output_sample_period=86400.0, - inchannels=(input_channel,), - outchannels=(output_channel,), - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(input_channel,), - output_channels=(output_channel,), - realtime=realtime_interval, - rename_output_channel=((input_channel, output_channel),), - update_limit=update_limit, - ) - - -def obsrio_hour( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Filter 1 second edge H,E,Z,F to 1 hour miniseed U,V,W,F.""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory or get_edge_factory(), - inputInterval="minute", - outputFactory=output_factory or get_miniseed_factory(), - outputInterval="hour", - ) - renames = {"H": "U", "E": "V", "Z": "W", "F": "F"} - for input_channel in renames.keys(): - output_channel = renames[input_channel] - controller.run_as_update( - algorithm=FilterAlgorithm( - input_sample_period=60.0, - output_sample_period=3600.0, - inchannels=(input_channel,), - outchannels=(output_channel,), - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(input_channel,), - output_channels=(output_channel,), - realtime=realtime_interval, - rename_output_channel=((input_channel, output_channel),), - update_limit=update_limit, - ) - - -def obsrio_minute( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Filter 1Hz legacy H,E,Z,F to 1 minute legacy. - - Should be called after obsrio_second() and obsrio_tenhertz(), - which populate 1Hz legacy H,E,Z,F. - """ - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory or get_edge_factory(), - inputInterval="second", - outputFactory=output_factory or get_edge_factory(), - outputInterval="minute", - ) - for channel in ["H", "E", "Z", "F"]: - controller.run_as_update( - algorithm=FilterAlgorithm( - input_sample_period=1, - output_sample_period=60, - inchannels=(channel,), - outchannels=(channel,), - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(channel,), - output_channels=(channel,), - realtime=realtime_interval, - update_limit=update_limit, - ) - - -def obsrio_second( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Copy 1Hz miniseed F to 1Hz legacy F.""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=Algorithm(inchannels=("F",), outchannels=("F",)), - inputFactory=input_factory or get_miniseed_factory(), - outputFactory=output_factory or get_edge_factory(), - ) - controller.run_as_update( - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=("F",), - output_channels=("F",), - realtime=realtime_interval, - update_limit=update_limit, - ) - - -def obsrio_temperatures( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Filter temperatures 1Hz miniseed (LK1-4) to 1 minute legacy (UK1-4).""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory or get_miniseed_factory(), - inputInterval="second", - outputFactory=output_factory or get_edge_factory(), - outputInterval="minute", - ) - renames = {"LK1": "UK1", "LK2": "UK2", "LK3": "UK3", "LK4": "UK4"} - for input_channel in renames.keys(): - output_channel = renames[input_channel] - controller.run_as_update( - algorithm=FilterAlgorithm( - input_sample_period=1, - output_sample_period=60, - inchannels=(input_channel,), - outchannels=(output_channel,), - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(input_channel,), - output_channels=(output_channel,), - realtime=realtime_interval, - rename_output_channel=((input_channel, output_channel),), - update_limit=update_limit, - ) - - -def obsrio_tenhertz( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Filter 10Hz miniseed U,V,W to 1Hz legacy H,E,Z.""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory or get_miniseed_factory(), - inputInterval="tenhertz", - outputFactory=output_factory or get_edge_factory(), - outputInterval="second", - ) - renames = {"U": "H", "V": "E", "W": "Z"} - for input_channel in renames.keys(): - output_channel = renames[input_channel] - controller.run_as_update( - algorithm=FilterAlgorithm( - input_sample_period=0.1, - output_sample_period=1, - inchannels=(input_channel,), - outchannels=(output_channel,), - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(input_channel,), - output_channels=(output_channel,), - realtime=realtime_interval, - rename_output_channel=((input_channel, output_channel),), - update_limit=update_limit, - ) diff --git a/geomagio/processing/realtime_filter.py b/geomagio/processing/realtime_filter.py new file mode 100644 index 000000000..58fc87969 --- /dev/null +++ b/geomagio/processing/realtime_filter.py @@ -0,0 +1,397 @@ +from typing import List, Optional + +import typer + +from ..algorithm import Algorithm, FilterAlgorithm +from ..Controller import Controller, get_realtime_interval +from .. import TimeseriesFactory +from .factory import get_edge_factory, get_miniseed_factory + +app = typer.Typer() + + +def main(): + app() + + +@app.command(name="legacy") +def copy_to_legacy( + observatory: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2061, + output_port: int = 7981, + output_read_port: int = 2060, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Copies miniseed 1Hz, minutes, and temperatures(UK1-4) to edge""" + input_factory = get_miniseed_factory(host=input_host, port=input_port) + output_factory = get_edge_factory( + host=output_host, port=output_read_port, write_port=output_port + ) + input_channels = ("U", "V", "W", "F") + output_channels = ("H", "E", "Z", "F") + copy_channels( + observatory=observatory, + interval="second", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=( + "UK1", + "UK2", + "UK3", + "UK4", + ), + output_channels=( + "UK1", + "UK2", + "UK3", + "UK4", + ), + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +@app.command() +def obsrio( + observatory: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2061, + output_port: int = 7905, + output_read_port: int = 2061, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Filters 10Hz miniseed U,V,W and 1Hz miniseed temperatures(LK1-4)""" + output_factory = get_miniseed_factory( + host=output_host, port=output_read_port, write_port=output_port + ) + obsrio_tenhertz( + observatory=observatory, + input_factory=get_miniseed_factory( + host=input_host, port=input_port, convert_channels=("U", "V", "W") + ), + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + obsrio_temperatures( + observatory=observatory, + input_factory=get_miniseed_factory(host=input_host, port=input_port), + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +@app.command() +def pcdcp( + observatory: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2060, + output_port: int = 7905, + output_read_port: int = 2061, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Copies 1Hz edge H,E,Z,F to 1Hz miniseed U,V,W,F""" + input_factory = get_edge_factory(host=input_host, port=input_port) + output_factory = get_miniseed_factory( + host=output_host, port=output_read_port, write_port=output_port + ) + copy_channels( + observatory=observatory, + interval="second", + input_channels=["H", "E", "Z", "F"], + output_channels=["U", "V", "W", "F"], + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +@app.command(name="miniseed") +def filter_miniseed( + observatory: str, + interval: str = "realtime", + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2061, + output_port: int = 7905, + output_read_port: int = 2061, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Produces 1 minute, 1 hour, or 1 day miniseed U,V,W,F""" + input_factory = get_miniseed_factory(host=input_host, port=input_port) + output_factory = get_miniseed_factory( + host=output_host, port=output_read_port, write_port=output_port + ) + if interval == "realtime": + obsrio_minute( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + elif interval == "hour": + obsrio_hour( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + elif interval == "day": + obsrio_day( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +def copy_channels( + observatory: str, + interval: str, + input_channels: List[str], + output_channels: List[str], + input_factory: TimeseriesFactory, + output_factory: TimeseriesFactory, + realtime_interval: int = 600, + update_limit: int = 10, +): + """Copy data between edge and miniseed formats""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory, + inputInterval=interval, + outputFactory=output_factory, + outputInterval=interval, + ) + for i in range(len(input_channels)): + input_channel = input_channels[i] + output_channel = output_channels[i] + controller.run_as_update( + algorithm=Algorithm( + inchannels=(input_channel,), outchannels=(output_channel) + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(input_channel,), + output_channels=(output_channel,), + realtime=realtime_interval, + rename_output_channel=((input_channel, output_channel),), + update_limit=update_limit, + ) + + +def obsrio_day( + observatory: str, + input_factory: TimeseriesFactory, + output_factory: TimeseriesFactory, + realtime_interval: int = 86400, + update_limit: int = 7, +): + """Filter 1 minute miniseed U,V,W,F to 1 day miniseed U,V,W,F.""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory, + inputInterval="minute", + outputFactory=output_factory, + outputInterval="day", + ) + for channel in ["U", "V", "W", "F"]: + controller.run_as_update( + algorithm=FilterAlgorithm( + input_sample_period=60.0, + output_sample_period=86400.0, + inchannels=(channel,), + outchannels=(channel,), + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(channel,), + output_channels=(channel,), + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def obsrio_hour( + observatory: str, + input_factory: TimeseriesFactory, + output_factory: TimeseriesFactory, + realtime_interval: int = 86400, + update_limit: int = 7, +): + """Filter 1 minute miniseed U,V,W,F to 1 hour miniseed U,V,W,F.""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory, + inputInterval="minute", + outputFactory=output_factory, + outputInterval="hour", + ) + for channel in ["U", "V", "W", "F"]: + controller.run_as_update( + algorithm=FilterAlgorithm( + input_sample_period=60.0, + output_sample_period=3600.0, + inchannels=(channel,), + outchannels=(channel,), + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(channel,), + output_channels=(channel,), + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def obsrio_minute( + observatory: str, + input_factory: Optional[TimeseriesFactory] = None, + output_factory: Optional[TimeseriesFactory] = None, + realtime_interval: int = 600, + update_limit: int = 10, +): + """Filter 1Hz miniseed U,V,W,F to 1 minute miniseed U,V,W,F""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory or get_miniseed_factory(), + inputInterval="second", + outputFactory=output_factory or get_miniseed_factory(), + outputInterval="minute", + ) + for channel in ["U", "V", "W", "F"]: + controller.run_as_update( + algorithm=FilterAlgorithm( + input_sample_period=1.0, + output_sample_period=60.0, + inchannels=(channel,), + outchannels=(channel,), + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(channel,), + output_channels=(channel,), + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def obsrio_temperatures( + observatory: str, + input_factory: TimeseriesFactory, + output_factory: TimeseriesFactory, + realtime_interval: int = 600, + update_limit: int = 10, +): + """Filter 1Hz miniseed (LK1-4) to 1 minute miniseed (UK1-4).""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory, + inputInterval="second", + outputFactory=output_factory, + outputInterval="minute", + ) + renames = {"LK1": "UK1", "LK2": "UK2", "LK3": "UK3", "LK4": "UK4"} + for input_channel in renames.keys(): + output_channel = renames[input_channel] + controller.run_as_update( + algorithm=FilterAlgorithm( + input_sample_period=1, + output_sample_period=60, + inchannels=(input_channel,), + outchannels=(output_channel,), + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(input_channel,), + output_channels=(output_channel,), + realtime=realtime_interval, + rename_output_channel=((input_channel, output_channel),), + update_limit=update_limit, + ) + + +def obsrio_tenhertz( + observatory: str, + input_factory: Optional[TimeseriesFactory] = None, + output_factory: Optional[TimeseriesFactory] = None, + realtime_interval: int = 60, + update_limit: int = 7, +): + """Filters 10Hz miniseed U,V,W to 1Hz miniseed U,V,W""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory + or get_miniseed_factory( + convert_channels=( + "U", + "V", + "W", + ) + ), + inputInterval="tenhertz", + outputFactory=output_factory or get_edge_factory(), + outputInterval="second", + ) + channels = ["U", "V", "W"] + for channel in channels: + controller.run_as_update( + algorithm=FilterAlgorithm( + input_sample_period=0.1, + output_sample_period=1, + inchannels=(channel,), + outchannels=(channel,), + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(channel,), + output_channels=(channel,), + realtime=realtime_interval, + update_limit=update_limit, + ) diff --git a/setup.py b/setup.py index 9a9c5ace7..dc3fc132f 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ setuptools.setup( "generate-matrix=geomagio.processing.adjusted:main", "geomag-metadata=geomagio.metadata.main:main", "magproc-prepfiles=geomagio.processing.magproc:main", - "obsrio-filter=geomagio.processing.obsrio:main", + "realtime-filter=geomagio.processing.realtime_filter:main", ], }, ) -- GitLab From e1c697aee64835c1918a3186d82562777bddb541 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Fri, 7 May 2021 13:19:28 -0600 Subject: [PATCH 2/7] Simplify channel iteration for tenhertz filter --- geomagio/processing/realtime_filter.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/geomagio/processing/realtime_filter.py b/geomagio/processing/realtime_filter.py index 58fc87969..5eff95402 100644 --- a/geomagio/processing/realtime_filter.py +++ b/geomagio/processing/realtime_filter.py @@ -377,8 +377,7 @@ def obsrio_tenhertz( outputFactory=output_factory or get_edge_factory(), outputInterval="second", ) - channels = ["U", "V", "W"] - for channel in channels: + for channel in ["U", "V", "W"]: controller.run_as_update( algorithm=FilterAlgorithm( input_sample_period=0.1, -- GitLab From 7efb0ddffebf1a710d9c51cfec5441a6a103a43c Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Fri, 7 May 2021 13:25:56 -0600 Subject: [PATCH 3/7] adjust miniseed factory tests for float64 precision --- test/edge_test/MiniSeedFactory_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/edge_test/MiniSeedFactory_test.py b/test/edge_test/MiniSeedFactory_test.py index a0c57869e..74426cc2b 100644 --- a/test/edge_test/MiniSeedFactory_test.py +++ b/test/edge_test/MiniSeedFactory_test.py @@ -98,7 +98,7 @@ def test__pre_process(): processed = MiniSeedInputClient(host=None)._pre_process(stream=Stream(trace)) assert len(processed) == 2 for trace in processed: - assert trace.data.dtype == "float32" + assert trace.data.dtype == "float64" stats = trace.stats assert stats.npts == 86400 assert stats.starttime.timestamp % 86400 == 0 @@ -113,9 +113,9 @@ def test__format_miniseed(): block_size = 512 data = buf.getvalue() n_blocks = int(len(data) / block_size) - assert n_blocks == 1516 + assert n_blocks == 3032 # 759th block is start of second day(758 blocks per day for 1Hz data) - block_start = 758 * block_size + block_start = 1516 * block_size block = data[block_start : block_start + block_size] out_stream = read(io.BytesIO(block)) assert out_stream[0].stats.starttime.timestamp % 86400 == 0 -- GitLab From e8487afa234eb02148ae9300d1be656b0c3da662 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Wed, 12 May 2021 14:20:57 -0600 Subject: [PATCH 4/7] Support miniseed channels in algorithm tests --- etc/adjusted/BOU201601adj.min | 4 +- etc/adjusted/BOU201601vmin.min | 4 +- etc/adjusted/BOU202005adj.min | 4 +- etc/adjusted/BOU202005vmin.min | 4 +- .../bou20181024_DQVS_expected_vmin.min | 4 +- .../bou20181024_DQVS_test0_vmin.min | 4 +- .../bou20181024_DQVS_test1_vmin.min | 4 +- .../bou20181024_DQVS_test2_vmin.min | 4 +- .../bou20181024_DQVS_test3_vmin.min | 4 +- .../bou20181024_DQVS_test4_vmin.min | 4 +- .../bou20181024_DQVS_test5_vmin.min | 4 +- .../bou20181024_DQVS_test6_vmin.min | 4 +- ...YZF_vmin.min => bou20181024_XYWF_vmin.min} | 4 +- etc/controller/sqdistBOU_h_state.json | 1 - etc/controller/sqdistBOU_u_state.json | 1454 +++++++++++++++++ test/Controller_test.py | 36 +- test/StreamConverter_test.py | 164 +- test/algorithm_test/AdjustedAlgorithm_test.py | 24 +- test/algorithm_test/XYZAlgorithm_test.py | 26 +- 19 files changed, 1605 insertions(+), 152 deletions(-) rename etc/controller/{bou20181024_XYZF_vmin.min => bou20181024_XYWF_vmin.min} (98%) delete mode 100755 etc/controller/sqdistBOU_h_state.json create mode 100755 etc/controller/sqdistBOU_u_state.json diff --git a/etc/adjusted/BOU201601adj.min b/etc/adjusted/BOU201601adj.min index 7d9262b9a..5ab1454a5 100644 --- a/etc/adjusted/BOU201601adj.min +++ b/etc/adjusted/BOU201601adj.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.764 | Elevation 1682 | - Reported XYZF | + Reported XYWF | Sensor Orientation HDZF | Digital Sampling 100.0 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUX BOUY BOUZ BOUF | +DATE TIME DOY BOUX BOUY BOUW BOUF | 2016-01-01 00:00:00.000 001 20428.79 3123.15 47956.69 52226.63 2016-01-01 00:01:00.000 001 20427.67 3127.49 47956.96 52226.72 2016-01-01 00:02:00.000 001 20427.86 3131.63 47957.42 52227.49 diff --git a/etc/adjusted/BOU201601vmin.min b/etc/adjusted/BOU201601vmin.min index 57c20c442..83ef32f48 100644 --- a/etc/adjusted/BOU201601vmin.min +++ b/etc/adjusted/BOU201601vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.764 | Elevation 1682 | - Reported HEZF | + Reported UVWF | Sensor Orientation HDZF | Digital Sampling 100.0 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUH BOUE BOUZ BOUF | +DATE TIME DOY BOUU BOUV BOUW BOUF | 2016-01-01 00:00:00.000 001 20735.93 -99.77 47370.21 52248.63 2016-01-01 00:01:00.000 001 20735.48 -95.30 47370.53 52248.72 2016-01-01 00:02:00.000 001 20736.30 -91.25 47371.05 52249.49 diff --git a/etc/adjusted/BOU202005adj.min b/etc/adjusted/BOU202005adj.min index 55f8fcc64..551fd3ed7 100644 --- a/etc/adjusted/BOU202005adj.min +++ b/etc/adjusted/BOU202005adj.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported HENULNUL | + Reported UVNULNUL | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -17,7 +17,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUH BOUE BOUNUL BOUNUL | +DATE TIME DOY BOUU BOUV BOUNUL BOUNUL | 2020-05-20 16:15:00.000 141 -20799.04 80.92 99999.00 99999.00 2020-05-20 16:16:00.000 141 -20798.26 79.97 99999.00 99999.00 2020-05-20 16:17:00.000 141 -20799.43 81.22 99999.00 99999.00 diff --git a/etc/adjusted/BOU202005vmin.min b/etc/adjusted/BOU202005vmin.min index 545671c9b..f3d0f15bc 100644 --- a/etc/adjusted/BOU202005vmin.min +++ b/etc/adjusted/BOU202005vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported HENULNUL | + Reported UVNULNUL | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUH BOUE BOUNUL BOUNUL | +DATE TIME DOY BOUU BOUV BOUNUL BOUNUL | 2020-05-20 16:15:00.000 141 20799.04 -80.92 99999.00 99999.00 2020-05-20 16:16:00.000 141 20798.26 -79.97 99999.00 99999.00 2020-05-20 16:17:00.000 141 20799.43 -81.22 99999.00 99999.00 diff --git a/etc/controller/bou20181024_DQVS_expected_vmin.min b/etc/controller/bou20181024_DQVS_expected_vmin.min index 1e0e920cb..cc382b422 100644 --- a/etc/controller/bou20181024_DQVS_expected_vmin.min +++ b/etc/controller/bou20181024_DQVS_expected_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test0_vmin.min b/etc/controller/bou20181024_DQVS_test0_vmin.min index 90d30eb42..310b6d549 100755 --- a/etc/controller/bou20181024_DQVS_test0_vmin.min +++ b/etc/controller/bou20181024_DQVS_test0_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 99999.00 99999.00 99999.00 99999.00 2018-10-24 00:01:00.000 297 99999.00 99999.00 99999.00 99999.00 2018-10-24 00:02:00.000 297 99999.00 99999.00 99999.00 99999.00 diff --git a/etc/controller/bou20181024_DQVS_test1_vmin.min b/etc/controller/bou20181024_DQVS_test1_vmin.min index 894bae588..250f1a45c 100755 --- a/etc/controller/bou20181024_DQVS_test1_vmin.min +++ b/etc/controller/bou20181024_DQVS_test1_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test2_vmin.min b/etc/controller/bou20181024_DQVS_test2_vmin.min index d1c108e80..106783eb6 100755 --- a/etc/controller/bou20181024_DQVS_test2_vmin.min +++ b/etc/controller/bou20181024_DQVS_test2_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test3_vmin.min b/etc/controller/bou20181024_DQVS_test3_vmin.min index f332e2c78..9f7f8827d 100755 --- a/etc/controller/bou20181024_DQVS_test3_vmin.min +++ b/etc/controller/bou20181024_DQVS_test3_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test4_vmin.min b/etc/controller/bou20181024_DQVS_test4_vmin.min index 50d7f62eb..3b7ad9300 100755 --- a/etc/controller/bou20181024_DQVS_test4_vmin.min +++ b/etc/controller/bou20181024_DQVS_test4_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test5_vmin.min b/etc/controller/bou20181024_DQVS_test5_vmin.min index 410d84fff..f3eccfc01 100755 --- a/etc/controller/bou20181024_DQVS_test5_vmin.min +++ b/etc/controller/bou20181024_DQVS_test5_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_DQVS_test6_vmin.min b/etc/controller/bou20181024_DQVS_test6_vmin.min index 1e0e920cb..cc382b422 100755 --- a/etc/controller/bou20181024_DQVS_test6_vmin.min +++ b/etc/controller/bou20181024_DQVS_test6_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported MDTMSQMSVMSS | + Reported UDTUSQUSVUSS | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUMDT BOUMSQ BOUMSV BOUMSS | +DATE TIME DOY BOUUDT BOUUSQ BOUUSV BOUUSS | 2018-10-24 00:00:00.000 297 12.37 -0.15 20825.28 9.68 2018-10-24 00:01:00.000 297 12.47 -0.17 20825.28 9.68 2018-10-24 00:02:00.000 297 12.59 -0.18 20825.28 9.68 diff --git a/etc/controller/bou20181024_XYZF_vmin.min b/etc/controller/bou20181024_XYWF_vmin.min similarity index 98% rename from etc/controller/bou20181024_XYZF_vmin.min rename to etc/controller/bou20181024_XYWF_vmin.min index ec6097ad9..488c77b84 100755 --- a/etc/controller/bou20181024_XYZF_vmin.min +++ b/etc/controller/bou20181024_XYWF_vmin.min @@ -5,7 +5,7 @@ Geodetic Latitude 40.137 | Geodetic Longitude 254.763 | Elevation 1682 | - Reported XYZF | + Reported XYWF | Sensor Orientation HDZF | Digital Sampling 0.01 second | Data Interval Type filtered 1-minute (00:15-01:45) | @@ -19,7 +19,7 @@ # CONDITIONS OF USE: The Conditions of Use for data provided | # through INTERMAGNET and acknowledgement templates can be found at | # www.intermagnet.org | -DATE TIME DOY BOUX BOUY BOUZ BOUF | +DATE TIME DOY BOUX BOUY BOUW BOUF | 2018-10-24 00:00:00.000 297 20576.37 3288.50 47013.46 51942.53 2018-10-24 00:01:00.000 297 20576.45 3288.57 47013.45 51942.56 2018-10-24 00:02:00.000 297 20576.54 3288.68 47013.47 51942.62 diff --git a/etc/controller/sqdistBOU_h_state.json b/etc/controller/sqdistBOU_h_state.json deleted file mode 100755 index a9cefc121..000000000 --- a/etc/controller/sqdistBOU_h_state.json +++ /dev/null @@ -1 +0,0 @@ -{"yhat0": [], "s0": [-0.15316247952645945, -0.16910664005994924, -0.18483375871067498, -0.2003470197560775, -0.2155958582076405, -0.23057931720052682, -0.24532398894595353, -0.25980439660330035, -0.2740174684957921, -0.28795551129887276, -0.3016061067330389, -0.3149577898281022, -0.3279802034537047, -0.3406859114489489, -0.35303637397002774, -0.3650402741249348, -0.37672630042314204, -0.38809925944036294, -0.3991390991730226, -0.4098365996341595, -0.4201544300720359, -0.4301214152931845, -0.4397092343352682, -0.4489542438709355, -0.4578025906784342, -0.46626379547491226, -0.4743576739181412, -0.48209369277552216, -0.48944470860044387, -0.49637383275910896, -0.5028972621299577, -0.5090358712914496, -0.5147571050467192, -0.5200731992297456, -0.5249967920147416, -0.52950435007042, -0.5335839644418323, -0.5372800382399783, -0.5406107221916043, -0.5435630225334691, -0.546112742525457, -0.5482548400817366, -0.5500106055790921, -0.5513474211133573, -0.552269891337458, -0.5528542738990385, -0.5530488695101416, -0.5528593001097786, -0.5522838417470624, -0.5513493326285159, -0.550047297575472, -0.5484178384984304, -0.5464666154045812, -0.5442167669467626, -0.541633446944914, -0.5387415522672949, -0.5355502335365605, -0.5320461977478548, -0.5282122822471198, -0.5240957616700941, -0.5196918873461343, -0.5150252369700068, -0.5100976508534334, -0.504914091219284, -0.49951227133623544, -0.4938705354434756, -0.4880244101262683, -0.48197175870533915, -0.4756738485377001, -0.4691357073500706, -0.46239131281983425, -0.45549141865557896, -0.44841331506319104, -0.44114802004284215, -0.4336936638147737, -0.4260695587454988, -0.4183168883524333, -0.4104336535153319, -0.40247214830014233, -0.3943772965222472, -0.38618389680694953, -0.3779000501795302, -0.369542970165905, -0.3611339381001404, -0.3526633550522842, -0.3441350697888872, -0.33556549420714266, -0.32694650443820716, -0.3182891299997408, -0.3095803032646902, -0.30086247273766364, -0.29213577568327054, -0.28338433490903636, -0.27460519532243044, -0.26579881400544725, -0.2569558925715274, -0.2480922406193189, -0.23923642382549115, -0.23040907998584892, -0.22164979018726338, -0.2129512353159324, -0.20437218798358714, -0.19588980545213275, -0.1874927054413904, -0.17919853506120376, -0.17102218547308823, -0.16298165591759428, -0.1550476086897996, -0.14722955808870353, -0.13953445572123258, -0.13198014331075392, -0.12457864294413312, -0.11735022171037102, -0.11028144299020237, -0.10335990277849394, -0.09658420302207027, -0.08996480700367293, -0.083472364718153, -0.07716733350696359, -0.07104828361231696, -0.06506959712920501, -0.059249582664208766, -0.053620341631392954, -0.048182706420916155, -0.04293853086005672, -0.037888106800744836, -0.03303043052529375, -0.0283705175646336, -0.023908930224147973, -0.019638233602796262, -0.01554222107007508, -0.011608469520673736, -0.007836197651287513, -0.004241460173362022, -0.0007925673267239475, 0.0025100771270709643, 0.005656339672628796, 0.008637241740101942, 0.011443735212668393, 0.01410868132010723, 0.01662863376132684, 0.018991078917578896, 0.02120738560531521, 0.02328492689061612, 0.025212654713334892, 0.027017307362492637, 0.02868461210615525, 0.030195090519889334, 0.031560459367777405, 0.032806806171264746, 0.03395349555150151, 0.03500125903044271, 0.03592642030398885, 0.03676120566191443, 0.03749999620790323, 0.0381850906852339, 0.03881871776166168, 0.03945014617005427, 0.040060306625298914, 0.040637097250050935, 0.04121270750015338, 0.04178348528556519, 0.04235669306716705, 0.042978478794061026, 0.043626717315600416, 0.044302925130375925, 0.04502454736998995, 0.0458113577851309, 0.046686710671465015, 0.04763385029185496, 0.048661189705260455, 0.049786790182304586, 0.051024332301333075, 0.05241857893029955, 0.05396508476078665, 0.05568794906576979, 0.05758931118410526, 0.05970481673022654, 0.06202733918371983, 0.06455144395501922, 0.06730401359826477, 0.07029641690307109, 0.0735406217952681, 0.07701517314141437, 0.08073009531000164, 0.08469701380759087, 0.08892036397696401, 0.0934178936429273, 0.09817705681113509, 0.10320540156598845, 0.10852037303379802, 0.11412401582836562, 0.1200291897674921, 0.12620182756231735, 0.13270796582649336, 0.13952326949748883, 0.14666089077519384, 0.15411806111348536, 0.1618875563458122, 0.16996197057874962, 0.17834558558242186, 0.18705417580945127, 0.19608956209317707, 0.2054392628423054, 0.21514732604374043, 0.22523095425570716, 0.23565965617895213, 0.24643620896842489, 0.2575811587074499, 0.26909066220077005, 0.2809340449939395, 0.29311933470503604, 0.3056407266278045, 0.31848485359396683, 0.3316338130600016, 0.34509385358946165, 0.35885050619251135, 0.37289262539483126, 0.3872300178403991, 0.4018557890786889, 0.4167799411251023, 0.4319907359977071, 0.44746144700392954, 0.4629364739236088, 0.47865123232731044, 0.4945840664101322, 0.5107334315194008, 0.5270671475110014, 0.5435979454152129, 0.5603181383035354, 0.5772188013671737, 0.5942611166073091, 0.6114544592346958, 0.6288069330491508, 0.6463066356907259, 0.663953043268851, 0.6817178744057477, 0.6995818563831602, 0.7175295389064624, 0.735576227707865, 0.7537161635266374, 0.7719473822879133, 0.7902476717720868, 0.8086134862723489, 0.8270461409536658, 0.845526438809209, 0.8640619366963556, 0.8826264289174279, 0.9012067486708082, 0.9198218803897955, 0.9384685510975626, 0.9571391241899354, 0.9758229133051533, 0.9945249885579974, 1.0132301462470839, 1.0319490131198448, 1.0506720100610725, 1.0693935020634777, 1.0881232688612092, 1.1068520570498173, 1.1255739626758112, 1.1443174469086044, 1.1630675248801285, 1.1818187966043143, 1.2005750472056245, 1.2193265207598074, 1.2380696737517072, 1.256817732505385, 1.2755517539201264, 1.2942912308650123, 1.31305007435481, 1.331836310664411, 1.3506471258674395, 1.369521134955344, 1.3884544748492367, 1.4074438281681334, 1.426501885263637, 1.4456551726548152, 1.4649125679571688, 1.4842794765433367, 1.5037505320642275, 1.5233176719242674, 1.5429897751264083, 1.5627605805152913, 1.5826733652490277, 1.6027406516470282, 1.6229429200594514, 1.6433093124543352, 1.6638342210130137, 1.6845263155193542, 1.7053779575212769, 1.726420998166685, 1.7476618301359959, 1.7691034087581792, 1.790750151841947, 1.8126234133759853, 1.8347298990315357, 1.857065564955653, 1.8796456030103839, 1.9024903779121822, 1.9255998317576228, 1.9489700881803844, 1.9725982058669072, 1.99648714841861, 2.0206377713547217, 2.0450496595328236, 2.0697293313669913, 2.0946630726456754, 2.1198510723615334, 2.1452860223377153, 2.1709702949359966, 2.1969046133824763, 2.2230934996106035, 2.249504295036986, 2.2761415880866886, 2.303009466180287, 2.3300978431686272, 2.357377643761698, 2.384836504572408, 2.4124654848497835, 2.440240682168646, 2.4681715864268186, 2.496212379696709, 2.52439509066737, 2.5526745170402276, 2.581048755260904, 2.6095162778278316, 2.6380556642929656, 2.6666623609689286, 2.6953104198854407, 2.7239949853448815, 2.7527057750583825, 2.7814186521817144, 2.8101276317944492, 2.838834686954178, 2.8675017045361093, 2.8961150751795985, 2.9246617117894496, 2.95312714268323, 2.9814621064152194, 3.0096845610834095, 3.0377836788495305, 3.065740200076473, 3.0934951152709362, 3.1210349071595083, 3.148326230576703, 3.1753628892281345, 3.202113141026686, 3.2285861916326812, 3.2547560647642224, 3.2806090328105224, 3.306128222530088, 3.3312952854353877, 3.356105695979948, 3.380540970369125, 3.4045793439830447, 3.4282319163954984, 3.451450450012114, 3.4742558978060187, 3.496634053842495, 3.518588811967639, 3.5400887036042525, 3.5611135384407357, 3.581645452991944, 3.6016830561098656, 3.6212137825444186, 3.6402414468949416, 3.658777910387085, 3.6768067327659733, 3.6943307925485396, 3.711345020030393, 3.727845914868478, 3.743831168554827, 3.759315720732167, 3.7742948476111433, 3.7887633150465563, 3.802721819355199, 3.8161674208228233, 3.829099030063265, 3.8415467209961207, 3.8535044293137553, 3.8649854779807553, 3.875971028142647, 3.886498336692626, 3.896561370568719, 3.906185108641048, 3.9153848122909682, 3.924199368790967, 3.9326528914239396, 3.940767981146801, 3.948557768037144, 3.9557940323411342, 3.9627536165951223, 3.969449491232667, 3.975905789020154, 3.9821578852747805, 3.988198687531312, 3.994057812845595, 3.9997502765049253, 4.005298098497015, 4.0107023112782665, 4.015985852228544, 4.0211744580278115, 4.026281477805665, 4.031338356578063, 4.036362217242768, 4.04137163623995, 4.04637716674905, 4.051408874891759, 4.056459260543143, 4.061563663239284, 4.066752506733563, 4.072018428651692, 4.077404439077036, 4.082916417980655, 4.088595819800009, 4.094456714239299, 4.10051661366489, 4.1067927694000765, 4.113296832418889, 4.120040142299676, 4.127064798319145, 4.134374558483721, 4.141978289531553, 4.149882292839871, 4.158107547055755, 4.166663948746156, 4.17556056177306, 4.184797148562575, 4.194392373754136, 4.204390635143858, 4.214787576533694, 4.225610155496263, 4.236852774942971, 4.248512571571648, 4.260604897523799, 4.273147211691818, 4.286147332678192, 4.299606722076587, 4.31350221004691, 4.327839530062872, 4.342618608908508, 4.35782110719585, 4.373459483657236, 4.389514671635058, 4.405984203732849, 4.4228346599669, 4.44010044173818, 4.457788474952049, 4.4758487750287355, 4.494295635205728, 4.5131086738830355, 4.532272628707914, 4.551809684843839, 4.571684713763421, 4.591882296444845, 4.612406157859424, 4.633235935574602, 4.654376398026927, 4.675805181829691, 4.697506790748842, 4.719467111701607, 4.741655753256102, 4.764060920641797, 4.78666717782126, 4.809478884672734, 4.832473902843707, 4.855632127011756, 4.878925037325728, 4.902347355798525, 4.925874952835992, 4.949503031578748, 4.973210901126017, 4.99699528115923, 5.020849779730271, 5.044747649829458, 5.068695307275491, 5.092683588038849, 5.116681913156329, 5.140684340966639, 5.164684808846363, 5.1886680887699095, 5.21262888545562, 5.236526762191566, 5.260374128089583, 5.284150235270889, 5.307858344730651, 5.331488648874958, 5.35502530190897, 5.378455860061894, 5.401765046193967, 5.424932691217991, 5.447956607914445, 5.470837489028084, 5.493545768350251, 5.516103333987559, 5.538483572534417, 5.5606664185569805, 5.582661496091443, 5.60447252014162, 5.626116234242191, 5.647587573633956, 5.668885885642352, 5.690011037369788, 5.710957256056015, 5.731721324491942, 5.752296004460003, 5.772642408577832, 5.7927878720062385, 5.812726422443479, 5.8324546116558045, 5.851973815253989, 5.871310237443233, 5.890461412740512, 5.9094405163101085, 5.928252220023701, 5.946913007550539, 5.965411721742322, 5.983758337450197, 6.001965802816761, 6.020048312753478, 6.03802041000197, 6.055888244788542, 6.073642999877825, 6.091274546279874, 6.108786416302288, 6.126179153906693, 6.143476295749461, 6.1606729930395625, 6.1777956845184026, 6.194824202869887, 6.211756228225719, 6.228579099410593, 6.24530383060172, 6.261949271223591, 6.278529259921812, 6.295057401625629, 6.3115426076428935, 6.32796844030063, 6.344332891049305, 6.360641720063732, 6.376900474942685, 6.393113323498879, 6.409295778839712, 6.4254348631469576, 6.441543344410688, 6.457632718371999, 6.4736980963089845, 6.489736163828759, 6.505762821318111, 6.521769594200945, 6.537766272995924, 6.553754387109886, 6.569746659958873, 6.585732585987243, 6.601717399774265, 6.617698895401314, 6.633687722218323, 6.649676677348454, 6.665671992163846, 6.681663569480333, 6.697675425810204, 6.71366830676372, 6.7296661984481885, 6.745649533322267, 6.761628866965974, 6.777603317004562, 6.79356074803932, 6.809497405311357, 6.825406467987177, 6.841291753761727, 6.857153716366222, 6.87327019834236, 6.8891196821151475, 6.9049603772904184, 6.920784204414174, 6.936569455836993, 6.952323270299754, 6.968020987861997, 6.983682447775578, 6.999308352335186, 7.0149016167057665, 7.030445014481293, 7.045922056634009, 7.061331899512651, 7.076667186962082, 7.091928415560223, 7.107105073641739, 7.122191636928107, 7.137194196740436, 7.152110838752865, 7.166943385173295, 7.181677685270958, 7.19631877989777, 7.210842883072537, 7.225236974146121, 7.239512789851938, 7.25365043550004, 7.267651113961876, 7.281534177949654, 7.295276352831944, 7.3088737550353535, 7.32234093049507, 7.33565236212063, 7.348812885407078, 7.361802997961519, 7.374635598493401, 7.387300077882667, 7.399790922143422, 7.412112769321462, 7.424255672171638, 7.436212438485514, 7.447961970398144, 7.459530521986364, 7.470910970045697, 7.482104981455491, 7.493095668388068, 7.5038703271365765, 7.514436955074873, 7.5247923648781425, 7.534920716223899, 7.54480018752558, 7.5544378531688645, 7.5638380033071115, 7.572992542910992, 7.581912707983708, 7.590592473999202, 7.59904843743835, 7.607283056198263, 7.615281649483524, 7.623052895942495, 7.6306135718531305, 7.637975841975809, 7.64512727785181, 7.6520657753129235, 7.658797684438506, 7.665333942585685, 7.671673222935535, 7.677800135796611, 7.683728020584755, 7.689466031240101, 7.695028101226484, 7.700396057686372, 7.705625742089925, 7.710695804312934, 7.715598518837528, 7.720298387728985, 7.724844475831009, 7.729223394404715, 7.733446029931658, 7.737522022186092, 7.741455023278387, 7.745257322079524, 7.748911936269671, 7.752431435472415, 7.755824321998885, 7.759097237936185, 7.762270018868647, 7.765354498790359, 7.768361486528565, 7.77127400879402, 7.7740951691607645, 7.77681214373135, 7.779441454156451, 7.781998862603111, 7.784487589547273, 7.786924769589227, 7.789313292874811, 7.7916596834993825, 7.793986491023647, 7.796280670880405, 7.798552232882669, 7.800802349521581, 7.80304060008198, 7.80526538162313, 7.807480727737374, 7.809690954535394, 7.811908870593307, 7.814140058566018, 7.816402278169571, 7.81894566134009, 7.821489297878458, 7.824051550110368, 7.826642146904509, 7.829267275594717, 7.83193182248565, 7.83465190761974, 7.837444060083652, 7.840298723960646, 7.843204143918103, 7.846178622907703, 7.849214263600073, 7.85232801546743, 7.8554921753620786, 7.858725209977139, 7.8620392619167525, 7.865448322648808, 7.868951681614513, 7.872541017461527, 7.876229029456702, 7.880001088416023, 7.883864478135862, 7.8877866147992375, 7.891769928550966, 7.895819373760435, 7.899921682374872, 7.90409815054551, 7.908334399972537, 7.912617147881894, 7.916940391373447, 7.921289909107543, 7.925646392541681, 7.930009916221271, 7.934390192212282, 7.938771629135333, 7.9431431076060255, 7.947506738807029, 7.95187424825926, 7.956216988159688, 7.960512475738627, 7.964759261454546, 7.968921631059087, 7.973011616326444, 7.97703066912135, 7.980945669190648, 7.9847233369635155, 7.9883932405617095, 7.991931599433519, 7.995293427830118, 7.9984589096902035, 8.001439200655822, 8.004225703783607, 8.006777488215373, 8.009093321589745, 8.011160124285103, 8.012956855795672, 8.014470252992947, 8.015683943798575, 8.016587650965736, 8.017151975775754, 8.017343408097819, 8.017120818568046, 8.016452610581219, 8.01533752201683, 8.013744947349055, 8.011653042590664, 8.009050507280909, 8.005904189621424, 8.00220310918984, 7.9979076537792615, 7.9929944904440475, 7.987425419647527, 7.981187702526022, 7.974260134337445, 7.96662493484892, 7.9582531280605675, 7.949099829328734, 7.93914856023984, 7.928370608037593, 7.9167585879390225, 7.904276987036025, 7.890905922935797, 7.876618511858066, 7.861398680206658, 7.845237063843355, 7.828085312837339, 7.80992897133417, 7.790775260275799, 7.770578668978921, 7.74929724431245, 7.726919114332139, 7.703412803266841, 7.67877329424074, 7.652960849239776, 7.625952896618799, 7.597722083513941, 7.568256819267248, 7.5375371388028904, 7.505576945210936, 7.472377771870976, 7.4379098941015425, 7.402125141198612, 7.364980158276749, 7.3264830749392935, 7.286589346882032, 7.2453307538895775, 7.2026702104080496, 7.15861045363282, 7.113137902185635, 7.066241083881112, 7.0179058691585166, 6.968119543970922, 6.916888354767877, 6.864188494274936, 6.810012313496776, 6.754376006558784, 6.697285417842165, 6.638705568125014, 6.578655635528993, 6.517119604244489, 6.454079861165431, 6.389543415388203, 6.323515661360698, 6.255976890552834, 6.186929855548945, 6.11638272516103, 6.044315753512999, 5.970717933643774, 5.895595789339931, 5.818955235804846, 5.740799655256505, 5.6611355272249675, 5.5799531980238, 5.497277315197123, 5.413127475249691, 5.32749372784474, 5.240419232023394, 5.151884065059343, 5.061869334108876, 4.970400196409905, 4.8774850942554675, 4.783159072093239, 4.687421331227439, 4.590273573138612, 4.491730238937365, 4.391840097614658, 4.290524173035556, 4.187860715795671, 4.08386536348168, 3.9785266080394903, 3.8719031356732856, 3.764257417369547, 3.6553586840150643, 3.5452299727079195, 3.4338905951735956, 3.3213520298561434, 3.2076468092673975, 3.092780087644657, 2.976787355190663, 2.8596891218806264, 2.7415159090006185, 2.622293859974244, 2.502043312953286, 2.3808081216080588, 2.2583468580117554, 2.1349178211802995, 2.0105184739940465, 1.8851986010656123, 1.7589597181169965, 1.6318189020501839, 1.5038067826804307, 1.3749592740673604, 1.2452726486252796, 1.1147827801288486, 0.9835191836795385, 0.851484451901432, 0.7187282474061654, 0.5852722149348359, 0.45114421730314547, 0.3163745380602201, 0.18095655768443386, 0.044683360735413125, -0.09190310120783884, -0.22906188049069165, -0.36677057745114183, -0.5049997768616175, -0.6437334778430124, -0.7829372217243478, -0.9225745572229354, -1.062641878049421, -1.2031202161312544, -1.3439863015060576, -1.4852120926864831, -1.62676219275731, -1.7685957549293683, -1.9106925540790254, -2.0530309717194912, -2.1955830450790152, -2.338272350192784, -2.4810392304246944, -2.6240352078641624, -2.7672641573242895, -2.9106311731996266, -3.0540496959843617, -3.1974961324939875, -3.3409747734074395, -3.4844565087204424, -3.627887132260626, -3.771263165523181, -3.9145770283920696, -4.057804133783196, -4.200928081875941, -4.343920093904507, -4.486747977656026, -4.6293842377479235, -4.771773941884963, -4.9139233348856175, -5.055806330561592, -5.197393588492321, -5.338669019397588, -5.479600153402216, -5.620185064366454, -5.760409034373612, -5.900243285631915, -6.0396569992403935, -6.1786042541137265, -6.317036101988431, -6.454967064384117, -6.592386989125976, -6.729262777128624, -6.865575881492792, -7.0013270399650205, -7.136465963056385, -7.270949914908505, -7.404801802654549, -7.537995167539491, -7.67056250715502, -7.802428642215054, -7.933572009582776, -8.063952620722809, -8.193563804112497, -8.32238549972812, -8.450371501511452, -8.577510395995226, -8.70378396810889, -8.829202281734297, -8.953719996461896, -9.077313329399654, -9.199934192831005, -9.321578283197411, -9.442242281681214, -9.561907651357444, -9.680564704961885, -9.798167021184035, -9.914695138622495, -10.030092748438715, -10.14439086931959, -10.257572792878392, -10.369634460697103, -10.480548695435157, -10.59027456211922, -10.698781301736144, -10.806050810073629, -10.912098630358742, -11.016899043662406, -11.120428345014314, -11.22268706420589, -11.32367389303214, -11.42336925924327, -11.521741619558252, -11.618760737352908, -11.714431240880742, -11.808737878143397, -11.901690700870418, -11.993269713200977, -12.083447290109149, -12.172205068199744, -12.259556300809745, -12.345502230746611, -12.430003462513447, -12.513035724972848, -12.594595009291435, -12.674684566884999, -12.75328662580841, -12.830410461154464, -12.906031472989167, -12.980181134650092, -13.052849337965988, -13.124020960138093, -13.193710743388607, -13.261885507626175, -13.32853757422625, -13.393677195485566, -13.457307466206533, -13.519406910608826, -13.580000232660673, -13.639066337756354, -13.69660438011913, -13.75258971290851, -13.807062645207111, -13.860005646892109, -13.911438625126305, -13.961335108611898, -14.009687165514556, -14.056490535261197, -14.101769456175365, -14.145515154534312, -14.187714601550365, -14.228392200831497, -14.267548457681805, -14.305191883618303, -14.341316206320329, -14.375951717527332, -14.40908747606268, -14.440709741847293, -14.470855901100844, -14.499527387853835, -14.526716984492978, -14.552450373049577, -14.576716034478046, -14.599503061584404, -14.620827819803303, -14.640709257476022, -14.659123985472366, -14.676086648585184, -14.691620955370482, -14.705740943287068, -14.718434825751139, -14.729690883817813, -14.739548357033751, -14.748007332384319, -14.755102712038791, -14.760854736672158, -14.765227524904557, -14.7682029831319, -14.76983644330689, -14.770120510598055, -14.769036889524056, -14.766551727669174, -14.762768405652906, -14.7575909679972, -14.75108920914537, -14.743263835351158, -14.734095253536754, -14.723604679540113, -14.71183397316494, -14.698794463221205, -14.684484798797055, -14.668907733771661, -14.652058264642232, -14.63386857659885, -14.614388277662151, -14.593624085068999, -14.571582389428144, -14.548292710379645, -14.523785918961966, -14.498036883870313, -14.471064049833881, -14.442878815617263, -14.413477742973871, -14.382867683686609, -14.351066306937206, -14.318090221675547, -14.283947519975488, -14.248686444581974, -14.212269831970598, -14.174708418420916, -14.136006593141438, -14.096165803543993, -14.05517845023314, -14.013079043206293, -13.96988060714936, -13.92558919950542, -13.88023306676024, -13.833804051385545, -13.786313287431817, -13.73779379406022, -13.688237182399412, -13.6376481765672, -13.586045633864579, -13.53343233774305, -13.479857496262373, -13.42529302030982, -13.369738775198048, -13.313223042871016, -13.255769707916592, -13.197392819578187, -13.138120760557523, -13.077997164890828, -13.017021527890861, -12.955184145879876, -12.892501027586462, -12.828996669562233, -12.764668088096837, -12.69956876900173, -12.633694842350412, -12.567085361822219, -12.499746640058728, -12.4317107423992, -12.362988241368278, -12.293647757220587, -12.223669970379827, -12.153052457299669, -12.08179275453081, -12.00989693884872, -11.937421317577265, -11.864385626322484, -11.79081870518883, -11.716710187402064, -11.642091637660041, -11.567000413424761, -11.491448310745909, -11.415432360484118, -11.339028613680302, -11.262232729753002, -11.185043202719879, -11.107473595085825, -11.02956129119303, -10.951344347387941, -10.872850104759316, -10.794061337105187, -10.714994130006946, -10.635669719585835, -10.555940535129263, -10.476150786812344, -10.396198871178377, -10.315920467710146, -10.235478230111436, -10.154895154027216, -10.074144331147288, -9.993285609243099, -9.912343359539243, -9.83126822091991, -9.750125125140581, -9.668967659247958, -9.587729655437435, -9.50649558213232, -9.425274232105572, -9.344051261553723, -9.262905766170604, -9.182098581636133, -9.101368505953456, -9.020742455503232, -8.940241540557974, -8.859771096009556, -8.779550457335745, -8.69947418238704, -8.619586313168803, -8.54007673011968, -8.460771686137377, -8.381690644371616, -8.302836942507604, -8.224226340725789, -8.145610871628719, -8.06725989330123, -7.989197770430397, -7.91145700384905, -7.834031234838814, -7.7569243849009775, -7.680090939246186, -7.603598742339076, -7.527419033829214, -7.451536214714232, -7.37598034084465, -7.300750881098, -7.225883722344384, -7.151405514227389, -7.077273717977611, -7.0034903022206665, -6.930016785879897, -6.8568801236093, -6.784101908797891, -6.711673610933565, -6.639580903833017, -6.567809285672282, -6.496390182076957, -6.4253030974016605, -6.354539764685335, -6.284116799036192, -6.214022708280884, -6.1442439542338585, -6.074792427286082, -6.005676574916138, -5.936917134803857, -5.8684823666701496, -5.800396795545974, -5.732657963986187, -5.665283858587622, -5.5982928015955755, -5.531504640593467, -5.464885570592741, -5.398547252790418, -5.332505918255953, -5.266765896808763, -5.201279077373612, -5.136067519191621, -5.071134184415638, -5.0064684769695615, -4.942022832096064, -4.877807708507546, -4.813841560300703, -4.750110509234772, -4.6865788406983855, -4.623268674374663, -4.560172417234116, -4.497256038401692, -4.434516945017596, -4.37198307669784, -4.309614345054462, -4.24737831194036, -4.185275111509692, -4.123308703172444, -4.061498271955803, -3.9998452826090807, -3.938364597979837, -3.8770715760291106, -3.8158869625139653, -3.75482814939038, -3.6939017461809245, -3.633104494175824, -3.572422544627929, -3.5118686331271602, -3.4514417291896793, -3.391105175637061, -3.33085662763808, -3.2706644535590366, -3.210564472705694, -3.1505255393658134, -3.090595089361373, -3.030784776034543, -2.9710677858952232, -2.9114488675939567, -2.8519115236690658, -2.7924682498015514, -2.7330945412353937, -2.6737927827993246, -2.6145903132655226, -2.555479605324331, -2.4964781440068666, -2.4375885570113676, -2.3788410795812363, -2.3202457448821443, -2.2617815677787503, -2.203457662702898, -2.145299333500131, -2.0873197702736963, -2.0294919082964276, -1.9717805938876154, -1.9142245066933397, -1.8568136742137167, -1.7996380741122202, -1.7426846481161986, -1.685928632387176, -1.629378900531563, -1.5730413166475197, -1.5169323041228147, -1.46105355709859, -1.4054193209330466, -1.3500540530762928, -1.2949755958261102, -1.24018716942905, -1.185698063928995, -1.131506633962779, -1.0776488646316222, -1.0241454299134904, -0.9710433891809478, -0.9183473328835738, -0.8660639766846874, -0.8142059251043499, -0.7627949209397533, -0.7118126670731417, -0.6612717594267892, -0.6111533672085381, -0.5614897627249151, -0.5123384363305004, -0.4636641104533883, -0.41549168031275574, -0.3678385863455178, -0.320725900639073, -0.2742040001262591, -0.22829380639239094, -0.1829868441374778, -0.1382696376442718, -0.09414900627380351, -0.050622094526013406, -0.007751381000567825, 0.03445988682637324, 0.07599122349029575, 0.11682186102432546, 0.15697528867170618, 0.19644563118237013, 0.2351999556961859, 0.27320424076254746, 0.31045757286785935, 0.34698822891148584, 0.3827600147130701, 0.4177730485207958, 0.4520142849167694, 0.48550430472887474, 0.5182445005583665, 0.5502377472605922, 0.5814743648784777, 0.6119285859263011, 0.6415655799336655, 0.670417256254467, 0.6984588188693044, 0.7257010866834444, 0.7521590474701147, 0.7778389865224531, 0.8027533965107088, 0.8268768749466062, 0.8502128346679605, 0.8727334265035829, 0.8944655897662903, 0.9154222825588736, 0.9356278987012869, 0.9550638855212066, 0.9737301639886065, 0.9916720050658316, 1.008889965651921, 1.0253839694226334, 1.041179550556289, 1.0562518726346566, 1.0706324417351967, 1.084330746540763, 1.0973625099638076, 1.1097217690284014, 1.1213870039737506, 1.1324252633117666, 1.1427401265360402, 1.152425155391735, 1.1614885204217442, 1.1699127577661153, 1.1777316650004805, 1.1849582222994965, 1.1916108000606678, 1.1977126483395568, 1.2032768985790132, 1.208301878661445, 1.212734554984694, 1.21664243700911, 1.2200363267244088, 1.2229342319324372, 1.2253529958844038, 1.2272907479654895, 1.2287507356757676, 1.229740045324712, 1.2302892986588305, 1.2303856813048624, 1.2300675174519462, 1.2293726760972996, 1.228279358242792, 1.226785820951462, 1.2249398529305005, 1.222758473758922, 1.2202368961687151, 1.2173716250827238, 1.2141736050707, 1.2106288530440175, 1.206794168504215, 1.202675686050385, 1.1982649439997863, 1.1935637263524406, 1.1885704607636307, 1.183315912626421, 1.1777842791228315, 1.171987508247327, 1.1659523074536935, 1.159659449123942, 1.1531345540700704, 1.1464149987774563, 1.1394644340117335, 1.1322636539580975, 1.1248612182238924, 1.1172594138617544, 1.109436637138753, 1.101375709286006, 1.093109108282352, 1.0846401637478502, 1.0759656075562258, 1.0670843721705747, 1.0580174790809895, 1.0487324633768313, 1.0392259502935204, 1.0295178166433816, 1.0196072827971738, 1.0094875527245062, 0.999169455280077, 0.9886479311855743, 0.9779767069765279, 0.9671028689360028, 0.9560018201387699, 0.9446607300011074, 0.933079234429786, 0.9215312795991704, 0.9097974115686389, 0.8978644630148587, 0.8857290906542019, 0.8734238605470503, 0.8609503753644789, 0.848277859424817, 0.8354109482954186, 0.8224068177077557, 0.8092112246738852, 0.7957937752514894, 0.7821735889293437, 0.7683382509540877, 0.7543227280843334, 0.7401402479320014, 0.7257431542167705, 0.7111395217518783, 0.6963147428391832, 0.6811107107135195, 0.6658901601055254, 0.6504851046120992, 0.6347440514060079, 0.6188388929833426, 0.602755954322288, 0.5864772340222943, 0.5700423890427571, 0.5534426437782782, 0.536623897553727, 0.5196381257979388, 0.5024968013523514, 0.4852114233724514, 0.4678040586345329, 0.4502725089179105, 0.4326091363543707, 0.41484551860338303, 0.3969936199319619, 0.37905974130203735, 0.36106010329302674, 0.3429903372757961, 0.3247586324494529, 0.30657856680305784, 0.28832420527900027, 0.27002742547965664, 0.2518764113645222, 0.23367151290862598, 0.21545730361342752, 0.197230891641051, 0.17899128596483305, 0.16073975342216773, 0.14249911292062034, 0.1243043826797452, 0.10615858098888342, 0.08809363612952126, 0.07010736625323855, 0.05213028980236434, 0.03424466211425781, 0.016467579506869612, -0.0012078422143222411, -0.01875121442663108, -0.03614146583500677, -0.053362299047956085, -0.07040329914476207, -0.08730844602068899, -0.10403718570288145, -0.120607912155271, -0.1369929071464835], "l0": 20825.28328342407, "b0": 0.0, "sigma0": [9.684516563073734], "last_observatory": "BOU", "last_channel": "H", "last_delta": 60.0, "next_starttime": "2018-10-24T00:00:00.000000Z"} \ No newline at end of file diff --git a/etc/controller/sqdistBOU_u_state.json b/etc/controller/sqdistBOU_u_state.json new file mode 100755 index 000000000..be2585bd9 --- /dev/null +++ b/etc/controller/sqdistBOU_u_state.json @@ -0,0 +1,1454 @@ +{ + "yhat0": [], + "s0": [ + -0.15316247952645945, + -0.16910664005994924, + -0.18483375871067498, + -0.2003470197560775, + -0.2155958582076405, + -0.23057931720052682, + -0.24532398894595353, + -0.25980439660330035, + -0.2740174684957921, + -0.28795551129887276, + -0.3016061067330389, + -0.3149577898281022, + -0.3279802034537047, + -0.3406859114489489, + -0.35303637397002774, + -0.3650402741249348, + -0.37672630042314204, + -0.38809925944036294, + -0.3991390991730226, + -0.4098365996341595, + -0.4201544300720359, + -0.4301214152931845, + -0.4397092343352682, + -0.4489542438709355, + -0.4578025906784342, + -0.46626379547491226, + -0.4743576739181412, + -0.48209369277552216, + -0.48944470860044387, + -0.49637383275910896, + -0.5028972621299577, + -0.5090358712914496, + -0.5147571050467192, + -0.5200731992297456, + -0.5249967920147416, + -0.52950435007042, + -0.5335839644418323, + -0.5372800382399783, + -0.5406107221916043, + -0.5435630225334691, + -0.546112742525457, + -0.5482548400817366, + -0.5500106055790921, + -0.5513474211133573, + -0.552269891337458, + -0.5528542738990385, + -0.5530488695101416, + -0.5528593001097786, + -0.5522838417470624, + -0.5513493326285159, + -0.550047297575472, + -0.5484178384984304, + -0.5464666154045812, + -0.5442167669467626, + -0.541633446944914, + -0.5387415522672949, + -0.5355502335365605, + -0.5320461977478548, + -0.5282122822471198, + -0.5240957616700941, + -0.5196918873461343, + -0.5150252369700068, + -0.5100976508534334, + -0.504914091219284, + -0.49951227133623544, + -0.4938705354434756, + -0.4880244101262683, + -0.48197175870533915, + -0.4756738485377001, + -0.4691357073500706, + -0.46239131281983425, + -0.45549141865557896, + -0.44841331506319104, + -0.44114802004284215, + -0.4336936638147737, + -0.4260695587454988, + -0.4183168883524333, + -0.4104336535153319, + -0.40247214830014233, + -0.3943772965222472, + -0.38618389680694953, + -0.3779000501795302, + -0.369542970165905, + -0.3611339381001404, + -0.3526633550522842, + -0.3441350697888872, + -0.33556549420714266, + -0.32694650443820716, + -0.3182891299997408, + -0.3095803032646902, + -0.30086247273766364, + -0.29213577568327054, + -0.28338433490903636, + -0.27460519532243044, + -0.26579881400544725, + -0.2569558925715274, + -0.2480922406193189, + -0.23923642382549115, + -0.23040907998584892, + -0.22164979018726338, + -0.2129512353159324, + -0.20437218798358714, + -0.19588980545213275, + -0.1874927054413904, + -0.17919853506120376, + -0.17102218547308823, + -0.16298165591759428, + -0.1550476086897996, + -0.14722955808870353, + -0.13953445572123258, + -0.13198014331075392, + -0.12457864294413312, + -0.11735022171037102, + -0.11028144299020237, + -0.10335990277849394, + -0.09658420302207027, + -0.08996480700367293, + -0.083472364718153, + -0.07716733350696359, + -0.07104828361231696, + -0.06506959712920501, + -0.059249582664208766, + -0.053620341631392954, + -0.048182706420916155, + -0.04293853086005672, + -0.037888106800744836, + -0.03303043052529375, + -0.0283705175646336, + -0.023908930224147973, + -0.019638233602796262, + -0.01554222107007508, + -0.011608469520673736, + -0.007836197651287513, + -0.004241460173362022, + -0.0007925673267239475, + 0.0025100771270709643, + 0.005656339672628796, + 0.008637241740101942, + 0.011443735212668393, + 0.01410868132010723, + 0.01662863376132684, + 0.018991078917578896, + 0.02120738560531521, + 0.02328492689061612, + 0.025212654713334892, + 0.027017307362492637, + 0.02868461210615525, + 0.030195090519889334, + 0.031560459367777405, + 0.032806806171264746, + 0.03395349555150151, + 0.03500125903044271, + 0.03592642030398885, + 0.03676120566191443, + 0.03749999620790323, + 0.0381850906852339, + 0.03881871776166168, + 0.03945014617005427, + 0.040060306625298914, + 0.040637097250050935, + 0.04121270750015338, + 0.04178348528556519, + 0.04235669306716705, + 0.042978478794061026, + 0.043626717315600416, + 0.044302925130375925, + 0.04502454736998995, + 0.0458113577851309, + 0.046686710671465015, + 0.04763385029185496, + 0.048661189705260455, + 0.049786790182304586, + 0.051024332301333075, + 0.05241857893029955, + 0.05396508476078665, + 0.05568794906576979, + 0.05758931118410526, + 0.05970481673022654, + 0.06202733918371983, + 0.06455144395501922, + 0.06730401359826477, + 0.07029641690307109, + 0.0735406217952681, + 0.07701517314141437, + 0.08073009531000164, + 0.08469701380759087, + 0.08892036397696401, + 0.0934178936429273, + 0.09817705681113509, + 0.10320540156598845, + 0.10852037303379802, + 0.11412401582836562, + 0.1200291897674921, + 0.12620182756231735, + 0.13270796582649336, + 0.13952326949748883, + 0.14666089077519384, + 0.15411806111348536, + 0.1618875563458122, + 0.16996197057874962, + 0.17834558558242186, + 0.18705417580945127, + 0.19608956209317707, + 0.2054392628423054, + 0.21514732604374043, + 0.22523095425570716, + 0.23565965617895213, + 0.24643620896842489, + 0.2575811587074499, + 0.26909066220077005, + 0.2809340449939395, + 0.29311933470503604, + 0.3056407266278045, + 0.31848485359396683, + 0.3316338130600016, + 0.34509385358946165, + 0.35885050619251135, + 0.37289262539483126, + 0.3872300178403991, + 0.4018557890786889, + 0.4167799411251023, + 0.4319907359977071, + 0.44746144700392954, + 0.4629364739236088, + 0.47865123232731044, + 0.4945840664101322, + 0.5107334315194008, + 0.5270671475110014, + 0.5435979454152129, + 0.5603181383035354, + 0.5772188013671737, + 0.5942611166073091, + 0.6114544592346958, + 0.6288069330491508, + 0.6463066356907259, + 0.663953043268851, + 0.6817178744057477, + 0.6995818563831602, + 0.7175295389064624, + 0.735576227707865, + 0.7537161635266374, + 0.7719473822879133, + 0.7902476717720868, + 0.8086134862723489, + 0.8270461409536658, + 0.845526438809209, + 0.8640619366963556, + 0.8826264289174279, + 0.9012067486708082, + 0.9198218803897955, + 0.9384685510975626, + 0.9571391241899354, + 0.9758229133051533, + 0.9945249885579974, + 1.0132301462470839, + 1.0319490131198448, + 1.0506720100610725, + 1.0693935020634777, + 1.0881232688612092, + 1.1068520570498173, + 1.1255739626758112, + 1.1443174469086044, + 1.1630675248801285, + 1.1818187966043143, + 1.2005750472056245, + 1.2193265207598074, + 1.2380696737517072, + 1.256817732505385, + 1.2755517539201264, + 1.2942912308650123, + 1.31305007435481, + 1.331836310664411, + 1.3506471258674395, + 1.369521134955344, + 1.3884544748492367, + 1.4074438281681334, + 1.426501885263637, + 1.4456551726548152, + 1.4649125679571688, + 1.4842794765433367, + 1.5037505320642275, + 1.5233176719242674, + 1.5429897751264083, + 1.5627605805152913, + 1.5826733652490277, + 1.6027406516470282, + 1.6229429200594514, + 1.6433093124543352, + 1.6638342210130137, + 1.6845263155193542, + 1.7053779575212769, + 1.726420998166685, + 1.7476618301359959, + 1.7691034087581792, + 1.790750151841947, + 1.8126234133759853, + 1.8347298990315357, + 1.857065564955653, + 1.8796456030103839, + 1.9024903779121822, + 1.9255998317576228, + 1.9489700881803844, + 1.9725982058669072, + 1.99648714841861, + 2.0206377713547217, + 2.0450496595328236, + 2.0697293313669913, + 2.0946630726456754, + 2.1198510723615334, + 2.1452860223377153, + 2.1709702949359966, + 2.1969046133824763, + 2.2230934996106035, + 2.249504295036986, + 2.2761415880866886, + 2.303009466180287, + 2.3300978431686272, + 2.357377643761698, + 2.384836504572408, + 2.4124654848497835, + 2.440240682168646, + 2.4681715864268186, + 2.496212379696709, + 2.52439509066737, + 2.5526745170402276, + 2.581048755260904, + 2.6095162778278316, + 2.6380556642929656, + 2.6666623609689286, + 2.6953104198854407, + 2.7239949853448815, + 2.7527057750583825, + 2.7814186521817144, + 2.8101276317944492, + 2.838834686954178, + 2.8675017045361093, + 2.8961150751795985, + 2.9246617117894496, + 2.95312714268323, + 2.9814621064152194, + 3.0096845610834095, + 3.0377836788495305, + 3.065740200076473, + 3.0934951152709362, + 3.1210349071595083, + 3.148326230576703, + 3.1753628892281345, + 3.202113141026686, + 3.2285861916326812, + 3.2547560647642224, + 3.2806090328105224, + 3.306128222530088, + 3.3312952854353877, + 3.356105695979948, + 3.380540970369125, + 3.4045793439830447, + 3.4282319163954984, + 3.451450450012114, + 3.4742558978060187, + 3.496634053842495, + 3.518588811967639, + 3.5400887036042525, + 3.5611135384407357, + 3.581645452991944, + 3.6016830561098656, + 3.6212137825444186, + 3.6402414468949416, + 3.658777910387085, + 3.6768067327659733, + 3.6943307925485396, + 3.711345020030393, + 3.727845914868478, + 3.743831168554827, + 3.759315720732167, + 3.7742948476111433, + 3.7887633150465563, + 3.802721819355199, + 3.8161674208228233, + 3.829099030063265, + 3.8415467209961207, + 3.8535044293137553, + 3.8649854779807553, + 3.875971028142647, + 3.886498336692626, + 3.896561370568719, + 3.906185108641048, + 3.9153848122909682, + 3.924199368790967, + 3.9326528914239396, + 3.940767981146801, + 3.948557768037144, + 3.9557940323411342, + 3.9627536165951223, + 3.969449491232667, + 3.975905789020154, + 3.9821578852747805, + 3.988198687531312, + 3.994057812845595, + 3.9997502765049253, + 4.005298098497015, + 4.0107023112782665, + 4.015985852228544, + 4.0211744580278115, + 4.026281477805665, + 4.031338356578063, + 4.036362217242768, + 4.04137163623995, + 4.04637716674905, + 4.051408874891759, + 4.056459260543143, + 4.061563663239284, + 4.066752506733563, + 4.072018428651692, + 4.077404439077036, + 4.082916417980655, + 4.088595819800009, + 4.094456714239299, + 4.10051661366489, + 4.1067927694000765, + 4.113296832418889, + 4.120040142299676, + 4.127064798319145, + 4.134374558483721, + 4.141978289531553, + 4.149882292839871, + 4.158107547055755, + 4.166663948746156, + 4.17556056177306, + 4.184797148562575, + 4.194392373754136, + 4.204390635143858, + 4.214787576533694, + 4.225610155496263, + 4.236852774942971, + 4.248512571571648, + 4.260604897523799, + 4.273147211691818, + 4.286147332678192, + 4.299606722076587, + 4.31350221004691, + 4.327839530062872, + 4.342618608908508, + 4.35782110719585, + 4.373459483657236, + 4.389514671635058, + 4.405984203732849, + 4.4228346599669, + 4.44010044173818, + 4.457788474952049, + 4.4758487750287355, + 4.494295635205728, + 4.5131086738830355, + 4.532272628707914, + 4.551809684843839, + 4.571684713763421, + 4.591882296444845, + 4.612406157859424, + 4.633235935574602, + 4.654376398026927, + 4.675805181829691, + 4.697506790748842, + 4.719467111701607, + 4.741655753256102, + 4.764060920641797, + 4.78666717782126, + 4.809478884672734, + 4.832473902843707, + 4.855632127011756, + 4.878925037325728, + 4.902347355798525, + 4.925874952835992, + 4.949503031578748, + 4.973210901126017, + 4.99699528115923, + 5.020849779730271, + 5.044747649829458, + 5.068695307275491, + 5.092683588038849, + 5.116681913156329, + 5.140684340966639, + 5.164684808846363, + 5.1886680887699095, + 5.21262888545562, + 5.236526762191566, + 5.260374128089583, + 5.284150235270889, + 5.307858344730651, + 5.331488648874958, + 5.35502530190897, + 5.378455860061894, + 5.401765046193967, + 5.424932691217991, + 5.447956607914445, + 5.470837489028084, + 5.493545768350251, + 5.516103333987559, + 5.538483572534417, + 5.5606664185569805, + 5.582661496091443, + 5.60447252014162, + 5.626116234242191, + 5.647587573633956, + 5.668885885642352, + 5.690011037369788, + 5.710957256056015, + 5.731721324491942, + 5.752296004460003, + 5.772642408577832, + 5.7927878720062385, + 5.812726422443479, + 5.8324546116558045, + 5.851973815253989, + 5.871310237443233, + 5.890461412740512, + 5.9094405163101085, + 5.928252220023701, + 5.946913007550539, + 5.965411721742322, + 5.983758337450197, + 6.001965802816761, + 6.020048312753478, + 6.03802041000197, + 6.055888244788542, + 6.073642999877825, + 6.091274546279874, + 6.108786416302288, + 6.126179153906693, + 6.143476295749461, + 6.1606729930395625, + 6.1777956845184026, + 6.194824202869887, + 6.211756228225719, + 6.228579099410593, + 6.24530383060172, + 6.261949271223591, + 6.278529259921812, + 6.295057401625629, + 6.3115426076428935, + 6.32796844030063, + 6.344332891049305, + 6.360641720063732, + 6.376900474942685, + 6.393113323498879, + 6.409295778839712, + 6.4254348631469576, + 6.441543344410688, + 6.457632718371999, + 6.4736980963089845, + 6.489736163828759, + 6.505762821318111, + 6.521769594200945, + 6.537766272995924, + 6.553754387109886, + 6.569746659958873, + 6.585732585987243, + 6.601717399774265, + 6.617698895401314, + 6.633687722218323, + 6.649676677348454, + 6.665671992163846, + 6.681663569480333, + 6.697675425810204, + 6.71366830676372, + 6.7296661984481885, + 6.745649533322267, + 6.761628866965974, + 6.777603317004562, + 6.79356074803932, + 6.809497405311357, + 6.825406467987177, + 6.841291753761727, + 6.857153716366222, + 6.87327019834236, + 6.8891196821151475, + 6.9049603772904184, + 6.920784204414174, + 6.936569455836993, + 6.952323270299754, + 6.968020987861997, + 6.983682447775578, + 6.999308352335186, + 7.0149016167057665, + 7.030445014481293, + 7.045922056634009, + 7.061331899512651, + 7.076667186962082, + 7.091928415560223, + 7.107105073641739, + 7.122191636928107, + 7.137194196740436, + 7.152110838752865, + 7.166943385173295, + 7.181677685270958, + 7.19631877989777, + 7.210842883072537, + 7.225236974146121, + 7.239512789851938, + 7.25365043550004, + 7.267651113961876, + 7.281534177949654, + 7.295276352831944, + 7.3088737550353535, + 7.32234093049507, + 7.33565236212063, + 7.348812885407078, + 7.361802997961519, + 7.374635598493401, + 7.387300077882667, + 7.399790922143422, + 7.412112769321462, + 7.424255672171638, + 7.436212438485514, + 7.447961970398144, + 7.459530521986364, + 7.470910970045697, + 7.482104981455491, + 7.493095668388068, + 7.5038703271365765, + 7.514436955074873, + 7.5247923648781425, + 7.534920716223899, + 7.54480018752558, + 7.5544378531688645, + 7.5638380033071115, + 7.572992542910992, + 7.581912707983708, + 7.590592473999202, + 7.59904843743835, + 7.607283056198263, + 7.615281649483524, + 7.623052895942495, + 7.6306135718531305, + 7.637975841975809, + 7.64512727785181, + 7.6520657753129235, + 7.658797684438506, + 7.665333942585685, + 7.671673222935535, + 7.677800135796611, + 7.683728020584755, + 7.689466031240101, + 7.695028101226484, + 7.700396057686372, + 7.705625742089925, + 7.710695804312934, + 7.715598518837528, + 7.720298387728985, + 7.724844475831009, + 7.729223394404715, + 7.733446029931658, + 7.737522022186092, + 7.741455023278387, + 7.745257322079524, + 7.748911936269671, + 7.752431435472415, + 7.755824321998885, + 7.759097237936185, + 7.762270018868647, + 7.765354498790359, + 7.768361486528565, + 7.77127400879402, + 7.7740951691607645, + 7.77681214373135, + 7.779441454156451, + 7.781998862603111, + 7.784487589547273, + 7.786924769589227, + 7.789313292874811, + 7.7916596834993825, + 7.793986491023647, + 7.796280670880405, + 7.798552232882669, + 7.800802349521581, + 7.80304060008198, + 7.80526538162313, + 7.807480727737374, + 7.809690954535394, + 7.811908870593307, + 7.814140058566018, + 7.816402278169571, + 7.81894566134009, + 7.821489297878458, + 7.824051550110368, + 7.826642146904509, + 7.829267275594717, + 7.83193182248565, + 7.83465190761974, + 7.837444060083652, + 7.840298723960646, + 7.843204143918103, + 7.846178622907703, + 7.849214263600073, + 7.85232801546743, + 7.8554921753620786, + 7.858725209977139, + 7.8620392619167525, + 7.865448322648808, + 7.868951681614513, + 7.872541017461527, + 7.876229029456702, + 7.880001088416023, + 7.883864478135862, + 7.8877866147992375, + 7.891769928550966, + 7.895819373760435, + 7.899921682374872, + 7.90409815054551, + 7.908334399972537, + 7.912617147881894, + 7.916940391373447, + 7.921289909107543, + 7.925646392541681, + 7.930009916221271, + 7.934390192212282, + 7.938771629135333, + 7.9431431076060255, + 7.947506738807029, + 7.95187424825926, + 7.956216988159688, + 7.960512475738627, + 7.964759261454546, + 7.968921631059087, + 7.973011616326444, + 7.97703066912135, + 7.980945669190648, + 7.9847233369635155, + 7.9883932405617095, + 7.991931599433519, + 7.995293427830118, + 7.9984589096902035, + 8.001439200655822, + 8.004225703783607, + 8.006777488215373, + 8.009093321589745, + 8.011160124285103, + 8.012956855795672, + 8.014470252992947, + 8.015683943798575, + 8.016587650965736, + 8.017151975775754, + 8.017343408097819, + 8.017120818568046, + 8.016452610581219, + 8.01533752201683, + 8.013744947349055, + 8.011653042590664, + 8.009050507280909, + 8.005904189621424, + 8.00220310918984, + 7.9979076537792615, + 7.9929944904440475, + 7.987425419647527, + 7.981187702526022, + 7.974260134337445, + 7.96662493484892, + 7.9582531280605675, + 7.949099829328734, + 7.93914856023984, + 7.928370608037593, + 7.9167585879390225, + 7.904276987036025, + 7.890905922935797, + 7.876618511858066, + 7.861398680206658, + 7.845237063843355, + 7.828085312837339, + 7.80992897133417, + 7.790775260275799, + 7.770578668978921, + 7.74929724431245, + 7.726919114332139, + 7.703412803266841, + 7.67877329424074, + 7.652960849239776, + 7.625952896618799, + 7.597722083513941, + 7.568256819267248, + 7.5375371388028904, + 7.505576945210936, + 7.472377771870976, + 7.4379098941015425, + 7.402125141198612, + 7.364980158276749, + 7.3264830749392935, + 7.286589346882032, + 7.2453307538895775, + 7.2026702104080496, + 7.15861045363282, + 7.113137902185635, + 7.066241083881112, + 7.0179058691585166, + 6.968119543970922, + 6.916888354767877, + 6.864188494274936, + 6.810012313496776, + 6.754376006558784, + 6.697285417842165, + 6.638705568125014, + 6.578655635528993, + 6.517119604244489, + 6.454079861165431, + 6.389543415388203, + 6.323515661360698, + 6.255976890552834, + 6.186929855548945, + 6.11638272516103, + 6.044315753512999, + 5.970717933643774, + 5.895595789339931, + 5.818955235804846, + 5.740799655256505, + 5.6611355272249675, + 5.5799531980238, + 5.497277315197123, + 5.413127475249691, + 5.32749372784474, + 5.240419232023394, + 5.151884065059343, + 5.061869334108876, + 4.970400196409905, + 4.8774850942554675, + 4.783159072093239, + 4.687421331227439, + 4.590273573138612, + 4.491730238937365, + 4.391840097614658, + 4.290524173035556, + 4.187860715795671, + 4.08386536348168, + 3.9785266080394903, + 3.8719031356732856, + 3.764257417369547, + 3.6553586840150643, + 3.5452299727079195, + 3.4338905951735956, + 3.3213520298561434, + 3.2076468092673975, + 3.092780087644657, + 2.976787355190663, + 2.8596891218806264, + 2.7415159090006185, + 2.622293859974244, + 2.502043312953286, + 2.3808081216080588, + 2.2583468580117554, + 2.1349178211802995, + 2.0105184739940465, + 1.8851986010656123, + 1.7589597181169965, + 1.6318189020501839, + 1.5038067826804307, + 1.3749592740673604, + 1.2452726486252796, + 1.1147827801288486, + 0.9835191836795385, + 0.851484451901432, + 0.7187282474061654, + 0.5852722149348359, + 0.45114421730314547, + 0.3163745380602201, + 0.18095655768443386, + 0.044683360735413125, + -0.09190310120783884, + -0.22906188049069165, + -0.36677057745114183, + -0.5049997768616175, + -0.6437334778430124, + -0.7829372217243478, + -0.9225745572229354, + -1.062641878049421, + -1.2031202161312544, + -1.3439863015060576, + -1.4852120926864831, + -1.62676219275731, + -1.7685957549293683, + -1.9106925540790254, + -2.0530309717194912, + -2.1955830450790152, + -2.338272350192784, + -2.4810392304246944, + -2.6240352078641624, + -2.7672641573242895, + -2.9106311731996266, + -3.0540496959843617, + -3.1974961324939875, + -3.3409747734074395, + -3.4844565087204424, + -3.627887132260626, + -3.771263165523181, + -3.9145770283920696, + -4.057804133783196, + -4.200928081875941, + -4.343920093904507, + -4.486747977656026, + -4.6293842377479235, + -4.771773941884963, + -4.9139233348856175, + -5.055806330561592, + -5.197393588492321, + -5.338669019397588, + -5.479600153402216, + -5.620185064366454, + -5.760409034373612, + -5.900243285631915, + -6.0396569992403935, + -6.1786042541137265, + -6.317036101988431, + -6.454967064384117, + -6.592386989125976, + -6.729262777128624, + -6.865575881492792, + -7.0013270399650205, + -7.136465963056385, + -7.270949914908505, + -7.404801802654549, + -7.537995167539491, + -7.67056250715502, + -7.802428642215054, + -7.933572009582776, + -8.063952620722809, + -8.193563804112497, + -8.32238549972812, + -8.450371501511452, + -8.577510395995226, + -8.70378396810889, + -8.829202281734297, + -8.953719996461896, + -9.077313329399654, + -9.199934192831005, + -9.321578283197411, + -9.442242281681214, + -9.561907651357444, + -9.680564704961885, + -9.798167021184035, + -9.914695138622495, + -10.030092748438715, + -10.14439086931959, + -10.257572792878392, + -10.369634460697103, + -10.480548695435157, + -10.59027456211922, + -10.698781301736144, + -10.806050810073629, + -10.912098630358742, + -11.016899043662406, + -11.120428345014314, + -11.22268706420589, + -11.32367389303214, + -11.42336925924327, + -11.521741619558252, + -11.618760737352908, + -11.714431240880742, + -11.808737878143397, + -11.901690700870418, + -11.993269713200977, + -12.083447290109149, + -12.172205068199744, + -12.259556300809745, + -12.345502230746611, + -12.430003462513447, + -12.513035724972848, + -12.594595009291435, + -12.674684566884999, + -12.75328662580841, + -12.830410461154464, + -12.906031472989167, + -12.980181134650092, + -13.052849337965988, + -13.124020960138093, + -13.193710743388607, + -13.261885507626175, + -13.32853757422625, + -13.393677195485566, + -13.457307466206533, + -13.519406910608826, + -13.580000232660673, + -13.639066337756354, + -13.69660438011913, + -13.75258971290851, + -13.807062645207111, + -13.860005646892109, + -13.911438625126305, + -13.961335108611898, + -14.009687165514556, + -14.056490535261197, + -14.101769456175365, + -14.145515154534312, + -14.187714601550365, + -14.228392200831497, + -14.267548457681805, + -14.305191883618303, + -14.341316206320329, + -14.375951717527332, + -14.40908747606268, + -14.440709741847293, + -14.470855901100844, + -14.499527387853835, + -14.526716984492978, + -14.552450373049577, + -14.576716034478046, + -14.599503061584404, + -14.620827819803303, + -14.640709257476022, + -14.659123985472366, + -14.676086648585184, + -14.691620955370482, + -14.705740943287068, + -14.718434825751139, + -14.729690883817813, + -14.739548357033751, + -14.748007332384319, + -14.755102712038791, + -14.760854736672158, + -14.765227524904557, + -14.7682029831319, + -14.76983644330689, + -14.770120510598055, + -14.769036889524056, + -14.766551727669174, + -14.762768405652906, + -14.7575909679972, + -14.75108920914537, + -14.743263835351158, + -14.734095253536754, + -14.723604679540113, + -14.71183397316494, + -14.698794463221205, + -14.684484798797055, + -14.668907733771661, + -14.652058264642232, + -14.63386857659885, + -14.614388277662151, + -14.593624085068999, + -14.571582389428144, + -14.548292710379645, + -14.523785918961966, + -14.498036883870313, + -14.471064049833881, + -14.442878815617263, + -14.413477742973871, + -14.382867683686609, + -14.351066306937206, + -14.318090221675547, + -14.283947519975488, + -14.248686444581974, + -14.212269831970598, + -14.174708418420916, + -14.136006593141438, + -14.096165803543993, + -14.05517845023314, + -14.013079043206293, + -13.96988060714936, + -13.92558919950542, + -13.88023306676024, + -13.833804051385545, + -13.786313287431817, + -13.73779379406022, + -13.688237182399412, + -13.6376481765672, + -13.586045633864579, + -13.53343233774305, + -13.479857496262373, + -13.42529302030982, + -13.369738775198048, + -13.313223042871016, + -13.255769707916592, + -13.197392819578187, + -13.138120760557523, + -13.077997164890828, + -13.017021527890861, + -12.955184145879876, + -12.892501027586462, + -12.828996669562233, + -12.764668088096837, + -12.69956876900173, + -12.633694842350412, + -12.567085361822219, + -12.499746640058728, + -12.4317107423992, + -12.362988241368278, + -12.293647757220587, + -12.223669970379827, + -12.153052457299669, + -12.08179275453081, + -12.00989693884872, + -11.937421317577265, + -11.864385626322484, + -11.79081870518883, + -11.716710187402064, + -11.642091637660041, + -11.567000413424761, + -11.491448310745909, + -11.415432360484118, + -11.339028613680302, + -11.262232729753002, + -11.185043202719879, + -11.107473595085825, + -11.02956129119303, + -10.951344347387941, + -10.872850104759316, + -10.794061337105187, + -10.714994130006946, + -10.635669719585835, + -10.555940535129263, + -10.476150786812344, + -10.396198871178377, + -10.315920467710146, + -10.235478230111436, + -10.154895154027216, + -10.074144331147288, + -9.993285609243099, + -9.912343359539243, + -9.83126822091991, + -9.750125125140581, + -9.668967659247958, + -9.587729655437435, + -9.50649558213232, + -9.425274232105572, + -9.344051261553723, + -9.262905766170604, + -9.182098581636133, + -9.101368505953456, + -9.020742455503232, + -8.940241540557974, + -8.859771096009556, + -8.779550457335745, + -8.69947418238704, + -8.619586313168803, + -8.54007673011968, + -8.460771686137377, + -8.381690644371616, + -8.302836942507604, + -8.224226340725789, + -8.145610871628719, + -8.06725989330123, + -7.989197770430397, + -7.91145700384905, + -7.834031234838814, + -7.7569243849009775, + -7.680090939246186, + -7.603598742339076, + -7.527419033829214, + -7.451536214714232, + -7.37598034084465, + -7.300750881098, + -7.225883722344384, + -7.151405514227389, + -7.077273717977611, + -7.0034903022206665, + -6.930016785879897, + -6.8568801236093, + -6.784101908797891, + -6.711673610933565, + -6.639580903833017, + -6.567809285672282, + -6.496390182076957, + -6.4253030974016605, + -6.354539764685335, + -6.284116799036192, + -6.214022708280884, + -6.1442439542338585, + -6.074792427286082, + -6.005676574916138, + -5.936917134803857, + -5.8684823666701496, + -5.800396795545974, + -5.732657963986187, + -5.665283858587622, + -5.5982928015955755, + -5.531504640593467, + -5.464885570592741, + -5.398547252790418, + -5.332505918255953, + -5.266765896808763, + -5.201279077373612, + -5.136067519191621, + -5.071134184415638, + -5.0064684769695615, + -4.942022832096064, + -4.877807708507546, + -4.813841560300703, + -4.750110509234772, + -4.6865788406983855, + -4.623268674374663, + -4.560172417234116, + -4.497256038401692, + -4.434516945017596, + -4.37198307669784, + -4.309614345054462, + -4.24737831194036, + -4.185275111509692, + -4.123308703172444, + -4.061498271955803, + -3.9998452826090807, + -3.938364597979837, + -3.8770715760291106, + -3.8158869625139653, + -3.75482814939038, + -3.6939017461809245, + -3.633104494175824, + -3.572422544627929, + -3.5118686331271602, + -3.4514417291896793, + -3.391105175637061, + -3.33085662763808, + -3.2706644535590366, + -3.210564472705694, + -3.1505255393658134, + -3.090595089361373, + -3.030784776034543, + -2.9710677858952232, + -2.9114488675939567, + -2.8519115236690658, + -2.7924682498015514, + -2.7330945412353937, + -2.6737927827993246, + -2.6145903132655226, + -2.555479605324331, + -2.4964781440068666, + -2.4375885570113676, + -2.3788410795812363, + -2.3202457448821443, + -2.2617815677787503, + -2.203457662702898, + -2.145299333500131, + -2.0873197702736963, + -2.0294919082964276, + -1.9717805938876154, + -1.9142245066933397, + -1.8568136742137167, + -1.7996380741122202, + -1.7426846481161986, + -1.685928632387176, + -1.629378900531563, + -1.5730413166475197, + -1.5169323041228147, + -1.46105355709859, + -1.4054193209330466, + -1.3500540530762928, + -1.2949755958261102, + -1.24018716942905, + -1.185698063928995, + -1.131506633962779, + -1.0776488646316222, + -1.0241454299134904, + -0.9710433891809478, + -0.9183473328835738, + -0.8660639766846874, + -0.8142059251043499, + -0.7627949209397533, + -0.7118126670731417, + -0.6612717594267892, + -0.6111533672085381, + -0.5614897627249151, + -0.5123384363305004, + -0.4636641104533883, + -0.41549168031275574, + -0.3678385863455178, + -0.320725900639073, + -0.2742040001262591, + -0.22829380639239094, + -0.1829868441374778, + -0.1382696376442718, + -0.09414900627380351, + -0.050622094526013406, + -0.007751381000567825, + 0.03445988682637324, + 0.07599122349029575, + 0.11682186102432546, + 0.15697528867170618, + 0.19644563118237013, + 0.2351999556961859, + 0.27320424076254746, + 0.31045757286785935, + 0.34698822891148584, + 0.3827600147130701, + 0.4177730485207958, + 0.4520142849167694, + 0.48550430472887474, + 0.5182445005583665, + 0.5502377472605922, + 0.5814743648784777, + 0.6119285859263011, + 0.6415655799336655, + 0.670417256254467, + 0.6984588188693044, + 0.7257010866834444, + 0.7521590474701147, + 0.7778389865224531, + 0.8027533965107088, + 0.8268768749466062, + 0.8502128346679605, + 0.8727334265035829, + 0.8944655897662903, + 0.9154222825588736, + 0.9356278987012869, + 0.9550638855212066, + 0.9737301639886065, + 0.9916720050658316, + 1.008889965651921, + 1.0253839694226334, + 1.041179550556289, + 1.0562518726346566, + 1.0706324417351967, + 1.084330746540763, + 1.0973625099638076, + 1.1097217690284014, + 1.1213870039737506, + 1.1324252633117666, + 1.1427401265360402, + 1.152425155391735, + 1.1614885204217442, + 1.1699127577661153, + 1.1777316650004805, + 1.1849582222994965, + 1.1916108000606678, + 1.1977126483395568, + 1.2032768985790132, + 1.208301878661445, + 1.212734554984694, + 1.21664243700911, + 1.2200363267244088, + 1.2229342319324372, + 1.2253529958844038, + 1.2272907479654895, + 1.2287507356757676, + 1.229740045324712, + 1.2302892986588305, + 1.2303856813048624, + 1.2300675174519462, + 1.2293726760972996, + 1.228279358242792, + 1.226785820951462, + 1.2249398529305005, + 1.222758473758922, + 1.2202368961687151, + 1.2173716250827238, + 1.2141736050707, + 1.2106288530440175, + 1.206794168504215, + 1.202675686050385, + 1.1982649439997863, + 1.1935637263524406, + 1.1885704607636307, + 1.183315912626421, + 1.1777842791228315, + 1.171987508247327, + 1.1659523074536935, + 1.159659449123942, + 1.1531345540700704, + 1.1464149987774563, + 1.1394644340117335, + 1.1322636539580975, + 1.1248612182238924, + 1.1172594138617544, + 1.109436637138753, + 1.101375709286006, + 1.093109108282352, + 1.0846401637478502, + 1.0759656075562258, + 1.0670843721705747, + 1.0580174790809895, + 1.0487324633768313, + 1.0392259502935204, + 1.0295178166433816, + 1.0196072827971738, + 1.0094875527245062, + 0.999169455280077, + 0.9886479311855743, + 0.9779767069765279, + 0.9671028689360028, + 0.9560018201387699, + 0.9446607300011074, + 0.933079234429786, + 0.9215312795991704, + 0.9097974115686389, + 0.8978644630148587, + 0.8857290906542019, + 0.8734238605470503, + 0.8609503753644789, + 0.848277859424817, + 0.8354109482954186, + 0.8224068177077557, + 0.8092112246738852, + 0.7957937752514894, + 0.7821735889293437, + 0.7683382509540877, + 0.7543227280843334, + 0.7401402479320014, + 0.7257431542167705, + 0.7111395217518783, + 0.6963147428391832, + 0.6811107107135195, + 0.6658901601055254, + 0.6504851046120992, + 0.6347440514060079, + 0.6188388929833426, + 0.602755954322288, + 0.5864772340222943, + 0.5700423890427571, + 0.5534426437782782, + 0.536623897553727, + 0.5196381257979388, + 0.5024968013523514, + 0.4852114233724514, + 0.4678040586345329, + 0.4502725089179105, + 0.4326091363543707, + 0.41484551860338303, + 0.3969936199319619, + 0.37905974130203735, + 0.36106010329302674, + 0.3429903372757961, + 0.3247586324494529, + 0.30657856680305784, + 0.28832420527900027, + 0.27002742547965664, + 0.2518764113645222, + 0.23367151290862598, + 0.21545730361342752, + 0.197230891641051, + 0.17899128596483305, + 0.16073975342216773, + 0.14249911292062034, + 0.1243043826797452, + 0.10615858098888342, + 0.08809363612952126, + 0.07010736625323855, + 0.05213028980236434, + 0.03424466211425781, + 0.016467579506869612, + -0.0012078422143222411, + -0.01875121442663108, + -0.03614146583500677, + -0.053362299047956085, + -0.07040329914476207, + -0.08730844602068899, + -0.10403718570288145, + -0.120607912155271, + -0.1369929071464835 + ], + "l0": 20825.28328342407, + "b0": 0.0, + "sigma0": [ + 9.684516563073734 + ], + "last_observatory": "BOU", + "last_channel": "U", + "last_delta": 60.0, + "next_starttime": "2018-10-24T00:00:00.000000Z" +} \ No newline at end of file diff --git a/test/Controller_test.py b/test/Controller_test.py index 4a722adaa..35ba8e60b 100644 --- a/test/Controller_test.py +++ b/test/Controller_test.py @@ -56,7 +56,7 @@ def test_controller_update_sqdist(): "--input", "iaga2002", "--input-url", - "file://etc/controller/{obs}{date:%Y%m%d}_XYZF_{t}{i}.{i}", + "file://etc/controller/{obs}{date:%Y%m%d}_XYWF_{t}{i}.{i}", "--observatory", "BOU", "--algorithm", @@ -72,30 +72,30 @@ def test_controller_update_sqdist(): "--inchannels", "X", "Y", - "Z", + "W", "F", "--interval", "minute", "--rename-output-channel", - "H_Dist", - "MDT", + "U_Dist", + "UDT", "--rename-output-channel", - "H_SQ", - "MSQ", + "U_SQ", + "USQ", "--rename-output-channel", - "H_SV", - "MSV", + "U_SV", + "USV", "--rename-output-channel", - "H_Sigma", - "MSS", + "U_Sigma", + "USS", "--outchannels", - "MDT", - "MSQ", - "MSV", - "MSS", + "UDT", + "USQ", + "USV", + "USS", "--sqdist-mag", "--sqdist-statefile", - tmp_dir + "/sqdistBOU_h_state.json", + tmp_dir + "/sqdistBOU_u_state.json", "--type", "variation", "--output", @@ -113,18 +113,18 @@ def test_controller_update_sqdist(): urlTemplate=("file://" + tmp_dir + "/{obs}{date:%Y%m%d}_DQVS_{t}{i}.{i}"), urlInterval=86400, observatory="BOU", - channels=["MDT", "MSQ", "MSV", "MSS"], + channels=["UDT", "USQ", "USV", "USS"], ) expected_factory = IAGA2002Factory( urlTemplate="url template, individual tests change the template below", urlInterval=86400, observatory="BOU", - channels=["MDT", "MSQ", "MSV", "MSS"], + channels=["UDT", "USQ", "USV", "USS"], ) # setup test data # copy SqDistAlgorithm statefile and empty DQVS output file to tmp folder - copy("etc/controller/sqdistBOU_h_state.json", tmp_dir) + copy("etc/controller/sqdistBOU_u_state.json", tmp_dir) copy( "etc/controller/bou20181024_DQVS_test0_vmin.min", tmp_dir + "/bou20181024_DQVS_vmin.min", diff --git a/test/StreamConverter_test.py b/test/StreamConverter_test.py index 0c8b4207a..102255576 100644 --- a/test/StreamConverter_test.py +++ b/test/StreamConverter_test.py @@ -26,19 +26,19 @@ STARTTIME = obspy.core.UTCDateTime("2014-11-01") def test_get_geo_from_mag(): """StreamConverter_test.test_get_geo_from_mag() - The magnetic north stream containing the traces ''h'', ''d'', ''z'', and + The magnetic north stream containing the traces ''u'', ''d'', ''w'', and ''f'' converts to the geographics stream containing the traces ''x'', - ''y'', ''z'' and ''f'' + ''y'', ''w'' and ''f'' """ mag = obspy.core.Stream() # Call get_geo_from_magusing a decbas of 15 degrees, and streams with - # H = [1, 1], and D = [15 degrees, 30 degrees], expect streams of + # U = [1, 1], and D = [15 degrees, 30 degrees], expect streams of # X = [cos(15), cos(30)] and Y = [sin(15), sin(30)] # stats.DECBAS = 15 * D2I - mag += __create_trace("H", [1, 1]) + mag += __create_trace("U", [1, 1]) mag += __create_trace("D", [15 * D2R, 30 * D2R]) - mag += __create_trace("Z", [1, 1]) + mag += __create_trace("W", [1, 1]) mag += __create_trace("F", [1, 1]) geo = StreamConverter.get_geo_from_mag(mag) X = geo.select(channel="X")[0].data @@ -63,16 +63,16 @@ def test_get_geo_from_obs(): """StreamConverter_test.test_get_geo_from_obs() The observatory stream containing the observatory traces - ''h'', ''d'' or ''e'', ''z'', and ''f'' converts to the geographic - stream containing the traces ''x'', ''y'', ''z'', and ''f'' + ''u'', ''d'' or ''v'', ''w'', and ''f'' converts to the geographic + stream containing the traces ''x'', ''y'', ''w'', and ''f'' """ obs = obspy.core.Stream() - # 1) Call get_geo_from_obs using equal h, e streams with a decbas of 0 + # 1) Call get_geo_from_obs using equal u, v streams with a decbas of 0 # the geographic stream values X, Y will be the same. - obs += __create_trace("H", [1]) - obs += __create_trace("E", [1]) - obs += __create_trace("Z", [1]) + obs += __create_trace("U", [1]) + obs += __create_trace("V", [1]) + obs += __create_trace("W", [1]) obs += __create_trace("F", [1]) geo = StreamConverter.get_geo_from_obs(obs) X = geo.select(channel="X")[0].data @@ -81,13 +81,13 @@ def test_get_geo_from_obs(): assert_almost_equal(Y[0], 1, 9, "Expect Y to almost equal 1", True) # 2) Call get_geo_from_obs using a decbas of 15 degrees, and streams - # with H = [cos(15), cos(30)], and E = [sin(15), sin(30)]. + # with U = [cos(15), cos(30)], and V = [sin(15), sin(30)]. # Expect streams of X = [cos(30), cos(45)] and Y = sin(30), sin(45) obs = obspy.core.Stream() DECBAS = 15 * D2I - obs += __create_trace("H", [cos(15 * D2R), cos(30 * D2R)], DECBAS) - obs += __create_trace("E", [sin(15 * D2R), sin(30 * D2R)], DECBAS) - obs += __create_trace("Z", [1, 1], DECBAS) + obs += __create_trace("U", [cos(15 * D2R), cos(30 * D2R)], DECBAS) + obs += __create_trace("V", [sin(15 * D2R), sin(30 * D2R)], DECBAS) + obs += __create_trace("W", [1, 1], DECBAS) obs += __create_trace("F", [1, 1], DECBAS) geo = StreamConverter.get_geo_from_obs(obs) X = geo.select(channel="X")[0].data @@ -111,24 +111,24 @@ def test_get_geo_from_obs(): def test_get_mag_from_geo(): """StreamConverter_test.test_get_mag_from_geo() - The geographic stream containing the traces ''x'', ''y'', ''z'', and + The geographic stream containing the traces ''x'', ''y'', ''w'', and ''f'' converts to the magnetic stream containing the traces - ''h'', ''d'', ''z'' and ''f''. + ''u'', ''d'', ''w'' and ''f''. """ geo = obspy.core.Stream() # Call get_mag_from_geo using a decbas of 15, a X stream of # [cos(15), cos(30)], and a Y stream of [sin(15), sin(30)]. - # Expect a H stream of [1,1] and a D strem of [15 degrees, 30 degrees] + # Expect a U stream of [1,1] and a D strem of [15 degrees, 30 degrees] DECBAS = 15 * D2I geo += __create_trace("X", [cos(15 * D2R), cos(30 * D2R)], DECBAS) geo += __create_trace("Y", [sin(15 * D2R), sin(30 * D2R)], DECBAS) geo += __create_trace("Z", [1, 1], DECBAS) geo += __create_trace("F", [1, 1], DECBAS) mag = StreamConverter.get_mag_from_geo(geo) - H = mag.select(channel="H")[0].data + U = mag.select(channel="U")[0].data D = mag.select(channel="D")[0].data - assert_almost_equal(H, [1, 1], 9, "Expect H to equal [1,1]", True) + assert_almost_equal(U, [1, 1], 9, "Expect U to equal [1,1]", True) assert_almost_equal( D, [15 * D2R, 30 * D2R], 9, "Expect D to equal [15 degrees, 30 degrees]", True ) @@ -137,23 +137,23 @@ def test_get_mag_from_geo(): def test_get_mag_from_obs(): """StreamConverter_test.test_get_mag_from_obs() - The observatory stream containing the traces ''h'', ''e'' or ''d'', - ''z'' and ''f'' + The observatory stream containing the traces ''u'', ''v'' or ''d'', + ''w'' and ''f'' """ obs = obspy.core.Stream() - # Call get_mag_from_obs using a DECBAS of 15 degrees, a H stream of - # [cos(15), cos(30)] and a E stream of [sin(15), sin(30)]. - # Expect a H stream of [1, 1] and a D stream of [30 degrees, 45 degrees] + # Call get_mag_from_obs using a DECBAS of 15 degrees, a U stream of + # [cos(15), cos(30)] and a V stream of [sin(15), sin(30)]. + # Expect a U stream of [1, 1] and a D stream of [30 degrees, 45 degrees] DECBAS = 15 * D2I - obs += __create_trace("H", [cos(15 * D2R), cos(30 * D2R)], DECBAS) - obs += __create_trace("E", [sin(15 * D2R), sin(30 * D2R)], DECBAS) - obs += __create_trace("Z", [1, 1], DECBAS) + obs += __create_trace("U", [cos(15 * D2R), cos(30 * D2R)], DECBAS) + obs += __create_trace("V", [sin(15 * D2R), sin(30 * D2R)], DECBAS) + obs += __create_trace("W", [1, 1], DECBAS) obs += __create_trace("F", [1, 1], DECBAS) mag = StreamConverter.get_mag_from_obs(obs) - H = mag.select(channel="H")[0].data + U = mag.select(channel="U")[0].data D = mag.select(channel="D")[0].data - assert_almost_equal(H, [1, 1], 9, "Expect H to equal [1,1]", True) + assert_almost_equal(U, [1, 1], 9, "Expect U to equal [1,1]", True) assert_almost_equal( D, [30 * D2R, 45 * D2R], 9, "Expect D to equal [30 degrees, 45 degrees]", True ) @@ -162,37 +162,37 @@ def test_get_mag_from_obs(): def test_get_obs_from_geo(): """StreamConverter_test.test_get_obs_from_geo() - The geographic stream containing the traces ''x'', ''y'', ''z'', and + The geographic stream containing the traces ''x'', ''y'', ''w'', and ''f'' converts to the observatory stream containing the traces - ''h'', ''d'' or ''e'', ''z'', and ''f''. + ''u'', ''d'' or ''v'', ''w'', and ''f''. """ geo = obspy.core.Stream() # Call get_geo_from_obs using a decbas of 15, a X stream of # [cos(30), cos(45)], and a Y stream of [sin(30), sin(45)]. - # Expect a H stream of [cos(15), cos(30)] and a - # E stream of [sin(15), sin(30)] + # Expect a U stream of [cos(15), cos(30)] and a + # V stream of [sin(15), sin(30)] DECBAS = 15 * D2I geo += __create_trace("X", [cos(30 * D2R), cos(45 * D2R)], DECBAS) geo += __create_trace("Y", [sin(30 * D2R), sin(45 * D2R)], DECBAS) - geo += __create_trace("Z", [1, 1], DECBAS) + geo += __create_trace("W", [1, 1], DECBAS) geo += __create_trace("F", [1, 1], DECBAS) obs = StreamConverter.get_obs_from_geo(geo, True) - H = obs.select(channel="H")[0].data - E = obs.select(channel="E")[0].data + U = obs.select(channel="U")[0].data + V = obs.select(channel="V")[0].data D = obs.select(channel="D")[0].data assert_almost_equal( - H, + U, [cos(15 * D2R), cos(30 * D2R)], 9, - "Expect H to equal [cos(15), cos(30)]", + "Expect U to equal [cos(15), cos(30)]", True, ) assert_almost_equal( - E, + V, [sin(15 * D2R), sin(30 * D2R)], 9, - "Expect E to equal [sin(15), sin(30)", + "Expect V to equal [sin(15), sin(30)", True, ) assert_almost_equal( @@ -203,40 +203,40 @@ def test_get_obs_from_geo(): def test_get_obs_from_mag(): """StreamConverter_test.test_get_obs_from_mag() - The magnetic stream containing the traces ''h'', ''d'', ''z'', and ''f'' + The magnetic stream containing the traces ''u'', ''d'', ''w'', and ''f'' converts to the observatory stream containing the traces - ''h'', ''e'' and/or ''d'', ''z'', and ''f'' + ''u'', ''v'' and/or ''d'', ''w'', and ''f'' """ mag = obspy.core.Stream() - # Call get_obs_from_mag using a decbas of 15, a H stream of [1,1], - # and a D stream of [30 degrees, 45 degrees]. Expect a H stream + # Call get_obs_from_mag using a decbas of 15, a U stream of [1,1], + # and a D stream of [30 degrees, 45 degrees]. Expect a U stream # of [cos(15), cos(30)], a D stream of [30 degrees, 45 degrees], - # and a E stream of [sin(15), sin(30)] + # and a V stream of [sin(15), sin(30)] DECBAS = 15 * D2I - mag += __create_trace("H", [1, 1], DECBAS) + mag += __create_trace("U", [1, 1], DECBAS) mag += __create_trace("D", [30 * D2R, 45 * D2R], DECBAS) - mag += __create_trace("Z", [1, 1], DECBAS) + mag += __create_trace("W", [1, 1], DECBAS) mag += __create_trace("F", [1, 1], DECBAS) obs = StreamConverter.get_obs_from_mag(mag, True) - H = obs.select(channel="H")[0].data + U = obs.select(channel="U")[0].data D = obs.select(channel="D")[0].data - E = obs.select(channel="E")[0].data + V = obs.select(channel="V")[0].data assert_almost_equal( - H, + U, [cos(15 * D2R), cos(30 * D2R)], 9, - "Expect H to equal [cos(15), cos(30)", + "Expect U to equal [cos(15), cos(30)", True, ) assert_almost_equal( D, [15 * D2R, 30 * D2R], 9, "Expect D to equal [15 degrees, 30 degrees", True ) assert_almost_equal( - E, + V, [sin(15 * D2R), sin(30 * D2R)], 9, - "Expect E to equal [sin(15), sin(30)", + "Expect V to equal [sin(15), sin(30)", True, ) @@ -244,19 +244,19 @@ def test_get_obs_from_mag(): def test_get_obs_from_obs(): """StreamConverter_test.test_get_obs_from_obs() - The observatory stream can contain either ''d'' or ''e'' depending + The observatory stream can contain either ''d'' or ''v'' depending on it's source. get_obs_from_obs will return either or both as part of the obs Stream. """ - # 1) Call get_obs_from_obs using a decbas of 15, a H stream of - # [cos(15), cos(30)], and a E stream of [sin(15), sin(30)]. + # 1) Call get_obs_from_obs using a decbas of 15, a U stream of + # [cos(15), cos(30)], and a V stream of [sin(15), sin(30)]. # Expect a D stream of [15 degrees, 30 degrees] obs_e = obspy.core.Stream() DECBAS = 15 * D2I - obs_e += __create_trace("H", [cos(15 * D2R), cos(30 * D2R)], DECBAS) - obs_e += __create_trace("E", [sin(15 * D2R), sin(30 * D2R)], DECBAS) - obs_e += __create_trace("Z", [1, 1], DECBAS) + obs_e += __create_trace("U", [cos(15 * D2R), cos(30 * D2R)], DECBAS) + obs_e += __create_trace("V", [sin(15 * D2R), sin(30 * D2R)], DECBAS) + obs_e += __create_trace("W", [1, 1], DECBAS) obs_e += __create_trace("F", [1, 1], DECBAS) obs_D = StreamConverter.get_obs_from_obs(obs_e, False, True) d = obs_D.select(channel="D")[0].data @@ -264,21 +264,21 @@ def test_get_obs_from_obs(): d, [15 * D2R, 30 * D2R], 9, "Expect D to equal [15 degrees, 30 degrees]", True ) - # 2) Call get_obs_from_obs using a decbase of 15 degrees, a H stream of + # 2) Call get_obs_from_obs using a decbase of 15 degrees, a U stream of # [cos(15), cos(30)], and a D stream of [15, 30]. # Expect a D stream of [sin(15), sin(30)] - obs_d = obspy.core.Stream() - obs_d += __create_trace("H", [cos(15 * D2R), cos(30 * D2R)], DECBAS) - obs_d += __create_trace("D", [15 * D2R, 30 * D2R], DECBAS) - obs_d += __create_trace("Z", [1, 1], DECBAS) - obs_d += __create_trace("F", [1, 1], DECBAS) - obs_E = StreamConverter.get_obs_from_obs(obs_d, True, False) - e = obs_E.select(channel="E")[0].data + obs_u = obspy.core.Stream() + obs_u += __create_trace("U", [cos(15 * D2R), cos(30 * D2R)], DECBAS) + obs_u += __create_trace("D", [15 * D2R, 30 * D2R], DECBAS) + obs_u += __create_trace("W", [1, 1], DECBAS) + obs_u += __create_trace("F", [1, 1], DECBAS) + obs_V = StreamConverter.get_obs_from_obs(obs_u, True, False) + v = obs_V.select(channel="V")[0].data assert_almost_equal( - e, + v, [sin(15 * D2R), sin(30 * D2R)], 9, - "Expect E to equal [sin(15), sin(30)", + "Expect V to equal [sin(15), sin(30)", True, ) @@ -296,21 +296,21 @@ def test_verification_data(): expectations. """ DECBAS = 552.7 - obs_v = obspy.core.Stream() - obs_v += __create_trace( - "H", [20889.55, 20889.57, 20889.74, 20889.86, 20889.91, 20889.81], DECBAS + obs_ver = obspy.core.Stream() + obs_ver += __create_trace( + "U", [20889.55, 20889.57, 20889.74, 20889.86, 20889.91, 20889.81], DECBAS ) - obs_v += __create_trace( - "E", [-21.10, -20.89, -20.72, -20.57, -20.39, -20.12], DECBAS + obs_ver += __create_trace( + "V", [-21.10, -20.89, -20.72, -20.57, -20.39, -20.12], DECBAS ) - obs_v += __create_trace( - "Z", [47565.29, 47565.34, 47565.39, 47565.45, 47565.51, 47565.54], DECBAS + obs_ver += __create_trace( + "W", [47565.29, 47565.34, 47565.39, 47565.45, 47565.51, 47565.54], DECBAS ) - obs_v += __create_trace( + obs_ver += __create_trace( "F", [52485.77, 52485.84, 52485.94, 52486.06, 52486.11, 52486.10], DECBAS ) - obs_V = StreamConverter.get_obs_from_obs(obs_v, True, True) - d = obs_V.select(channel="D")[0].data + obs_VER = StreamConverter.get_obs_from_obs(obs_ver, True, True) + d = obs_VER.select(channel="D")[0].data d = ChannelConverter.get_minutes_from_radians(d) # Using d values calculated using small angle approximation. assert_almost_equal( @@ -324,14 +324,14 @@ def test_verification_data(): mag = obspy.core.Stream() DECBAS = 552.7 mag += __create_trace( - "H", [20884.04, 20883.45, 20883.38, 20883.43, 20883.07, 20882.76], DECBAS + "U", [20884.04, 20883.45, 20883.38, 20883.43, 20883.07, 20882.76], DECBAS ) d = ChannelConverter.get_radians_from_minutes( [556.51, 556.52, 556.56, 556.61, 556.65, 556.64] ) mag += __create_trace("D", d, DECBAS) mag += __create_trace( - "Z", [48546.90, 48546.80, 48546.80, 48546.70, 48546.80, 48546.90], DECBAS + "W", [48546.90, 48546.80, 48546.80, 48546.70, 48546.80, 48546.90], DECBAS ) mag += __create_trace("F", [0.10, 0.00, 0.10, 0.00, 0.00, 0.00, 0.00], DECBAS) geo = StreamConverter.get_geo_from_mag(mag) diff --git a/test/algorithm_test/AdjustedAlgorithm_test.py b/test/algorithm_test/AdjustedAlgorithm_test.py index 220d498c6..cbfa2ab1e 100644 --- a/test/algorithm_test/AdjustedAlgorithm_test.py +++ b/test/algorithm_test/AdjustedAlgorithm_test.py @@ -23,7 +23,7 @@ def assert_streams_almost_equal(adjusted, expected, channels): ) -def test_process_XYZF_AdjustedMatrix(): +def test_process_XYWF_AdjustedMatrix(): """algorithm_test.AdjustedAlgorithm_test.test_process_XYZF_AdjustedMatrix() Check adjusted data processing versus files generated from @@ -67,7 +67,7 @@ def test_process_XYZF_AdjustedMatrix(): adjusted = a.process(raw) assert_streams_almost_equal( - adjusted=adjusted, expected=expected, channels=["X", "Y", "Z", "F"] + adjusted=adjusted, expected=expected, channels=["X", "Y", "W", "F"] ) @@ -87,8 +87,8 @@ def test_process_reverse_polarity_AdjustedMatrix(): ], pier_correction=-22, ), - inchannels=["H", "E"], - outchannels=["H", "E"], + inchannels=["U", "V"], + outchannels=["U", "V"], ) # load boulder May 20 files from /etc/ directory @@ -101,11 +101,11 @@ def test_process_reverse_polarity_AdjustedMatrix(): adjusted = a.process(raw) assert_streams_almost_equal( - adjusted=adjusted, expected=expected, channels=["H", "E"] + adjusted=adjusted, expected=expected, channels=["U", "V"] ) -def test_process_XYZF_statefile(): +def test_process_XYWF_statefile(): """algorithm_test.AdjustedAlgorithm_test.test_process_XYZF_statefile() Check adjusted data processing versus files generated from @@ -126,7 +126,7 @@ def test_process_XYZF_statefile(): adjusted = a.process(raw) assert_streams_almost_equal( - adjusted=adjusted, expected=expected, channels=["X", "Y", "Z", "F"] + adjusted=adjusted, expected=expected, channels=["X", "Y", "W", "F"] ) @@ -141,8 +141,8 @@ def test_process_reverse_polarity_statefile(): # load adjusted data transform matrix and pier correction a = AdjustedAlgorithm( statefile="etc/adjusted/adjbou_state_HE_.json", - inchannels=["H", "E"], - outchannels=["H", "E"], + inchannels=["U", "V"], + outchannels=["U", "V"], ) # load boulder May 20 files from /etc/ directory @@ -151,11 +151,11 @@ def test_process_reverse_polarity_statefile(): with open("etc/adjusted/BOU202005adj.min") as f: expected = i2.IAGA2002Factory().parse_string(f.read()) - # process he(raw) channels with loaded transform + # process uv(raw) channels with loaded transform adjusted = a.process(raw) assert_streams_almost_equal( - adjusted=adjusted, expected=expected, channels=["H", "E"] + adjusted=adjusted, expected=expected, channels=["U", "V"] ) @@ -171,7 +171,7 @@ def test_process_no_statefile(): # load boulder Jan 16 files from /etc/ directory with open("etc/adjusted/BOU201601vmin.min") as f: raw = i2.IAGA2002Factory().parse_string(f.read()) - # process hezf (raw) channels with identity transform + # process uvwf (raw) channels with identity transform adjusted = a.process(raw) for i in range(len(adjusted)): assert_array_equal(adjusted[i].data, raw[i].data) diff --git a/test/algorithm_test/XYZAlgorithm_test.py b/test/algorithm_test/XYZAlgorithm_test.py index 67be143a8..254b10471 100644 --- a/test/algorithm_test/XYZAlgorithm_test.py +++ b/test/algorithm_test/XYZAlgorithm_test.py @@ -13,9 +13,9 @@ def test_xyzalgorithm_process(): """ algorithm = XYZAlgorithm("obs", "geo") timeseries = Stream() - timeseries += __create_trace("H", [1, 1]) - timeseries += __create_trace("E", [1, 1]) - timeseries += __create_trace("Z", [1, 1]) + timeseries += __create_trace("U", [1, 1]) + timeseries += __create_trace("V", [1, 1]) + timeseries += __create_trace("W", [1, 1]) timeseries += __create_trace("F", [1, 1]) outputstream = algorithm.process(timeseries) assert_equal(outputstream[0].stats.channel, "X") @@ -28,8 +28,8 @@ def test_xyzalgorithm_channels(): informat/outformat during instantiation. """ algorithm = XYZAlgorithm("obs", "geo") - inchannels = ["H", "E", "Z", "F"] - outchannels = ["X", "Y", "Z", "F"] + inchannels = ["U", "V", "W", "F"] + outchannels = ["X", "Y", "W", "F"] assert_equal(algorithm.get_input_channels(), inchannels) assert_equal(algorithm.get_output_channels(), outchannels) @@ -38,13 +38,13 @@ def test_xyzalgorithm_limited_channels(): """XYZAlgorithm_test.test_xyzalgorithm_limited_channels() confirms that only the required channels are necessary for processing - ie. 'H' and 'E' are only needed to get 'X' and 'Y' without 'Z' or 'F' + ie. 'U' and 'V' are only needed to get 'X' and 'Y' without 'Z' or 'F' """ algorithm = XYZAlgorithm("obs", "mag") count = 5 timeseries = Stream() - timeseries += __create_trace("H", [2] * count) - timeseries += __create_trace("E", [3] * count) + timeseries += __create_trace("U", [2] * count) + timeseries += __create_trace("V", [3] * count) outstream = algorithm.process(timeseries) ds = outstream.select(channel="D") # there is 1 trace @@ -66,14 +66,14 @@ def test_xyzalgorithm_uneccesary_channel_empty(): """ algorithm = XYZAlgorithm("obs", "mag") timeseries = Stream() - timeseries += __create_trace("H", [1, 1]) - timeseries += __create_trace("E", [1, 1]) - timeseries += __create_trace("Z", [1, np.NaN]) + timeseries += __create_trace("U", [1, 1]) + timeseries += __create_trace("V", [1, 1]) + timeseries += __create_trace("W", [1, np.NaN]) timeseries += __create_trace("F", [np.NaN, np.NaN]) outstream = algorithm.process(timeseries) assert_equal( - outstream.select(channel="Z")[0].data.all(), - timeseries.select(channel="Z")[0].data.all(), + outstream.select(channel="W")[0].data.all(), + timeseries.select(channel="W")[0].data.all(), ) assert_equal( outstream.select(channel="F")[0].data.all(), -- GitLab From c2a49ae2a94ee65f9cfce4a30a02424abd6a7a68 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Wed, 12 May 2021 14:22:54 -0600 Subject: [PATCH 5/7] Support miniseed channels for algorithms --- geomagio/StreamConverter.py | 144 ++++++++++++------------ geomagio/algorithm/AdjustedAlgorithm.py | 4 +- geomagio/algorithm/DeltaFAlgorithm.py | 6 +- geomagio/algorithm/SqDistAlgorithm.py | 10 +- geomagio/algorithm/XYZAlgorithm.py | 10 +- 5 files changed, 87 insertions(+), 87 deletions(-) diff --git a/geomagio/StreamConverter.py b/geomagio/StreamConverter.py index 4ef3232c5..5c1eb0822 100644 --- a/geomagio/StreamConverter.py +++ b/geomagio/StreamConverter.py @@ -1,10 +1,10 @@ """Convert streams from one coordinate system to another. We use three coordinate systems. -Geo: Based on Geographic North. X, Y, Z, F - X is north, Y is east, Z is down -Obs: Based on the observatories orientaion. H, E, Z, F, d0 -Mag: Based on Magnetic North. H, D, Z, F +Geo: Based on Geographic North. X, Y, W, F + X is north, Y is east, W is down +Obs: Based on the observatories orientaion. U, V, W, F, d0 +Mag: Based on Magnetic North. U, D, W, F """ from __future__ import absolute_import @@ -19,25 +19,25 @@ def get_geo_from_mag(mag): Parameters ---------- stream : obspy.core.Stream - stream containing observatory components H, D, Z, and F. + stream containing observatory components U, D, W, and F. Returns ------- obspy.core.Stream - new stream object containing geographic components X, Y, Z, and F. + new stream object containing geographic components X, Y, W, and F. """ - h = mag.select(channel="H")[0] + u = mag.select(channel="U")[0] d = mag.select(channel="D")[0] - z = mag.select(channel="Z") + w = mag.select(channel="W") f = mag.select(channel="F") - mag_h = h.data + mag_u = u.data mag_d = d.data - (geo_x, geo_y) = ChannelConverter.get_geo_from_mag(mag_h, mag_d) + (geo_x, geo_y) = ChannelConverter.get_geo_from_mag(mag_u, mag_d) return ( obspy.core.Stream( - (__get_trace("X", h.stats, geo_x), __get_trace("Y", d.stats, geo_y)) + (__get_trace("X", u.stats, geo_x), __get_trace("Y", d.stats, geo_y)) ) - + z + + u + f ) @@ -48,12 +48,12 @@ def get_geo_from_obs(obs): Parameters ---------- stream : obspy.core.Stream - stream containing observatory components H, D or E, Z, and F. + stream containing observatory components U, D or V, W, and F. Returns ------- obspy.core.Stream - new stream object containing geographic components X, Y, Z, and F. + new stream object containing geographic components X, Y, W, and F. """ return get_geo_from_mag(get_mag_from_obs(obs)) @@ -64,7 +64,7 @@ def get_deltaf_from_geo(geo): Parameters ---------- obs: obspy.core.Stream - stream containing the observatory components H, D or E, Z, and F. + stream containing the observatory components U, D or V, W, and F. Returns ------- @@ -73,9 +73,9 @@ def get_deltaf_from_geo(geo): """ x = geo.select(channel="X")[0] y = geo.select(channel="Y")[0] - z = geo.select(channel="Z")[0] + w = geo.select(channel="W")[0] fs = geo.select(channel="F")[0] - fv = ChannelConverter.get_computed_f_using_squares(x, y, z) + fv = ChannelConverter.get_computed_f_using_squares(x, y, w) G = ChannelConverter.get_deltaf(fv, fs) return obspy.core.Stream((__get_trace("G", x.stats, G),)) @@ -86,20 +86,20 @@ def get_deltaf_from_obs(obs): Parameters ---------- obs: obspy.core.Stream - stream containing the observatory components H, D or E, Z, and F. + stream containing the observatory components U, D or V, W, and F. Returns ------- obspy.core.Stream stream object containing delta f values """ - h = obs.select(channel="H")[0] - z = obs.select(channel="Z")[0] + u = obs.select(channel="U")[0] + w = obs.select(channel="W")[0] fs = obs.select(channel="F")[0] - e = __get_obs_e_from_obs(obs) - fv = ChannelConverter.get_computed_f_using_squares(h, e, z) + v = __get_obs_e_from_obs(obs) + fv = ChannelConverter.get_computed_f_using_squares(u, v, w) G = ChannelConverter.get_deltaf(fv, fs) - return obspy.core.Stream((__get_trace("G", h.stats, G),)) + return obspy.core.Stream((__get_trace("G", u.stats, G),)) def get_mag_from_geo(geo): @@ -108,25 +108,25 @@ def get_mag_from_geo(geo): Parameters ---------- geo: obspy.core.Stream - stream containing observatory components X, Y, Z, and F. + stream containing observatory components X, Y, W, and F. Returns ------- obspy.core.Stream - new stream object containing magnetic components H, D, Z, and F. + new stream object containing magnetic components U, D, W, and F. """ x = geo.select(channel="X")[0] y = geo.select(channel="Y")[0] - z = geo.select(channel="Z") + w = geo.select(channel="W") f = geo.select(channel="F") geo_x = x.data geo_y = y.data - (mag_h, mag_d) = ChannelConverter.get_mag_from_geo(geo_x, geo_y) + (mag_u, mag_d) = ChannelConverter.get_mag_from_geo(geo_x, geo_y) return ( obspy.core.Stream( - (__get_trace("H", x.stats, mag_h), __get_trace("D", y.stats, mag_d)) + (__get_trace("U", x.stats, mag_u), __get_trace("D", y.stats, mag_d)) ) - + z + + w + f ) @@ -137,28 +137,28 @@ def get_mag_from_obs(obs): Parameters ---------- obs : obspy.core.Stream - stream containing observatory components H, D or E, Z, and F. + stream containing observatory components U, D or V, W, and F. Returns ------- obspy.core.Stream - new stream object containing magnetic components H, D, Z, and F. + new stream object containing magnetic components U, D, W, and F. """ - h = obs.select(channel="H")[0] - e = __get_obs_e_from_obs(obs) - z = obs.select(channel="Z") + u = obs.select(channel="U")[0] + v = __get_obs_e_from_obs(obs) + w = obs.select(channel="W") f = obs.select(channel="F") - obs_h = h.data - obs_e = e.data + obs_u = u.data + obs_v = v.data d0 = ChannelConverter.get_radians_from_minutes( - numpy.float64(e.stats.declination_base) / 10 + numpy.float64(v.stats.declination_base) / 10 ) - (mag_h, mag_d) = ChannelConverter.get_mag_from_obs(obs_h, obs_e, d0) + (mag_u, mag_d) = ChannelConverter.get_mag_from_obs(obs_u, obs_v, d0) return ( obspy.core.Stream( - (__get_trace("H", h.stats, mag_h), __get_trace("D", e.stats, mag_d)) + (__get_trace("U", u.stats, mag_u), __get_trace("D", v.stats, mag_d)) ) - + z + + w + f ) @@ -169,14 +169,14 @@ def get_obs_from_geo(geo, include_d=False): Parameters ---------- stream : obspy.core.Stream - stream containing geographic components X, Y, Z, and F. + stream containing geographic components X, Y, W, and F. include_d : boolean whether to also include the observatory D component. Returns ------- obspy.core.Stream - new stream object containing observatory components H, D, E, Z, and F. + new stream object containing observatory components U, D, V, W, and F. """ return get_obs_from_mag(get_mag_from_geo(geo), include_d) @@ -187,31 +187,31 @@ def get_obs_from_mag(mag, include_d=False): Parameters ---------- stream: obspy.core.Stream - stream containing magnetic components H, D, Z, and F. + stream containing magnetic components U, D, W, and F. include_d: boolean whether to also include the observatory D component Returns ------- obspy.core.Stream - new stream object containing observatory components H, D, E, Z, and F + new stream object containing observatory components U, D, V, W, and F """ - h = mag.select(channel="H")[0] + u = mag.select(channel="U")[0] d = mag.select(channel="D")[0] - z = mag.select(channel="Z") + w = mag.select(channel="W") f = mag.select(channel="F") - mag_h = h.data + mag_u = u.data mag_d = d.data d0 = ChannelConverter.get_radians_from_minutes( numpy.float64(d.stats.declination_base) / 10 ) - (obs_h, obs_e) = ChannelConverter.get_obs_from_mag(mag_h, mag_d, d0) + (obs_u, obs_v) = ChannelConverter.get_obs_from_mag(mag_u, mag_d, d0) - traces = (__get_trace("H", h.stats, obs_h), __get_trace("E", d.stats, obs_e)) + traces = (__get_trace("U", u.stats, obs_u), __get_trace("V", d.stats, obs_v)) if include_d: - obs_d = ChannelConverter.get_obs_d_from_obs(obs_h, obs_e) + obs_d = ChannelConverter.get_obs_d_from_obs(obs_u, obs_v) traces = traces + (__get_trace("D", d.stats, obs_d),) - return obspy.core.Stream(traces) + z + f + return obspy.core.Stream(traces) + w + f def get_obs_from_obs(obs, include_e=False, include_d=False): @@ -220,7 +220,7 @@ def get_obs_from_obs(obs, include_e=False, include_d=False): Parameters ---------- stream: obspy.core.Stream - stream containing the observatory components H, D or E, Z, and F. + stream containing the observatory components U, D or V, W, and F. include_e: boolean whether to include the e component include_d: boolean @@ -229,19 +229,19 @@ def get_obs_from_obs(obs, include_e=False, include_d=False): Returns ------- obspy.core.Stream - new stream object containing observatory components H, D, E, Z, and F + new stream object containing observatory components U, D, V, W, and F """ - h = obs.select(channel="H")[0] - z = obs.select(channel="Z") + u = obs.select(channel="U")[0] + w = obs.select(channel="W") f = obs.select(channel="F") - traces = (h,) + traces = (u,) if include_d: d = __get_obs_d_from_obs(obs) traces = traces + (d,) if include_e: - e = __get_obs_e_from_obs(obs) - traces = traces + (e,) - return obspy.core.Stream(traces) + z + f + v = __get_obs_e_from_obs(obs) + traces = traces + (v,) + return obspy.core.Stream(traces) + w + f def __get_trace(channel, stats, data): @@ -269,12 +269,12 @@ def __get_trace(channel, stats, data): def __get_obs_d_from_obs(obs): """Get trace containing observatory D component. - Returns D if found, otherwise computes D from H, E, D0. + Returns D if found, otherwise computes D from U, V, D0. Parameters ---------- obs : obspy.core.Stream - observatory components (D) or (H, E). + observatory components (D) or (U, V). Returns ------- @@ -284,10 +284,10 @@ def __get_obs_d_from_obs(obs): try: d = obs.select(channel="D")[0] except IndexError: - h = obs.select(channel="H")[0] - e = obs.select(channel="E")[0] + u = obs.select(channel="U")[0] + v = obs.select(channel="V")[0] d = __get_trace( - "D", e.stats, ChannelConverter.get_obs_d_from_obs(h.data, e.data) + "D", v.stats, ChannelConverter.get_obs_d_from_obs(u.data, v.data) ) return d @@ -295,24 +295,24 @@ def __get_obs_d_from_obs(obs): def __get_obs_e_from_obs(obs): """Get trace containing observatory E component. - Returns E if found, otherwise computes E from H,D. + Returns V if found, otherwise computes V from U,D. Parameters ---------- obs : obspy.core.Stream - observatory components (E) or (H, D). + observatory components (V) or (U, D). Returns ------- obspy.core.Trace - observatory component E. + observatory component V. """ try: - e = obs.select(channel="E")[0] + v = obs.select(channel="V")[0] except IndexError: - h = obs.select(channel="H")[0] + u = obs.select(channel="U")[0] d = obs.select(channel="D")[0] - e = __get_trace( - "E", d.stats, ChannelConverter.get_obs_e_from_obs(h.data, d.data) + v = __get_trace( + "V", d.stats, ChannelConverter.get_obs_e_from_obs(u.data, d.data) ) - return e + return v diff --git a/geomagio/algorithm/AdjustedAlgorithm.py b/geomagio/algorithm/AdjustedAlgorithm.py index fcbe2dceb..30bfb7cfd 100644 --- a/geomagio/algorithm/AdjustedAlgorithm.py +++ b/geomagio/algorithm/AdjustedAlgorithm.py @@ -23,8 +23,8 @@ class AdjustedAlgorithm(Algorithm): inchannels=None, outchannels=None, ): - inchannels = inchannels or ["H", "E", "Z", "F"] - outchannels = outchannels or ["X", "Y", "Z", "F"] + inchannels = inchannels or ["U", "V", "W", "F"] + outchannels = outchannels or ["X", "Y", "W", "F"] Algorithm.__init__( self, inchannels=inchannels, diff --git a/geomagio/algorithm/DeltaFAlgorithm.py b/geomagio/algorithm/DeltaFAlgorithm.py index 22ebab009..1e0d5a7d5 100644 --- a/geomagio/algorithm/DeltaFAlgorithm.py +++ b/geomagio/algorithm/DeltaFAlgorithm.py @@ -12,9 +12,9 @@ from .. import StreamConverter # obs represents the sensor orientation aligned close to the mag orientation # obsd is the same as obs, but with D(declination) instead of E (e/w vector) CHANNELS = { - "geo": ["X", "Y", "Z", "F"], - "obs": ["H", "E", "Z", "F"], - "obsd": ["H", "D", "Z", "F"], + "geo": ["X", "Y", "W", "F"], + "obs": ["U", "V", "W", "F"], + "obsd": ["U", "D", "W", "F"], } diff --git a/geomagio/algorithm/SqDistAlgorithm.py b/geomagio/algorithm/SqDistAlgorithm.py index 4dc5087a2..8e9cc2abc 100644 --- a/geomagio/algorithm/SqDistAlgorithm.py +++ b/geomagio/algorithm/SqDistAlgorithm.py @@ -88,7 +88,7 @@ class SqDistAlgorithm(Algorithm): end of input required to generate requested output. """ if self.mag: - channels = "H" + channels = "U" if ( observatory == self.last_observatory and len(channels) == 1 @@ -186,8 +186,8 @@ class SqDistAlgorithm(Algorithm): if self.mag: # convert stream to mag if ( - stream.select(channel="H").count() > 0 - and stream.select(channel="E").count() > 0 + stream.select(channel="U").count() > 0 + and stream.select(channel="V").count() > 0 ): stream = StreamConverter.get_mag_from_obs(stream) elif ( @@ -196,8 +196,8 @@ class SqDistAlgorithm(Algorithm): ): stream = StreamConverter.get_mag_from_geo(stream) else: - raise AlgorithmException("Unable to convert to magnetic H") - stream = stream.select(channel="H") + raise AlgorithmException("Unable to convert to magnetic U") + stream = stream.select(channel="U") for trace in stream.traces: out += self.process_one(trace) diff --git a/geomagio/algorithm/XYZAlgorithm.py b/geomagio/algorithm/XYZAlgorithm.py index 1f43c8785..ae37518c5 100644 --- a/geomagio/algorithm/XYZAlgorithm.py +++ b/geomagio/algorithm/XYZAlgorithm.py @@ -12,12 +12,12 @@ from .. import StreamConverter # geo represents a geographic north/south orientation # mag represents the (calculated)instantaneous mangnetic north orientation # obs represents the sensor orientation aligned close to the mag orientation -# obsd is the same as obs, but with D(declination) instead of E (e/w vector) +# obsd is the same as obs, but with D(declination) instead of V (east/west vector) CHANNELS = { - "geo": ["X", "Y", "Z", "F"], - "mag": ["H", "D", "Z", "F"], - "obs": ["H", "E", "Z", "F"], - "obsd": ["H", "D", "Z", "F"], + "geo": ["X", "Y", "W", "F"], + "mag": ["U", "D", "W", "F"], + "obs": ["U", "V", "W", "F"], + "obsd": ["U", "D", "W", "F"], } -- GitLab From c73489464527b3716d2661eedb8aedcc0bff28c7 Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Wed, 12 May 2021 14:29:06 -0600 Subject: [PATCH 6/7] Filter/derive variation channels in one call. Separate adjusted processes --- geomagio/Controller.py | 2 +- geomagio/processing/DataFormat.py | 6 + geomagio/processing/__init__.py | 4 +- geomagio/processing/derived.py | 388 ++++++++++++++++++ geomagio/processing/observatory.py | 279 +++---------- .../{realtime_filter.py => obsrio.py} | 287 ++++--------- geomagio/processing/pcdcp.py | 219 ++++++++++ setup.py | 3 +- 8 files changed, 747 insertions(+), 441 deletions(-) create mode 100644 geomagio/processing/DataFormat.py create mode 100644 geomagio/processing/derived.py rename geomagio/processing/{realtime_filter.py => obsrio.py} (50%) create mode 100644 geomagio/processing/pcdcp.py diff --git a/geomagio/Controller.py b/geomagio/Controller.py index 4342bd856..e88003187 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -101,7 +101,7 @@ class Controller(object): input_start, input_end = algorithm.get_input_interval( start=starttime, end=endtime, observatory=obs, channels=channels ) - if input_start is None or input_end is None: + if input_start is None or input_end is None or input_start > input_end: continue timeseries += self._inputFactory.get_timeseries( observatory=obs, diff --git a/geomagio/processing/DataFormat.py b/geomagio/processing/DataFormat.py new file mode 100644 index 000000000..06bd44ef6 --- /dev/null +++ b/geomagio/processing/DataFormat.py @@ -0,0 +1,6 @@ +from enum import Enum + + +class DataFormat(str, Enum): + OBSRIO = "obsrio" + PCDCP = "pcdcp" diff --git a/geomagio/processing/__init__.py b/geomagio/processing/__init__.py index 14dc324f1..c71e5ceaf 100644 --- a/geomagio/processing/__init__.py +++ b/geomagio/processing/__init__.py @@ -4,12 +4,14 @@ Note that these implementations are subject to change, and should be considered less stable than other packages in the library. """ from .factory import get_edge_factory, get_miniseed_factory -from .observatory import adjusted, average, deltaf, rotate, sqdist_minute +from .derived import adjusted, deltaf, rotate, sqdist_minute +from .DataFormat import DataFormat __all__ = [ "adjusted", "average", + "DataFormat", "deltaf", "get_edge_factory", "get_miniseed_factory", diff --git a/geomagio/processing/derived.py b/geomagio/processing/derived.py new file mode 100644 index 000000000..97c1f8980 --- /dev/null +++ b/geomagio/processing/derived.py @@ -0,0 +1,388 @@ +from typing import Optional + +from obspy import UTCDateTime + +from ..adjusted import AdjustedMatrix +from ..algorithm import ( + AdjustedAlgorithm, + DeltaFAlgorithm, + SqDistAlgorithm, + XYZAlgorithm, +) +from ..Controller import Controller, get_realtime_interval +from ..edge import MiniSeedFactory +from ..metadata import MetadataCategory, MetadataFactory, MetadataQuery +from .factory import get_miniseed_factory + + +def process_adjusted( + observatory: str, + sqdist_statefile: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: str = 2061, + output_port: str = 7905, + output_read_port: str = 2061, + realtime_interval: int = 600, + update_limit: int = 7, +): + """Computes derived adjusted channels + U, D, X, Y, W, G (1Hz) + U, D, X, Y, W, G, USQ, USV, UDT (1 min) + """ + input_factory = get_miniseed_factory( + host=input_host, + port=input_port, + ) + output_factory = get_miniseed_factory( + host=output_host, + port=output_read_port, + write_port=output_port, + locationCode="A0", + ) + adjusted( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + adjusted( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + input_factory.type = "adjusted" + input_factory.locationCode = "A0" + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + output_channels=("U", "D"), + xyz_from="geo", + xyz_to="mag", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + output_channels=("U", "D"), + xyz_from="geo", + xyz_to="mag", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + deltaf( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + deltaf_from="geo", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + deltaf( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + deltaf_from="geo", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + sqdist_minute( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + statefile=sqdist_statefile, + realtime_interval=realtime_interval, + ) + + +def process_variation( + observatory: str, + sqdist_statefile: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: str = 2061, + output_port: str = 7905, + output_read_port: str = 2061, + realtime_interval: int = 600, + update_limit: int = 7, +): + """Computes derived adjusted channels + D, X, Y, W, G (1Hz) + D, X, Y, W, G, USQ, USV, UDT (1 min) + """ + input_factory = get_miniseed_factory(host=input_host, port=input_port) + output_factory = get_miniseed_factory( + host=output_host, port=output_read_port, write_port=output_port + ) + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + output_channels=("X", "Y"), + xyz_from="obs", + xyz_to="geo", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + output_channels=("X", "Y"), + xyz_from="obs", + xyz_to="geo", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + output_channels=("D"), + xyz_from="obs", + xyz_to="obsd", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + rotate( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + output_channels=("D"), + xyz_from="obs", + xyz_to="obsd", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + deltaf( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="second", + deltaf_from="obs", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + deltaf( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + interval="minute", + deltaf_from="obs", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + sqdist_minute( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + statefile=sqdist_statefile, + realtime_interval=realtime_interval, + ) + + +def adjusted( + observatory: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + interval: str = "second", + realtime_interval: int = 60, + update_limit: int = 10, +): + """Run Adjusted algorithm. + + Parameters + ---------- + observatory: observatory to calculate + input_factory: where to read, should be configured with data_type + interval: data interval + output_factory: where to write, should be configured with data_type + statefile: adjusted statefile + realtime_interval: window in seconds + Uses update_limit=10. + """ + starttime, endtime = get_realtime_interval(realtime_interval) + adjusted_matrix = get_adjusted_matrix(observatory=observatory, time=endtime) + controller = Controller( + algorithm=AdjustedAlgorithm( + matrix=adjusted_matrix, + data_type="adjusted", + location="A0", + ), + inputFactory=input_factory or get_miniseed_factory(), + inputInterval=interval, + outputFactory=output_factory or get_miniseed_factory(), + outputInterval=interval, + ) + controller.run_as_update( + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=("U", "V", "W", "F"), + output_channels=("X", "Y", "W", "F"), + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def deltaf( + observatory: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + interval: str = "second", + deltaf_from="obs", + realtime_interval: int = 60, + update_limit: int = 10, +): + """Run Delta-F algorithm. + + Parameters + ---------- + observatory: observatory to calculate + input_factory: where to read, should be configured with data_type and interval + output_factory: where to write, should be configured with data_type and interval + deltaf_from: one of {"obs", "mag", "geo"} + realtime_interval: window in seconds + Uses update_limit=10. + """ + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + algorithm=DeltaFAlgorithm(informat=deltaf_from), + inputFactory=input_factory or get_miniseed_factory(interval=interval), + inputInterval=interval, + outputFactory=output_factory or get_miniseed_factory(interval=interval), + outputInterval=interval, + ) + controller.run_as_update( + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + output_channels=("G",), + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def rotate( + observatory: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + interval: str = "second", + output_channels=("X", "Y"), + xyz_from="obs", + xyz_to="geo", + realtime_interval: int = 60, + update_limit: int = 10, +): + """Run XYZ rotation algorithm. + + Parameters + ---------- + observatory: observatory to calculate + input_factory: where to read, should be configured with data_type and interval + output_channels: which channels to write + output_factory: where to write, should be configured with data_type and interval + realtime_interval: window in seconds + xyz_from: one of {"obs", "mag", "geo"} + xyz_to: one of {"obs", "obsd", "mag", "geo"} + Uses update_limit=10. + """ + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + algorithm=XYZAlgorithm(informat=xyz_from, outformat=xyz_to), + inputFactory=input_factory or get_miniseed_factory(interval=interval), + inputInterval=interval, + outputFactory=output_factory or get_miniseed_factory(interval=interval), + outputInterval=interval, + ) + controller.run_as_update( + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + output_channels=output_channels, + realtime=realtime_interval, + update_limit=update_limit, + ) + + +def sqdist_minute( + observatory: str, + statefile: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 1800, +): + """Run SqDist algorithm. + + Only supports "minute" interval. + + Parameters + ---------- + observatory: observatory to calculate + statefile: sqdist statefile must already exist + input_factory: where to read, should be configured with data_type and interval + output_factory: where to write, should be configured with data_type and interval + realtime_interval: window in seconds + """ + if not statefile: + raise ValueError("Statefile is required.") + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + algorithm=SqDistAlgorithm( + alpha=2.3148e-5, + beta=0, + gamma=3.3333e-2, + m=1440, + mag=True, + smooth=180, + statefile=statefile, + ), + inputFactory=input_factory or get_miniseed_factory(), + inputInterval="minute", + outputFactory=output_factory or get_miniseed_factory(), + outputInterval="minute", + ) + # sqdist is stateful, use run + controller.run( + observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=("X", "Y", "W", "F"), + output_channels=("UDT", "USQ", "USV"), + realtime=realtime_interval, + rename_output_channel=(("U_Dist", "UDT"), ("U_SQ", "USQ"), ("U_SV", "USV")), + ) + + +def get_adjusted_matrix(observatory: str, time: UTCDateTime) -> AdjustedMatrix: + """Searches one month for an observatory's most recent adjusted matrix""" + metas = MetadataFactory().get_metadata( + MetadataQuery( + category=MetadataCategory.ADJUSTED_MATRIX, + station=observatory, + starttime=time - (86400 * 31), + endtime=time, + ) + ) + metadata = metas[-1] + return AdjustedMatrix(**metadata.metadata) diff --git a/geomagio/processing/observatory.py b/geomagio/processing/observatory.py index 85a9cfd7f..d24185674 100644 --- a/geomagio/processing/observatory.py +++ b/geomagio/processing/observatory.py @@ -1,243 +1,70 @@ -from typing import List, Optional +import typer -import numpy +from . import obsrio, pcdcp, derived, DataFormat -from ..algorithm import ( - AdjustedAlgorithm, - AverageAlgorithm, - DeltaFAlgorithm, - SqDistAlgorithm, - XYZAlgorithm, -) -from ..Controller import Controller, get_realtime_interval -from ..TimeseriesFactory import TimeseriesFactory -from .factory import get_edge_factory +app = typer.Typer() -def adjusted( - observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - interval: str = "second", - output_factory: Optional[TimeseriesFactory] = None, - matrix: Optional[numpy.ndarray] = None, - pier_correction: Optional[float] = None, - statefile: Optional[str] = None, - realtime_interval: int = 600, -): - """Run Adjusted algorithm. - - Parameters - ---------- - observatory: observatory to calculate - input_factory: where to read, should be configured with data_type - interval: data interval - output_factory: where to write, should be configured with data_type - matrix: adjusted matrix - pier_correction: adjusted pier correction - statefile: adjusted statefile - realtime_interval: window in seconds - - Uses update_limit=10. - """ - if not statefile and (not matrix or not pier_correction): - raise ValueError("Either statefile or matrix and pier_correction are required.") - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=AdjustedAlgorithm( - matrix=matrix, - pier_correction=pier_correction, - statefile=statefile, - data_type="adjusted", - location="A0", - ), - inputFactory=input_factory or get_edge_factory(data_type="variation"), - inputInterval=interval, - outputFactory=output_factory or get_edge_factory(data_type="adjusted"), - outputInterval=interval, - ) - controller.run_as_update( - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=("H", "E", "Z", "F"), - output_channels=("X", "Y", "Z", "F"), - realtime=realtime_interval, - update_limit=10, - ) - - -def average( - observatories: List[str], - input_channel: str, - input_factory: Optional[TimeseriesFactory] = None, - interval: str = "second", - output_channel: str = None, - output_factory: Optional[TimeseriesFactory] = None, - output_observatory: str = "USGS", - realtime_interval: int = 600, -): - """Run Average algorithm. - - Parameters - ---------- - observatories: input observatories to calculate - input_channel: channel from multiple observatories to average - input_factory: where to read, should be configured with data_type and interval - interval: data interval - output_channel: channel to write (defaults to input_channel). - output_factory: where to write, should be configured with data_type and interval - output_observatory: observatory where output is written - realtime_interval: window in seconds - - Uses update_limit=10. - """ - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=AverageAlgorithm(observatories=observatories, channel=output_channel), - inputFactory=input_factory or get_edge_factory(), - inputInterval=interval, - outputFactory=output_factory or get_edge_factory(), - outputInterval=interval, - ) - controller.run_as_update( - observatory=observatories, - output_observatory=(output_observatory,), - starttime=starttime, - endtime=endtime, - output_channels=(output_channel or input_channel,), - realtime=realtime_interval, - update_limit=10, - ) +def main(): + app() -def deltaf( +@app.command() +def adjusted( observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - interval: str = "second", - output_factory: Optional[TimeseriesFactory] = None, - deltaf_from="obs", - realtime_interval: int = 600, + sqdist_statefile: str, + realtime_interval: int = 60, + update_limit: int = 10, ): - """Run Delta-F algorithm. - - Parameters - ---------- - observatory: observatory to calculate - input_factory: where to read, should be configured with data_type and interval - output_factory: where to write, should be configured with data_type and interval - deltaf_from: one of {"obs", "mag", "geo"} - realtime_interval: window in seconds - - Uses update_limit=10. - """ - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=DeltaFAlgorithm(informat=deltaf_from), - inputFactory=input_factory or get_edge_factory(), - inputInterval=interval, - outputFactory=output_factory or get_edge_factory(), - outputInterval=interval, + """Compute derived adjusted channels""" + derived.process_adjusted( + observatory=observatory, + sqdist_statefile=sqdist_statefile, + realtime_interval=realtime_interval, + update_limit=update_limit, ) - controller.run_as_update( - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - output_channels=("G",), - realtime=realtime_interval, - update_limit=10, + pcdcp.copy_adjusted( + observatory=observatory, + realtime_interval=realtime_interval, + update_limit=update_limit, ) -def rotate( +@app.command(name="variation") +def process_variation( observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - interval: str = "second", - output_channels=("X", "Y"), - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, - xyz_from="obs", - xyz_to="geo", + sqdist_statefile: str, + data_format: DataFormat = DataFormat.OBSRIO, + realtime_interval: int = 60, + update_limit: int = 10, ): - """Run XYZ rotation algorithm. - - Parameters - ---------- - observatory: observatory to calculate - input_factory: where to read, should be configured with data_type and interval - output_channels: which channels to write - output_factory: where to write, should be configured with data_type and interval - realtime_interval: window in seconds - xyz_from: one of {"obs", "mag", "geo"} - xyz_to: one of {"obs", "obsd", "mag", "geo"} - - Uses update_limit=10. - """ - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=XYZAlgorithm(informat=xyz_from, outformat=xyz_to), - inputFactory=input_factory or get_edge_factory(), - inputInterval=interval, - outputFactory=output_factory or get_edge_factory(), - outputInterval=interval, - ) - controller.run_as_update( - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - output_channels=output_channels, - realtime=realtime_interval, - update_limit=10, + """Filter raw data and compute derived variaiton channels""" + if data_format == DataFormat.OBSRIO: + obsrio.prepare( + observatory=observatory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + elif data_format == DataFormat.PCDCP: + pcdcp.prepare( + observatory=observatory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + obsrio.filter_minute( + observatory=observatory, + realtime_interval=realtime_interval, + update_limit=update_limit, ) - - -def sqdist_minute( - observatory: str, - statefile: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 1800, -): - """Run SqDist algorithm. - - Only supports "minute" interval. - - Parameters - ---------- - observatory: observatory to calculate - statefile: sqdist statefile must already exist - input_factory: where to read, should be configured with data_type and interval - output_factory: where to write, should be configured with data_type and interval - realtime_interval: window in seconds - """ - if not statefile: - raise ValueError("Statefile is required.") - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - algorithm=SqDistAlgorithm( - alpha=2.3148e-5, - gamma=3.3333e-2, - m=1440, - mag=True, - smooth=180, - statefile=statefile, - ), - inputFactory=input_factory or get_edge_factory(interval="minute"), - inputInterval="minute", - outputFactory=output_factory or get_edge_factory(interval="minute"), - outputInterval="minute", + derived.process_variation( + observatory=observatory, + sqdist_statefile=sqdist_statefile, + realtime_interval=realtime_interval, + update_limit=update_limit, ) - # sqdist is stateful, use run - controller.run( - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=("X", "Y", "Z", "F"), - output_channels=("MDT", "MSQ", "MSV"), - realtime=realtime_interval, - rename_output_channel=(("H_Dist", "MDT"), ("H_SQ", "MSQ"), ("H_SV", "MSV")), - update_limit=10, + pcdcp.copy_variation( + observatory=observatory, + realtime_interval=realtime_interval, + update_limit=update_limit, + data_format=data_format, ) diff --git a/geomagio/processing/realtime_filter.py b/geomagio/processing/obsrio.py similarity index 50% rename from geomagio/processing/realtime_filter.py rename to geomagio/processing/obsrio.py index 5eff95402..0f9bf164d 100644 --- a/geomagio/processing/realtime_filter.py +++ b/geomagio/processing/obsrio.py @@ -1,176 +1,50 @@ -from typing import List, Optional +from enum import Enum +from typing import Optional import typer -from ..algorithm import Algorithm, FilterAlgorithm +from ..algorithm import FilterAlgorithm from ..Controller import Controller, get_realtime_interval -from .. import TimeseriesFactory -from .factory import get_edge_factory, get_miniseed_factory +from ..edge import MiniSeedFactory +from .factory import get_miniseed_factory -app = typer.Typer() - -def main(): - app() - - -@app.command(name="legacy") -def copy_to_legacy( - observatory: str, - input_host: str = "127.0.0.1", - output_host: str = "127.0.0.1", - input_port: int = 2061, - output_port: int = 7981, - output_read_port: int = 2060, - realtime_interval: int = 3600, - update_limit: int = 7, -): - """Copies miniseed 1Hz, minutes, and temperatures(UK1-4) to edge""" - input_factory = get_miniseed_factory(host=input_host, port=input_port) - output_factory = get_edge_factory( - host=output_host, port=output_read_port, write_port=output_port - ) - input_channels = ("U", "V", "W", "F") - output_channels = ("H", "E", "Z", "F") - copy_channels( - observatory=observatory, - interval="second", - input_channels=input_channels, - output_channels=output_channels, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - copy_channels( - observatory=observatory, - interval="minute", - input_channels=input_channels, - output_channels=output_channels, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - copy_channels( - observatory=observatory, - interval="minute", - input_channels=( - "UK1", - "UK2", - "UK3", - "UK4", - ), - output_channels=( - "UK1", - "UK2", - "UK3", - "UK4", - ), - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) +class DataInterval(str, Enum): + HOUR = "hour" + DAY = "day" -@app.command() -def obsrio( - observatory: str, - input_host: str = "127.0.0.1", - output_host: str = "127.0.0.1", - input_port: int = 2061, - output_port: int = 7905, - output_read_port: int = 2061, - realtime_interval: int = 3600, - update_limit: int = 7, -): - """Filters 10Hz miniseed U,V,W and 1Hz miniseed temperatures(LK1-4)""" - output_factory = get_miniseed_factory( - host=output_host, port=output_read_port, write_port=output_port - ) - obsrio_tenhertz( - observatory=observatory, - input_factory=get_miniseed_factory( - host=input_host, port=input_port, convert_channels=("U", "V", "W") - ), - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - obsrio_temperatures( - observatory=observatory, - input_factory=get_miniseed_factory(host=input_host, port=input_port), - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - - -@app.command() -def pcdcp( - observatory: str, - input_host: str = "127.0.0.1", - output_host: str = "127.0.0.1", - input_port: int = 2060, - output_port: int = 7905, - output_read_port: int = 2061, - realtime_interval: int = 3600, - update_limit: int = 7, -): - """Copies 1Hz edge H,E,Z,F to 1Hz miniseed U,V,W,F""" - input_factory = get_edge_factory(host=input_host, port=input_port) - output_factory = get_miniseed_factory( - host=output_host, port=output_read_port, write_port=output_port - ) - copy_channels( - observatory=observatory, - interval="second", - input_channels=["H", "E", "Z", "F"], - output_channels=["U", "V", "W", "F"], - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) +def main(): + typer.run(obsrio_filter) -@app.command(name="miniseed") -def filter_miniseed( +def obsrio_filter( observatory: str, - interval: str = "realtime", + interval: DataInterval = DataInterval.HOUR, input_host: str = "127.0.0.1", output_host: str = "127.0.0.1", - input_port: int = 2061, - output_port: int = 7905, - output_read_port: int = 2061, - realtime_interval: int = 3600, + input_port: str = 2061, + output_port: str = 7905, + output_read_port: str = 2061, + realtime_interval: int = 86400, update_limit: int = 7, ): - """Produces 1 minute, 1 hour, or 1 day miniseed U,V,W,F""" + """Filters 1 min miniseed U,V,W,F to + 1 hour or 1 day miniseed U,V,W,F""" input_factory = get_miniseed_factory(host=input_host, port=input_port) output_factory = get_miniseed_factory( host=output_host, port=output_read_port, write_port=output_port ) - if interval == "realtime": - obsrio_minute( + if interval == DataInterval.HOUR: + filter_hour( observatory=observatory, input_factory=input_factory, output_factory=output_factory, realtime_interval=realtime_interval, update_limit=update_limit, ) - - elif interval == "hour": - obsrio_hour( - observatory=observatory, - input_factory=input_factory, - output_factory=output_factory, - realtime_interval=realtime_interval, - update_limit=update_limit, - ) - elif interval == "day": - obsrio_day( + if interval == DataInterval.DAY: + filter_day( observatory=observatory, input_factory=input_factory, output_factory=output_factory, @@ -179,56 +53,19 @@ def filter_miniseed( ) -def copy_channels( +def filter_day( observatory: str, - interval: str, - input_channels: List[str], - output_channels: List[str], - input_factory: TimeseriesFactory, - output_factory: TimeseriesFactory, - realtime_interval: int = 600, - update_limit: int = 10, -): - """Copy data between edge and miniseed formats""" - starttime, endtime = get_realtime_interval(realtime_interval) - controller = Controller( - inputFactory=input_factory, - inputInterval=interval, - outputFactory=output_factory, - outputInterval=interval, - ) - for i in range(len(input_channels)): - input_channel = input_channels[i] - output_channel = output_channels[i] - controller.run_as_update( - algorithm=Algorithm( - inchannels=(input_channel,), outchannels=(output_channel) - ), - observatory=(observatory,), - output_observatory=(observatory,), - starttime=starttime, - endtime=endtime, - input_channels=(input_channel,), - output_channels=(output_channel,), - realtime=realtime_interval, - rename_output_channel=((input_channel, output_channel),), - update_limit=update_limit, - ) - - -def obsrio_day( - observatory: str, - input_factory: TimeseriesFactory, - output_factory: TimeseriesFactory, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, realtime_interval: int = 86400, update_limit: int = 7, ): """Filter 1 minute miniseed U,V,W,F to 1 day miniseed U,V,W,F.""" starttime, endtime = get_realtime_interval(realtime_interval) controller = Controller( - inputFactory=input_factory, + inputFactory=input_factory or get_miniseed_factory(), inputInterval="minute", - outputFactory=output_factory, + outputFactory=output_factory or get_miniseed_factory(), outputInterval="day", ) for channel in ["U", "V", "W", "F"]: @@ -250,19 +87,19 @@ def obsrio_day( ) -def obsrio_hour( +def filter_hour( observatory: str, - input_factory: TimeseriesFactory, - output_factory: TimeseriesFactory, - realtime_interval: int = 86400, - update_limit: int = 7, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 3600, + update_limit: int = 24, ): """Filter 1 minute miniseed U,V,W,F to 1 hour miniseed U,V,W,F.""" starttime, endtime = get_realtime_interval(realtime_interval) controller = Controller( - inputFactory=input_factory, + inputFactory=input_factory or get_miniseed_factory(), inputInterval="minute", - outputFactory=output_factory, + outputFactory=output_factory or get_miniseed_factory(), outputInterval="hour", ) for channel in ["U", "V", "W", "F"]: @@ -284,11 +121,11 @@ def obsrio_hour( ) -def obsrio_minute( +def filter_minute( observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, - realtime_interval: int = 600, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 60, update_limit: int = 10, ): """Filter 1Hz miniseed U,V,W,F to 1 minute miniseed U,V,W,F""" @@ -318,19 +155,19 @@ def obsrio_minute( ) -def obsrio_temperatures( +def filter_temperatures( observatory: str, - input_factory: TimeseriesFactory, - output_factory: TimeseriesFactory, - realtime_interval: int = 600, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 60, update_limit: int = 10, ): """Filter 1Hz miniseed (LK1-4) to 1 minute miniseed (UK1-4).""" starttime, endtime = get_realtime_interval(realtime_interval) controller = Controller( - inputFactory=input_factory, + inputFactory=input_factory or get_miniseed_factory(), inputInterval="second", - outputFactory=output_factory, + outputFactory=output_factory or get_miniseed_factory(), outputInterval="minute", ) renames = {"LK1": "UK1", "LK2": "UK2", "LK3": "UK3", "LK4": "UK4"} @@ -355,10 +192,10 @@ def obsrio_temperatures( ) -def obsrio_tenhertz( +def filter_tenhertz( observatory: str, - input_factory: Optional[TimeseriesFactory] = None, - output_factory: Optional[TimeseriesFactory] = None, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, realtime_interval: int = 60, update_limit: int = 7, ): @@ -371,10 +208,10 @@ def obsrio_tenhertz( "U", "V", "W", - ) + ), ), inputInterval="tenhertz", - outputFactory=output_factory or get_edge_factory(), + outputFactory=output_factory or get_miniseed_factory(), outputInterval="second", ) for channel in ["U", "V", "W"]: @@ -394,3 +231,29 @@ def obsrio_tenhertz( realtime=realtime_interval, update_limit=update_limit, ) + + +def prepare( + observatory: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 60, + update_limit: int = 10, +): + """Filters 10Hz miniseed U,V,W to 1Hz miniseed U,V,W + Filters 1Hz miniseed LK1-4 to 1 min miniseed UK1-4 + """ + filter_tenhertz( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + filter_temperatures( + observatory=observatory, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) diff --git a/geomagio/processing/pcdcp.py b/geomagio/processing/pcdcp.py new file mode 100644 index 000000000..95496e06b --- /dev/null +++ b/geomagio/processing/pcdcp.py @@ -0,0 +1,219 @@ +from typing import List, Optional + +from ..algorithm import Algorithm +from ..Controller import Controller, get_realtime_interval +from ..edge import EdgeFactory, MiniSeedFactory +from .. import TimeseriesFactory +from .factory import get_edge_factory, get_miniseed_factory +from .DataFormat import DataFormat + + +def copy_adjusted( + observatory: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2061, + output_port: int = 7981, + output_read_port: int = 2060, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Copies 1Hz and 1 min miniseed adjusted + channels to 1Hz and 1 min edge adjusted channels + """ + input_factory = get_miniseed_factory( + host=input_host, + port=input_port, + data_type="adjusted", + locationCode="A0", + ) + output_factory = get_miniseed_factory( + host=output_host, + port=output_read_port, + write_port=output_port, + data_type="adjusted", + locationCode="A0", + ) + input_channels = ["U", "X", "Y", "W", "D", "G"] + output_channels = ["H", "X", "Y", "Z", "D", "G"] + copy_channels( + observatory=observatory, + interval="second", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + input_channels.extend(["USQ", "USV", "UDT"]) + output_channels.extend(["MSQ", "MSV", "MDT"]) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +def copy_variation( + observatory: str, + input_host: str = "127.0.0.1", + output_host: str = "127.0.0.1", + input_port: int = 2061, + output_port: int = 7981, + output_read_port: int = 2060, + realtime_interval: int = 3600, + update_limit: int = 7, + data_format: DataFormat = DataFormat.OBSRIO, +): + """Copies 1Hz and 1 min miniseed variation + channels to 1Hz and 1 min edge variation channels + """ + input_factory = get_miniseed_factory( + host=input_host, port=input_port, data_type="variation" + ) + output_factory = get_edge_factory( + host=output_host, + port=output_read_port, + write_port=output_port, + data_type="variation", + ) + input_channels = ("U", "V", "W", "F") + output_channels = ("H", "E", "Z", "F") + if data_format == DataFormat.OBSRIO: + copy_channels( + observatory=observatory, + interval="second", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=( + "UK1", + "UK2", + "UK3", + "UK4", + ), + output_channels=( + "UK1", + "UK2", + "UK3", + "UK4", + ), + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + input_channels = ["X", "Y", "W", "D", "G"] + output_channels = ["X", "Y", "Z", "D", "G"] + copy_channels( + observatory=observatory, + interval="second", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + input_channels.extend(["USQ", "USV", "UDT"]) + output_channels.extend(["MSQ", "MSV", "MDT"]) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=input_channels, + output_channels=output_channels, + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + +def copy_channels( + observatory: str, + interval: str, + input_channels: List[str], + output_channels: List[str], + input_factory: Optional[TimeseriesFactory] = None, + output_factory: Optional[TimeseriesFactory] = None, + realtime_interval: int = 600, + update_limit: int = 10, +): + """Copy data between edge and miniseed formats""" + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + inputFactory=input_factory or get_edge_factory(), + inputInterval=interval, + outputFactory=output_factory or get_miniseed_factory(), + outputInterval=interval, + ) + for (input_channel, output_channel) in zip(input_channels, output_channels): + controller.run_as_update( + algorithm=Algorithm( + inchannels=(input_channel,), outchannels=(output_channel,) + ), + observatory=(observatory,), + output_observatory=(observatory,), + starttime=starttime, + endtime=endtime, + input_channels=(input_channel,), + output_channels=(output_channel,), + realtime=realtime_interval, + rename_output_channel=((input_channel, output_channel),), + update_limit=update_limit, + ) + + +def prepare( + observatory: str, + input_factory: Optional[EdgeFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + realtime_interval: int = 3600, + update_limit: int = 7, +): + """Copies 1Hz edge H,E,Z,F to 1Hz miniseed U,V,W,F + Copies 1 min edge UK1-4 to 1 min miniseed UK1-4 + """ + copy_channels( + observatory=observatory, + interval="second", + input_channels=["H", "E", "Z", "F"], + output_channels=["U", "V", "W", "F"], + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + copy_channels( + observatory=observatory, + interval="minute", + input_channels=["UK1", "UK2", "UK3", "UK4"], + output_channels=["UK1", "UK2", "UK3", "UK4"], + input_factory=input_factory, + output_factory=output_factory, + realtime_interval=realtime_interval, + update_limit=update_limit, + ) diff --git a/setup.py b/setup.py index dc3fc132f..6d5a5013f 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,8 @@ setuptools.setup( "generate-matrix=geomagio.processing.adjusted:main", "geomag-metadata=geomagio.metadata.main:main", "magproc-prepfiles=geomagio.processing.magproc:main", - "realtime-filter=geomagio.processing.realtime_filter:main", + "observatory=geomagio.processing.observatory:main", + "obsrio-filter=geomagio.processing.obsrio:main", ], }, ) -- GitLab From f1c1f8ffd853f34557020d145df93541902ad6ee Mon Sep 17 00:00:00 2001 From: pcain-usgs <pcain@usgs.gov> Date: Fri, 14 May 2021 12:52:30 -0600 Subject: [PATCH 7/7] Implement average algorithm --- geomagio/processing/derived.py | 44 +++++++++++++++++++++++++++++- geomagio/processing/observatory.py | 32 ++++++++++++++++++++-- 2 files changed, 73 insertions(+), 3 deletions(-) diff --git a/geomagio/processing/derived.py b/geomagio/processing/derived.py index 97c1f8980..91578e9de 100644 --- a/geomagio/processing/derived.py +++ b/geomagio/processing/derived.py @@ -1,10 +1,11 @@ -from typing import Optional +from typing import List, Optional from obspy import UTCDateTime from ..adjusted import AdjustedMatrix from ..algorithm import ( AdjustedAlgorithm, + AverageAlgorithm, DeltaFAlgorithm, SqDistAlgorithm, XYZAlgorithm, @@ -243,6 +244,47 @@ def adjusted( ) +def average( + observatories: List[str], + output_channel: str, + input_factory: Optional[MiniSeedFactory] = None, + output_factory: Optional[MiniSeedFactory] = None, + output_observatory: str = "USGS", + realtime_interval: int = 60, + update_limit: int = 10, +): + """Run Average algorithm. + + Parameters + ---------- + observatories: input observatories to calculate + output_channel: channel to write + input_factory: where to read, should be configured with data_type and interval + output_factory: where to write, should be configured with data_type and interval + output_observatory: observatory where output is written + realtime_interval: window in seconds + + Uses update_limit=10. + """ + starttime, endtime = get_realtime_interval(realtime_interval) + controller = Controller( + algorithm=AverageAlgorithm(observatories=observatories, channel=output_channel), + inputFactory=input_factory or get_miniseed_factory(), + inputInterval="minute", + outputFactory=output_factory or get_miniseed_factory(), + outputInterval="minute", + ) + controller.run_as_update( + observatory=observatories, + output_observatory=(output_observatory,), + starttime=starttime, + endtime=endtime, + output_channels=(output_channel or "UDT",), + realtime=realtime_interval, + update_limit=update_limit, + ) + + def deltaf( observatory: str, input_factory: Optional[MiniSeedFactory] = None, diff --git a/geomagio/processing/observatory.py b/geomagio/processing/observatory.py index d24185674..abf391e21 100644 --- a/geomagio/processing/observatory.py +++ b/geomagio/processing/observatory.py @@ -1,6 +1,6 @@ import typer -from . import obsrio, pcdcp, derived, DataFormat +from . import obsrio, pcdcp, derived, DataFormat, get_miniseed_factory app = typer.Typer() @@ -30,8 +30,36 @@ def adjusted( ) +@app.command() +def average( + data_type: str = "variation", + realtime_interval: int = 60, + update_limit: int = 10, +): + input_factory = get_miniseed_factory(data_type=data_type) + output_factory = get_miniseed_factory(data_type=data_type) + derived.average( + observatories=["HON", "GUA", "SJG"], + output_channel="UX3", + input_factory=input_factory, + output_factory=output_factory, + output_observatory="USGS", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + derived.average( + observatories=["HON", "SJG", "HER", "KAK"], + output_channel="UX4", + input_factory=input_factory, + output_factory=output_factory, + output_observatory="USGS", + realtime_interval=realtime_interval, + update_limit=update_limit, + ) + + @app.command(name="variation") -def process_variation( +def variation( observatory: str, sqdist_statefile: str, data_format: DataFormat = DataFormat.OBSRIO, -- GitLab