From a0bacf3d6a9da4ff07cb1dfbf2a0e02b4ac9ca0f Mon Sep 17 00:00:00 2001
From: pcain-usgs <pcain@usgs.gov>
Date: Fri, 10 Apr 2020 17:21:05 -0600
Subject: [PATCH] Gather ordinates in SPREADSHEET_MEASUREMENTS

---
 .../residual/SpreadsheetAbsolutesFactory.py   | 156 ++++++++++--------
 1 file changed, 85 insertions(+), 71 deletions(-)

diff --git a/geomagio/residual/SpreadsheetAbsolutesFactory.py b/geomagio/residual/SpreadsheetAbsolutesFactory.py
index 1952e8429..c1ed37fce 100644
--- a/geomagio/residual/SpreadsheetAbsolutesFactory.py
+++ b/geomagio/residual/SpreadsheetAbsolutesFactory.py
@@ -18,191 +18,205 @@ SPREADSHEET_MEASUREMENTS = [
     {"type": mt.FIRST_MARK_UP, "angle": "B13"},
     {"type": mt.FIRST_MARK_DOWN, "angle": "C13"},
     {"type": mt.FIRST_MARK_DOWN, "angle": "D13"},
-    # declination
-    {"type": mt.WEST_DOWN, "angle": "C19", "residual": "E19", "time": "B19"},
-    {"type": mt.WEST_DOWN, "angle": "C20", "residual": "E20", "time": "B20"},
-    {"type": mt.EAST_DOWN, "angle": "C21", "residual": "E21", "time": "B21"},
-    {"type": mt.EAST_DOWN, "angle": "C22", "residual": "E22", "time": "B22"},
-    {"type": mt.WEST_UP, "angle": "C23", "residual": "E23", "time": "B23"},
-    {"type": mt.WEST_UP, "angle": "C24", "residual": "E24", "time": "B24"},
-    {"type": mt.EAST_UP, "angle": "C25", "residual": "E25", "time": "B25"},
-    {"type": mt.EAST_UP, "angle": "C26", "residual": "E26", "time": "B26"},
-    # second mark
-    {"type": mt.SECOND_MARK_UP, "angle": "A31"},
-    {"type": mt.SECOND_MARK_UP, "angle": "B31"},
-    {"type": mt.SECOND_MARK_DOWN, "angle": "C31"},
-    {"type": mt.SECOND_MARK_DOWN, "angle": "D31"},
-    # meridian
-    {"type": mt.MERIDIAN, "angle": "C37"},
-    # inclination
-    {"type": mt.SOUTH_DOWN, "angle": "D37", "residual": "E37", "time": "B37"},
-    {"type": mt.SOUTH_DOWN, "angle": "D38", "residual": "E38", "time": "B38"},
-    {"type": mt.NORTH_UP, "angle": "D39", "residual": "E39", "time": "B39"},
-    {"type": mt.NORTH_UP, "angle": "D40", "residual": "E40", "time": "B40"},
-    {"type": mt.SOUTH_UP, "angle": "D41", "residual": "E41", "time": "B41"},
-    {"type": mt.SOUTH_UP, "angle": "D42", "residual": "E42", "time": "B42"},
-    {"type": mt.NORTH_DOWN, "angle": "D43", "residual": "E43", "time": "B43"},
-    {"type": mt.NORTH_DOWN, "angle": "D44", "residual": "E44", "time": "B44"},
-    # scaling
-    {"type": mt.NORTH_DOWN_SCALE, "angle": "D44", "residual": "E44", "time": "B44"},
-    {"type": mt.NORTH_DOWN_SCALE, "angle": "D45", "residual": "E45", "time": "B45"},
-]
-
-SPREADSHEET_ORDINATES = [
     # declination
     {
         "type": mt.WEST_DOWN,
+        "angle": "C19",
+        "residual": "E19",
+        "time": "B19",
         "h": "F19",
         "e": "G19",
-        "z": "H19",
-        "f": "F19",
-        "time": "B19",
+        "z": "F19",
+        "f": "H19",
     },
     {
         "type": mt.WEST_DOWN,
+        "angle": "C20",
+        "residual": "E20",
+        "time": "B20",
         "h": "F20",
         "e": "G20",
-        "z": "H20",
-        "f": "F20",
-        "time": "B20",
+        "z": "F20",
+        "f": "H20",
     },
     {
         "type": mt.EAST_DOWN,
+        "angle": "C21",
+        "residual": "E21",
+        "time": "B21",
         "h": "F21",
         "e": "G21",
-        "z": "H19",
-        "f": "F21",
-        "time": "B21",
+        "z": "F21",
+        "f": "H21",
     },
     {
         "type": mt.EAST_DOWN,
+        "angle": "C22",
+        "residual": "E22",
+        "time": "B22",
         "h": "F22",
         "e": "G22",
-        "z": "H20",
-        "f": "F22",
-        "time": "B22",
+        "z": "F22",
+        "f": "H22",
     },
     {
         "type": mt.WEST_UP,
+        "angle": "C23",
+        "residual": "E23",
+        "time": "B23",
         "h": "F23",
         "e": "G23",
-        "z": "H19",
-        "f": "F23",
-        "time": "B23",
+        "z": "F23",
+        "f": "H23",
     },
     {
         "type": mt.WEST_UP,
+        "angle": "C24",
+        "residual": "E24",
+        "time": "B24",
         "h": "F24",
         "e": "G24",
-        "z": "H20",
-        "f": "F24",
-        "time": "B24",
+        "z": "F24",
+        "f": "H24",
     },
     {
         "type": mt.EAST_UP,
+        "angle": "C25",
+        "residual": "E25",
+        "time": "B25",
         "h": "F25",
         "e": "G25",
-        "z": "H19",
-        "f": "F25",
-        "time": "B25",
+        "z": "F25",
+        "f": "H25",
     },
     {
         "type": mt.EAST_UP,
+        "angle": "C26",
+        "residual": "E26",
+        "time": "B26",
         "h": "F26",
         "e": "G26",
-        "z": "H20",
-        "f": "F26",
-        "time": "B26",
+        "z": "F26",
+        "f": "H26",
     },
+    # second mark
+    {"type": mt.SECOND_MARK_UP, "angle": "A31"},
+    {"type": mt.SECOND_MARK_UP, "angle": "B31"},
+    {"type": mt.SECOND_MARK_DOWN, "angle": "C31"},
+    {"type": mt.SECOND_MARK_DOWN, "angle": "D31"},
+    # meridian
+    {"type": mt.MERIDIAN, "angle": "C37"},
     # inclination
     {
         "type": mt.SOUTH_DOWN,
+        "angle": "D37",
+        "residual": "E37",
+        "time": "B37",
         "h": "C50",
         "e": "D50",
         "z": "E50",
         "f": "B50",
-        "time": "A50",
     },
     {
         "type": mt.SOUTH_DOWN,
+        "angle": "D38",
+        "residual": "E38",
+        "time": "B38",
         "h": "C51",
         "e": "D51",
         "z": "E51",
         "f": "B51",
-        "time": "A51",
     },
     {
         "type": mt.NORTH_UP,
+        "angle": "D39",
+        "residual": "E39",
+        "time": "B39",
         "h": "C52",
         "e": "D52",
         "z": "E52",
         "f": "B52",
-        "time": "A52",
     },
     {
         "type": mt.NORTH_UP,
+        "angle": "D40",
+        "residual": "E40",
+        "time": "B40",
         "h": "C53",
         "e": "D53",
         "z": "E53",
         "f": "B53",
-        "time": "A53",
     },
     {
         "type": mt.SOUTH_UP,
+        "angle": "D41",
+        "residual": "E41",
+        "time": "B41",
         "h": "C54",
         "e": "D54",
         "z": "E54",
         "f": "B54",
-        "time": "A54",
     },
     {
         "type": mt.SOUTH_UP,
+        "angle": "D42",
+        "residual": "E42",
+        "time": "B42",
         "h": "C55",
         "e": "D55",
         "z": "E55",
         "f": "B55",
-        "time": "A55",
     },
     {
         "type": mt.NORTH_DOWN,
+        "angle": "D43",
+        "residual": "E43",
+        "time": "B43",
         "h": "C56",
         "e": "D56",
         "z": "E56",
         "f": "B56",
-        "time": "A56",
     },
     {
         "type": mt.NORTH_DOWN,
+        "angle": "D43",
+        "residual": "E43",
+        "time": "B43",
         "h": "C57",
         "e": "D57",
         "z": "E57",
         "f": "B57",
-        "time": "A57",
     },
     {
         "type": mt.NORTH_DOWN,
+        "angle": "D44",
+        "residual": "E44",
+        "time": "B44",
         "h": "C58",
         "e": "D58",
         "z": "E58",
         "f": "B58",
-        "time": "A58",
     },
     # scaling
     {
         "type": mt.NORTH_DOWN_SCALE,
+        "angle": "D44",
+        "residual": "E44",
+        "time": "B44",
         "h": "C57",
         "e": "D57",
         "z": "E57",
         "f": "B57",
-        "time": "A57",
     },
     {
         "type": mt.NORTH_DOWN_SCALE,
+        "angle": "D45",
+        "residual": "E45",
+        "time": "B45",
         "h": "C58",
         "e": "D58",
         "z": "E58",
         "f": "B58",
-        "time": "A58",
     },
 ]
 
@@ -357,12 +371,12 @@ class SpreadsheetAbsolutesFactory(object):
         """Parse ordinates from a measurement sheet.
         """
         ordinates = []
-        for m in SPREADSHEET_ORDINATES:
+        for m in SPREADSHEET_MEASUREMENTS:
             measurement_type = m["type"]
-            h = "h" in m and sheet[m["h"]].value or None
-            e = "e" in m and sheet[m["e"]].value or None
-            z = "z" in m and sheet[m["z"]].value or None
-            f = "f" in m and sheet[m["f"]].value or None
+            h = "h" in m and sheet[m["h"]].value or 0.0
+            e = "e" in m and sheet[m["e"]].value or 0.0
+            z = "z" in m and sheet[m["z"]].value or 0.0
+            f = "f" in m and sheet[m["f"]].value or 0.0
             time = (
                 "time" in m
                 and parse_relative_time(base_date, sheet[m["time"]].value)
-- 
GitLab