From 132a2b24878aa6f44195bb4f1f7b6179d0c32053 Mon Sep 17 00:00:00 2001
From: arigdon-usgs <arigdon@usgs.gov>
Date: Fri, 20 Jul 2018 10:58:27 -0600
Subject: [PATCH] Cleaned up channel initialization in XYZalgorithm and calls
 to get_required_channels() in algorithm.py

---
 geomagio/Controller.py             |  4 +---
 geomagio/algorithm/Algorithm.py    |  6 ++++--
 geomagio/algorithm/XYZAlgorithm.py | 14 ++------------
 3 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/geomagio/Controller.py b/geomagio/Controller.py
index f6c92f67c..346070be5 100644
--- a/geomagio/Controller.py
+++ b/geomagio/Controller.py
@@ -245,9 +245,7 @@ class Controller(object):
             if not algorithm.can_produce_data(
                     starttime=output_gap[0],
                     endtime=output_gap[1],
-                    stream=input_timeseries,
-                    channels=algorithm.get_required_channels() or
-                        input_channels):
+                    stream=input_timeseries):
                 continue
             # check for fillable gap at start
             if output_gap[0] == options.starttime:
diff --git a/geomagio/algorithm/Algorithm.py b/geomagio/algorithm/Algorithm.py
index 40fd46f64..c7410f8d6 100644
--- a/geomagio/algorithm/Algorithm.py
+++ b/geomagio/algorithm/Algorithm.py
@@ -87,7 +87,7 @@ class Algorithm(object):
         """
         return (start, end)
 
-    def can_produce_data(self, starttime, endtime, stream, channels=None):
+    def can_produce_data(self, starttime, endtime, stream):
         """Can Product data
 
         Parameters
@@ -100,7 +100,9 @@ class Algorithm(object):
             The input stream we want to make certain has data for the algorithm
         """
         input_gaps = TimeseriesUtility.get_merged_gaps(
-                TimeseriesUtility.get_stream_gaps(stream, channels))
+                TimeseriesUtility.get_stream_gaps(
+                    stream=stream,
+                    channels=self.get_required_channels()))
         for input_gap in input_gaps:
             # Check for gaps that include the entire range
             if (starttime >= input_gap[0] and
diff --git a/geomagio/algorithm/XYZAlgorithm.py b/geomagio/algorithm/XYZAlgorithm.py
index ab75c7b24..d1c4ba63c 100644
--- a/geomagio/algorithm/XYZAlgorithm.py
+++ b/geomagio/algorithm/XYZAlgorithm.py
@@ -140,15 +140,5 @@ class XYZAlgorithm(Algorithm):
         """
         self._informat = arguments.xyz_from
         self._outformat = arguments.xyz_to
-        self._inchannels = arguments.inchannels or \
-                            CHANNELS[self._informat]
-        # Set outchannels to outchannel argument or inchannel designation
-        # if the inchannels do not have 'Z' or 'F' neither will the outchannel
-        if arguments.outchannels:
-            self._outchannels = arguments.outchannels
-        else:
-            self._outchannels = CHANNELS[self._outformat]
-            if 'Z' not in self._inchannels:
-                del self._outchannels[self._outchannels.index('Z')]
-            if 'F' not in self._inchannels:
-                del self._outchannels[self._outchannels.index('F')]
+        self._inchannels = CHANNELS[self._informat]
+        self._outchannels = CHANNELS[self._outformat]
-- 
GitLab