diff --git a/bin/geomag.py b/bin/geomag.py index 5bcaa2baa2734d688fbf4235d623ae3057962ee8..a63c87fbb2119367413eb2f9b9e7035efc6a9d65 100755 --- a/bin/geomag.py +++ b/bin/geomag.py @@ -17,6 +17,9 @@ from geomagio.Algorithm import Algorithm from geomagio.XYZAlgorithm import XYZAlgorithm from geomagio.Controller import Controller from geomagio.iaga2002.IAGA2002Factory import IAGA_FILE_PATTERN +from geomagio.iaga2002.IAGA2002Factory import iaga_add_parse_arguments +from geomagio.XYZAlgorithm import XYZAlgorithm_add_parse_arguments +from geomagio.edge.EdgeFactory import edge_add_parse_arguments from obspy.core.utcdatetime import UTCDateTime @@ -137,48 +140,12 @@ def parse_args(): parser.add_argument('--interval', default='minute', choices=['minute', 'second']) - parser.add_argument('--algorithm', choices='xyz') - - # xyz algorithm arguments - parser.add_argument('--xyz-informat', - choices=['geo', 'mag', 'obs', 'obsd']) - parser.add_argument('--xyz-outformat', - choices=['geo', 'mag', 'obs', 'obsd']) - - # iaga2002 input arguments - parser.add_argument('--input-iaga-file', - help='Iaga2002 filename') - parser.add_argument('--input-iaga-magweb', - action="store_true", default=False, - help='Indicates iaga2002 files will be read from \ - http://magweb.cr.usgs.gov/data/magnetometer/') - parser.add_argument('--input-iaga-stdin', - action="store_true", default=False, - help='Indicates file will be redirected from stdin') - parser.add_argument('--input-iaga-url', - help='Url or Directory where Iaga2002 files can be read from') - parser.add_argument('--input-iaga-urltemplate', - help='Template for directory matching') - parser.add_argument('--input-iaga-filetemplate', - help='Template for iaga filenames') - - parser.add_argument('--output-iaga-url', - help='Url or Directory where IAGA2002 files should be written to') - parser.add_argument('--output-iaga-stdout', - action="store_true", default=False, - help='Indicates file will be directed to stdout') - parser.add_argument('--output-iaga-urltemplate', - help='Template for subdirectories') - parser.add_argument('--output-iaga-filetemplate', - help='Template for iaga filenames') - parser.add_argument('--output-iaga-file', - help='Output file name for single iaga file.') - - # Edge input arguments - parser.add_argument('--input-edge-host', - help='ip address of the edge input server') - parser.add_argument('--input-edge-port', type=int, - help='port number of the edge input server') + parser.add_argument('--algorithm', choices=['xyz', ]) + + # Add I/O and Algorithm specific arguments + iaga_add_parse_arguments(parser) + edge_add_parse_arguments(parser) + XYZAlgorithm_add_parse_arguments(parser) return parser.parse_args() diff --git a/geomagio/XYZAlgorithm.py b/geomagio/XYZAlgorithm.py index 60e175a70aab2ce1ab3d940cfe538c02ec8e04b6..bf06b300d5abb9f122eb34fa31896a82632b5b2c 100644 --- a/geomagio/XYZAlgorithm.py +++ b/geomagio/XYZAlgorithm.py @@ -19,6 +19,19 @@ CHANNELS = { } +def XYZAlgorithm_add_parse_arguments(parser): + """add XYZ specific arguments to parser + + Parameters + ---------- + parser: argparse.ArgumentParser + """ + parser.add_argument('--xyz-informat', + choices=['geo', 'mag', 'obs', 'obsd']) + parser.add_argument('--xyz-outformat', + choices=['geo', 'mag', 'obs', 'obsd']) + + class XYZAlgorithm(Algorithm): """Algorithm for converting data, probably inapproprately named XYZ. diff --git a/geomagio/edge/EdgeFactory.py b/geomagio/edge/EdgeFactory.py index 9ce07c5b6ef76c39d982059f7314c3828441785f..12a86af0e150f80f7bedde1ca2e70d12b3655627 100644 --- a/geomagio/edge/EdgeFactory.py +++ b/geomagio/edge/EdgeFactory.py @@ -17,6 +17,19 @@ from obspy import earthworm from ObservatoryMetadata import ObservatoryMetadata +def edge_add_parse_arguments(parser): + """add edge specific arguments to parser + + Parameters + ---------- + parser: argparse.ArgumentParser + """ + parser.add_argument('--input-edge-host', + help='ip address of the edge input server') + parser.add_argument('--input-edge-port', type=int, + help='port number of the edge input server') + + class EdgeFactory(TimeseriesFactory): """TimeseriesFactory for Edge related data. diff --git a/geomagio/iaga2002/IAGA2002Factory.py b/geomagio/iaga2002/IAGA2002Factory.py index c5be4f1bd00e3e36552209b24d038561f441ef6c..493bdd08a5e55a8770f611ac28be086a6d1efaf5 100644 --- a/geomagio/iaga2002/IAGA2002Factory.py +++ b/geomagio/iaga2002/IAGA2002Factory.py @@ -43,6 +43,42 @@ def read_url(url): return content +def iaga_add_parse_arguments(parser): + """add iaga2002 specific arguments to parser + + Parameters + ---------- + parser: argparse.ArgumentParser + """ + parser.add_argument('--input-iaga-file', + help='Iaga2002 filename') + parser.add_argument('--input-iaga-magweb', + action="store_true", default=False, + help='Indicates iaga2002 files will be read from \ + http://magweb.cr.usgs.gov/data/magnetometer/') + parser.add_argument('--input-iaga-stdin', + action="store_true", default=False, + help='Indicates file will be redirected from stdin') + parser.add_argument('--input-iaga-url', + help='Url or Directory where Iaga2002 files can be read from') + parser.add_argument('--input-iaga-urltemplate', + help='Template for directory matching') + parser.add_argument('--input-iaga-filetemplate', + help='Template for iaga filenames') + + parser.add_argument('--output-iaga-url', + help='Url or Directory where IAGA2002 files should be written to') + parser.add_argument('--output-iaga-stdout', + action="store_true", default=False, + help='Indicates file will be directed to stdout') + parser.add_argument('--output-iaga-urltemplate', + help='Template for subdirectories') + parser.add_argument('--output-iaga-filetemplate', + help='Template for iaga filenames') + parser.add_argument('--output-iaga-file', + help='Output file name for single iaga file.') + + class IAGA2002Factory(TimeseriesFactory): """TimeseriesFactory for IAGA 2002 formatted files.