From c54f184ff70829b38d7213839192a3e6fdebfc14 Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Sun, 2 Mar 2025 15:11:18 -0700 Subject: [PATCH 1/3] Add sncl_mode and scale_factor options to controller: These will be passed to IO factories if those factories accept them. As of this commit, only Edge and MiniSeed factories honor these options. Others should be updated to accept these, and apply them in a similar manner. --- geomagio/Controller.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/geomagio/Controller.py b/geomagio/Controller.py index 7895fc54..6297df43 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -491,6 +491,8 @@ def get_input_factory(args): # standard arguments input_factory_args = {} input_factory_args["interval"] = args.input_interval or args.interval + input_factory_args["scale_factor"] = args.input_scale_factor or args.scale_factor + input_factory_args["sncl_mode"] = args.input_sncl_mode or args.sncl_mode input_factory_args["observatory"] = args.observatory input_factory_args["type"] = args.type input_type = args.input @@ -600,6 +602,8 @@ def get_output_factory(args): # standard arguments output_factory_args = {} output_factory_args["interval"] = args.output_interval or args.interval + output_factory_args["scale_factor"] = args.output_scale_factor or args.scale_factor + output_factory_args["sncl_mode"] = args.ouput_sncl_mode or args.sncl_mode output_factory_args["observatory"] = args.output_observatory output_factory_args["type"] = args.type # stream/url arguments @@ -878,6 +882,17 @@ def parse_args(args): metavar="PORT", type=int, ) + input_group.add_argument( + "--input-scale-factor", + default=None, + help="Override default factory scale_factor (divide on read; multiply on write)", + ) + input_group.add_argument( + "--input-sncl-mode", + default=None, + help="Override default factory sncl_mode", + choices=["geomag", "legacy", "fdsn"], + ) input_group.add_argument( "--input-stdin", action="store_true", @@ -969,6 +984,17 @@ def parse_args(args): metavar=("FROM", "TO"), nargs=2, ) + input_group.add_argument( + "--scale-factor", + default=None, + help="Override default factory scale_factor (divide on read; multiply on write)", + ) + input_group.add_argument( + "--sncl-mode", + default=None, + help="Override default factory sncl_mode", + choices=["geomag", "legacy", "fdsn"], + ) input_group.add_argument( "--type", default="variation", @@ -1102,6 +1128,17 @@ def parse_args(args): metavar="PORT", type=int, ) + output_group.add_argument( + "--output-scale-factor", + default=None, + help="Override default factory scale_factor (divide on read; multiply on write)", + ) + output_group.add_argument( + "--output-sncl-mode", + default=None, + help="Override default factory sncl_mode ()", + choices=["geomag", "legacy", "fdsn"], + ) output_group.add_argument( "--output-stdout", action="store_true", -- GitLab From d46ef71fbc2478b1f83c7caabe69662bceaaa10e Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Sun, 2 Mar 2025 19:03:29 -0700 Subject: [PATCH 2/3] Only EdgeFactory and MiniSeedFactory use scale_factor and sncl_mode: I knew this in the previous commit, but I thought their parent class, TimeseriesFactory, could handle arbitrary keywords (i.e., it had a kwargs argument to vacuum up unrecognized keywords). I was mistaken. --- geomagio/Controller.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/geomagio/Controller.py b/geomagio/Controller.py index 6297df43..1380c34b 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -491,8 +491,6 @@ def get_input_factory(args): # standard arguments input_factory_args = {} input_factory_args["interval"] = args.input_interval or args.interval - input_factory_args["scale_factor"] = args.input_scale_factor or args.scale_factor - input_factory_args["sncl_mode"] = args.input_sncl_mode or args.sncl_mode input_factory_args["observatory"] = args.observatory input_factory_args["type"] = args.type input_type = args.input @@ -519,6 +517,8 @@ def get_input_factory(args): host=args.input_host, port=args.input_port, locationCode=args.locationcode, + scale_factor=args.input_scale_factor or args.scale_factor, + sncl_mode=args.input_sncl_mode or args.sncl_mode, **input_factory_args, ) elif input_type == "goes": @@ -564,6 +564,8 @@ def get_input_factory(args): port=args.input_port, locationCode=args.locationcode, convert_channels=args.convert_voltbin, + scale_factor=args.input_scale_factor or args.scale_factor, + sncl_mode=args.input_sncl_mode or args.sncl_mode, **input_factory_args, ) elif input_type == "xml": @@ -602,8 +604,6 @@ def get_output_factory(args): # standard arguments output_factory_args = {} output_factory_args["interval"] = args.output_interval or args.interval - output_factory_args["scale_factor"] = args.output_scale_factor or args.scale_factor - output_factory_args["sncl_mode"] = args.ouput_sncl_mode or args.sncl_mode output_factory_args["observatory"] = args.output_observatory output_factory_args["type"] = args.type # stream/url arguments @@ -632,6 +632,8 @@ def get_output_factory(args): locationCode=locationcode, tag=args.output_edge_tag, forceout=args.output_edge_forceout, + scale_factor=args.input_scale_factor or args.scale_factor, + sncl_mode=args.input_sncl_mode or args.sncl_mode, **output_factory_args, ) elif output_type == "plot": @@ -662,6 +664,8 @@ def get_output_factory(args): port=args.output_read_port, write_port=args.output_port, locationCode=locationcode, + scale_factor=args.input_scale_factor or args.scale_factor, + sncl_mode=args.input_sncl_mode or args.sncl_mode, **output_factory_args, ) elif output_type == "xml": -- GitLab From b7d331600352d196214c1e8ca97b8f4fb53d55e6 Mon Sep 17 00:00:00 2001 From: "E. Joshua Rigler" <erigler@usgs.gov> Date: Tue, 4 Mar 2025 14:08:16 -0700 Subject: [PATCH 3/3] Update version metadata for new release --- code.json | 4 ++-- pyproject.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code.json b/code.json index a130d5d5..5c7fac86 100644 --- a/code.json +++ b/code.json @@ -3,7 +3,7 @@ "name": "geomag-algorithms", "organization": "U.S. Geological Survey", "description": "Library for processing Geomagnetic timeseries data.", - "version": "1.13.2", + "version": "1.13.3", "status": "Development", "permissions": { "usageType": "openSource", @@ -35,7 +35,7 @@ "email": "gs-haz_dev_team_group@usgs.gov" }, "date": { - "metadataLastUpdated": "2025-02-27" + "metadataLastUpdated": "2025-03-04" } } ] \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 3205b459..36c1a304 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ packages = [ {include = "geomagio" } ] repository="https://code.usgs.gov/ghsc/geomag/geomag-algorithms" -version = "1.13.2" +version = "1.13.3" [tool.poetry.dependencies] -- GitLab