From 696082d1c605e46c11a70f8b99400650adf7dd83 Mon Sep 17 00:00:00 2001
From: Hal Simpson <hasimpson@usgs.gov>
Date: Fri, 27 Mar 2015 17:18:26 -0600
Subject: [PATCH] Controller for geomagio

---
 geomagio/Controller.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 geomagio/Controller.py

diff --git a/geomagio/Controller.py b/geomagio/Controller.py
new file mode 100644
index 00000000..928fe629
--- /dev/null
+++ b/geomagio/Controller.py
@@ -0,0 +1,29 @@
+#! /usr/bin/env python
+
+"""Converts iaga2002 files from one coordinate system to another.
+
+    Inputs
+    ------
+    inputFactory: TimeseriesFactory
+    outputFactory: TimeseriesFactory
+    algorithm: Algorithm
+"""
+
+
+class Controller(object):
+
+    def __init__(self, inputFactory, outputFactory, algorithm=None):
+        self._inputFactory = inputFactory
+        self._algorithm = algorithm
+        self._outputFactory = outputFactory
+
+    def run(self, starttime, endtime):
+        input_channels = self._algorithm.get_input_channels()
+        timeseries = self._inputFactory.get_timeseries(starttime, endtime,
+                channels=input_channels)
+        if self._algorithm is not None:
+            processed = self._algorithm.process(timeseries)
+        else:
+            processed = timeseries
+        output_channels = self._algorithm.get_output_channels()
+        self._outputFactory.put_timeseries(processed, channels=output_channels)
-- 
GitLab