Skip to content
Snippets Groups Projects
Commit d59e3cbc authored by Adren Rigdon's avatar Adren Rigdon Committed by Jeremy M Fee
Browse files

Determine interval from delta when data is not from EDGE.

Add optional --output-observatory argument to controller to support average algorithm.
parent f4667f69
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment