Skip to content
Snippets Groups Projects
Commit c897348b authored by Hal Simpson's avatar Hal Simpson
Browse files

updated per comments in git

parent 25d8edab
No related branches found
No related tags found
No related merge requests found
...@@ -25,66 +25,12 @@ def main(): ...@@ -25,66 +25,12 @@ def main():
Inputs Inputs
------ ------
--input: string see --help from commandline.
the type of data for input
currently either iaga or edge. Notes
--output: string -----
the type of data for ouput parses command line options using argparse, then calls the controller
currently either iaga or edge. with instantiated I/O factories, and algorithm(s)
--starttime: string
formatted as a obspy.core.UTCDateTime object
the starttime for data input/output
--endtime: string
formatted as a obspy.core.UTCDateTime object
the endtime for data input/output
--observatory:string
--channels: array_like
list of channels
--type: string
data type
--invterval: string
data interval.
--algorithm: string
name of an algorithm to use.
--xyz-informat: string
The input format/coordinate system of the input file.
geo: geographic coordinate system (xyzf)
mag: magnetic north coordinate system (hdzf)
obs: observatory coordinate system (hezf)
obsd: observatory coordinate system (hdzf)
--xyz-outformat: string
The ouput format/coordinate system of the output file.
geo: geographic coordinate system (xyzf)
mag: magnetic north coordinate system (hdzf)
obs: observatory coordinate system (hezf or hdzf)
--input_iaga_magweb: boolean
indicates to use http://magweb.cr.usgs.gov/data/magnetometer/ as the
source of iaga2002 files.
--input_iaga_url: string
url of iaga2002 files to use as the data source.
--input-iaga-urltemplate: string
template for the subdirectories that files are found in.
example: %(OBS)s/%(interval)s%(type)s/
--input-iaga-filetemplate: string
template for the file name
example: %(obs)s%(ymd)s%(t)s%(i)s.%(i)s
--input-iaga-file: string
the filename of the Iaga2002 file to be read from
--input-iaga-stdin: boolean
indicates the file will be coming from stdin
--output_iaga_file: string
the filename of a new Iaga2002 file to be read to
--output-iaga-url: string
url of directory to write output files in.
--output-iaga-urltemplate: string
template for the subdirectories that files are to be written in.
example: %(OBS)s/%(interval)s%(type)s/
--output-iaga-filetemplate: string
template for the file name
example: %(obs)s%(ymd)s%(t)s%(i)s.%(i)s
--output-iaga-stdout: boolen
indicates output will go to stdout
""" """
args = parse_args() args = parse_args()
...@@ -101,16 +47,12 @@ def main(): ...@@ -101,16 +47,12 @@ def main():
observatory=args.observatory, observatory=args.observatory,
type=args.type, type=args.type,
interval=args.interval) interval=args.interval)
elif args.input_iaga_file is not None: elif args.input_iaga_file is not None or args.input_iaga_stdin:
iagaFile = open(args.input_iaga_file, 'r').read() if args.input_iaga_file is not None:
inputfactory = iaga2002.StreamIAGA2002Factory( iagaFile = open(args.input_iaga_file, 'r').read()
stream=iagaFile, else:
observatory=args.observatory, print >> sys.stderr, "Iaga Input waiting for data from stdin"
type=args.type, iagaFile = sys.stdin.read()
interval=args.interval)
elif args.input_iaga_stdin:
print >> sys.stderr, "Iaga Input waiting for data from stdin"
iagaFile = sys.stdin.read()
inputfactory = iaga2002.StreamIAGA2002Factory( inputfactory = iaga2002.StreamIAGA2002Factory(
stream=iagaFile, stream=iagaFile,
observatory=args.observatory, observatory=args.observatory,
......
...@@ -14,8 +14,9 @@ class Algorithm(object): ...@@ -14,8 +14,9 @@ class Algorithm(object):
An algorithm processes a stream of timeseries to produce new timeseries. An algorithm processes a stream of timeseries to produce new timeseries.
""" """
def __init__(self, channels=None): def __init__(self, inchannels=None, outchannels=None):
self._channels = channels self._inchannels = inchannels
self._outchannels = outchannels
pass pass
def process(self, stream): def process(self, stream):
...@@ -41,7 +42,7 @@ class Algorithm(object): ...@@ -41,7 +42,7 @@ class Algorithm(object):
array_like array_like
list of channels the algorithm needs to operate. list of channels the algorithm needs to operate.
""" """
return self._channels return self._inchannels
def get_output_channels(self): def get_output_channels(self):
"""Get output channels """Get output channels
...@@ -51,4 +52,4 @@ class Algorithm(object): ...@@ -51,4 +52,4 @@ class Algorithm(object):
array_like array_like
list of channels the algorithm will be returning. list of channels the algorithm will be returning.
""" """
return self._channels return self._outchannels
...@@ -13,7 +13,7 @@ class Controller(object): ...@@ -13,7 +13,7 @@ class Controller(object):
algorithm: the algorithm(s) that will take procees the timeseries data algorithm: the algorithm(s) that will take procees the timeseries data
""" """
def __init__(self, inputFactory, outputFactory, algorithm=None): def __init__(self, inputFactory, outputFactory, algorithm):
self._inputFactory = inputFactory self._inputFactory = inputFactory
self._algorithm = algorithm self._algorithm = algorithm
self._outputFactory = outputFactory self._outputFactory = outputFactory
...@@ -31,9 +31,6 @@ class Controller(object): ...@@ -31,9 +31,6 @@ class Controller(object):
input_channels = self._algorithm.get_input_channels() input_channels = self._algorithm.get_input_channels()
timeseries = self._inputFactory.get_timeseries(starttime, endtime, timeseries = self._inputFactory.get_timeseries(starttime, endtime,
channels=input_channels) channels=input_channels)
if self._algorithm is not None: processed = self._algorithm.process(timeseries)
processed = self._algorithm.process(timeseries)
else:
processed = timeseries
output_channels = self._algorithm.get_output_channels() output_channels = self._algorithm.get_output_channels()
self._outputFactory.put_timeseries(processed, channels=output_channels) self._outputFactory.put_timeseries(processed, channels=output_channels)
...@@ -33,7 +33,8 @@ class XYZAlgorithm(Algorithm): ...@@ -33,7 +33,8 @@ class XYZAlgorithm(Algorithm):
""" """
def __init__(self, informat=None, outformat=None): def __init__(self, informat=None, outformat=None):
Algorithm.__init__(self) Algorithm.__init__(self, inchannels=CHANNELS[self.informat],
outchannels=CHANNELS[self.outformat])
self.informat = informat self.informat = informat
self.outformat = outformat self.outformat = outformat
...@@ -54,26 +55,6 @@ class XYZAlgorithm(Algorithm): ...@@ -54,26 +55,6 @@ class XYZAlgorithm(Algorithm):
return False return False
return True return True
def get_input_channels(self):
"""Get input channels
Returns
-------
array_like
list of channels the algorithm needs to operate.
"""
return CHANNELS[self.informat]
def get_output_channels(self):
"""Get output channels
Returns
-------
array_like
list of channels the algorithm will be returning.
"""
return CHANNELS[self.outformat]
def process(self, timeseries): def process(self, timeseries):
"""converts a timeseries stream into a different coordinate system """converts a timeseries stream into a different coordinate system
......
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