diff --git a/geomagio/Controller.py b/geomagio/Controller.py index d176b10c08f610241717039550528426cd76b299..875483e0de69c92870aeaa441f7c03d5bdd8be40 100644 --- a/geomagio/Controller.py +++ b/geomagio/Controller.py @@ -217,7 +217,7 @@ class Controller(object): algorithm.get_output_channels() # request output to see what has already been generated output_timeseries = self._get_output_timeseries( - observatory=options.observatory, + observatory=options.output_observatory, starttime=options.starttime, endtime=options.endtime, channels=output_channels) @@ -346,7 +346,7 @@ def get_output_factory(args): # standard arguments output_factory_args = {} output_factory_args['interval'] = args.interval - output_factory_args['observatory'] = args.observatory + output_factory_args['observatory'] = args.output_observatory output_factory_args['type'] = args.type # stream/url arguments if args.output_file is not None: @@ -479,10 +479,16 @@ def main(args): if isinstance(args.observatory, (str, unicode)): args.observatory = (args.observatory,) + if args.output_observatory is None: + args.output_observatory = args.observatory + elif args.observatory_foreach: + raise Exception("Cannot specify --output-observatory with --observatory-foreach") + if args.observatory_foreach: observatory = args.observatory for obs in observatory: args.observatory = (obs,) + args.output_observatory = (obs,) _main(args) else: _main(args) @@ -551,6 +557,15 @@ def parse_args(args): ' single observatory formats like IAGA and PCDCP.', nargs='*', type=str) + parser.add_argument('--output-observatory', + default=None, + help='Defaults to valur of --observatory argument.' + + ' Observatory code ie BOU, CMO, etc.' + + ' CAUTION: Using multiple observatories is not' + + ' recommended in most cases; especially with' + + ' single observatory formats like IAGA and PCDCP.', + nargs='*', + type=str) parser.add_argument('--observatory-foreach', action='store_true', default=False, diff --git a/geomagio/algorithm/AverageAlgorithm.py b/geomagio/algorithm/AverageAlgorithm.py index 092bad2db6f0016cea0ff9af3480f00aac21d0a9..662de7919ac30b4d08f20cb1a9d18829fa661279 100644 --- a/geomagio/algorithm/AverageAlgorithm.py +++ b/geomagio/algorithm/AverageAlgorithm.py @@ -118,14 +118,22 @@ class AverageAlgorithm(Algorithm): stream = obspy.core.Stream(( get_trace(self.outchannel, self._stats, dst_tot), )) + # TODO: move this to a better place + interval = None + if 'data_interval' in timeseries[0].stats: + interval = timeseries[0].stats.data_interval + elif timeseries[0].stats.delta == 60: + interval = 'minute' + elif timeseries[0].stats.delta == 1: + interval = 'second' + # set the full metadata for the USGS station used for averaged # data sets self.set_metadata( stream=stream, observatory='USGS', channel=self.outchannel, - type=stream[0].stats.data_type, - interval=timeseries[0].stats.data_interval) + type=stream[0].stats.data_type) # return averaged values as a stream return stream