From 9efa6467d716f9d97342647f48c43b2bc51f1c96 Mon Sep 17 00:00:00 2001 From: Hal Simpson <hasimpson@usgs.gov> Date: Fri, 3 Apr 2015 00:01:24 -0600 Subject: [PATCH] refactored check_stream to use class variables for channel, and call from process --- geomagio/XYZAlgorithm.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/geomagio/XYZAlgorithm.py b/geomagio/XYZAlgorithm.py index 60e175a7..12c3a1e0 100644 --- a/geomagio/XYZAlgorithm.py +++ b/geomagio/XYZAlgorithm.py @@ -4,6 +4,7 @@ """ from Algorithm import Algorithm +from AlgorithmException import AlgorithmException import StreamConverter as StreamConverter # List of channels by geomagnetic observatory orientation. @@ -38,7 +39,7 @@ class XYZAlgorithm(Algorithm): self.informat = informat self.outformat = outformat - def check_stream(self, timeseries, channels): + def check_stream(self, timeseries): """checks an stream to make certain all the required channels exist. @@ -49,11 +50,10 @@ class XYZAlgorithm(Algorithm): channels: array_like channels that are expected in stream. """ - for channel in channels: + for channel in self._inchannels: if len(timeseries.select(channel=channel)) == 0: - print 'Channel %s not found in input' % channel - return False - return True + raise AlgorithmException( + 'Channel %s not found in input' % channel) def process(self, timeseries): """converts a timeseries stream into a different coordinate system @@ -67,6 +67,7 @@ class XYZAlgorithm(Algorithm): out_stream: obspy.core.Stream new stream object containing the converted coordinates. """ + self.check_stream(timeseries) out_stream = None if self.outformat == 'geo': if self.informat == 'geo': -- GitLab