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

refactored check_stream to use class variables for channel, and call from process

parent 339609bc
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
""" """
from Algorithm import Algorithm from Algorithm import Algorithm
from AlgorithmException import AlgorithmException
import StreamConverter as StreamConverter import StreamConverter as StreamConverter
# List of channels by geomagnetic observatory orientation. # List of channels by geomagnetic observatory orientation.
...@@ -38,7 +39,7 @@ class XYZAlgorithm(Algorithm): ...@@ -38,7 +39,7 @@ class XYZAlgorithm(Algorithm):
self.informat = informat self.informat = informat
self.outformat = outformat self.outformat = outformat
def check_stream(self, timeseries, channels): def check_stream(self, timeseries):
"""checks an stream to make certain all the required channels """checks an stream to make certain all the required channels
exist. exist.
...@@ -49,11 +50,10 @@ class XYZAlgorithm(Algorithm): ...@@ -49,11 +50,10 @@ class XYZAlgorithm(Algorithm):
channels: array_like channels: array_like
channels that are expected in stream. channels that are expected in stream.
""" """
for channel in channels: for channel in self._inchannels:
if len(timeseries.select(channel=channel)) == 0: if len(timeseries.select(channel=channel)) == 0:
print 'Channel %s not found in input' % channel raise AlgorithmException(
return False 'Channel %s not found in input' % channel)
return True
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
...@@ -67,6 +67,7 @@ class XYZAlgorithm(Algorithm): ...@@ -67,6 +67,7 @@ class XYZAlgorithm(Algorithm):
out_stream: obspy.core.Stream out_stream: obspy.core.Stream
new stream object containing the converted coordinates. new stream object containing the converted coordinates.
""" """
self.check_stream(timeseries)
out_stream = None out_stream = None
if self.outformat == 'geo': if self.outformat == 'geo':
if self.informat == 'geo': if self.informat == 'geo':
......
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