From 2f574471946baf0deefb1ee6ab37185090987a9d Mon Sep 17 00:00:00 2001
From: Hal Simpson <hasimpson@usgs.gov>
Date: Wed, 8 Jul 2015 13:44:08 -0600
Subject: [PATCH] Added function to determine if an algorithm can produce data
 for the given timerange.

---
 geomagio/Algorithm.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/geomagio/Algorithm.py b/geomagio/Algorithm.py
index d4a2a45a..bd769908 100644
--- a/geomagio/Algorithm.py
+++ b/geomagio/Algorithm.py
@@ -1,5 +1,7 @@
 """Algorithm Interface."""
 
+import TimeseriesUtility
+
 
 class Algorithm(object):
     """Base class for geomag algorithms
@@ -67,3 +69,25 @@ class Algorithm(object):
             start and end of required input to generate requested output.
         """
         return (start, end)
+
+    def can_produce_data(self, starttime, endtime, stream):
+        """Can Product data
+
+        Parameters
+        ----------
+        starttime: UTCDateTime
+            start time of requested output
+        end : UTCDateTime
+            end time of requested output
+        stream: obspy.core.Stream
+            The input stream we want to make certain has data for the algorithm
+        """
+        input_gaps = TimeseriesUtility.get_merged_gaps(
+                TimeseriesUtility.get_stream_gaps(stream))
+        for input_gap in input_gaps:
+            # Check for gaps that include the entire range
+            if (starttime >= input_gap[0] and
+                    starttime <= input_gap[1] and
+                    endtime < input_gap[2]):
+                return False
+        return True
-- 
GitLab