From a8267feb1cceb1a760dbe9bbf0f0c1fe43c542ff Mon Sep 17 00:00:00 2001
From: pcain-usgs <pcain@usgs.gov>
Date: Fri, 10 Apr 2020 19:05:33 -0600
Subject: [PATCH] Perform recalculations of H and B absolutes

---
 geomagio/residual/Calculation.py                 | 9 +++++++++
 geomagio/residual/SpreadsheetAbsolutesFactory.py | 4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/geomagio/residual/Calculation.py b/geomagio/residual/Calculation.py
index f11e463a2..8d091d9f3 100644
--- a/geomagio/residual/Calculation.py
+++ b/geomagio/residual/Calculation.py
@@ -69,6 +69,15 @@ def calculate(reading):
     h_abs, z_abs = calculate_absolutes(f, inclination)
     # calculate baselines for H and Z
     h_b, z_b = calculate_baselines(h_abs, z_abs, mean, reading.pier_correction)
+    # gather first measurement's ordinates
+    wd_ord = ordinate_index[mt.WEST_DOWN][0]
+    wd_h = wd_ord.h
+    wd_e = wd_ord.e
+    wd_z = wd_ord.z
+    # recalculate absolute value for H
+    h_abs = np.sqrt((h_b + wd_h) ** 2 + (wd_e) ** 2)
+    # recalculate absolute value for Z
+    z_abs = z_b + wd_z
     # calculate scale value
     scale_ordinates = ordinate_index[mt.NORTH_DOWN_SCALE]
     scale_measurements = measurement_index[mt.NORTH_DOWN_SCALE]
diff --git a/geomagio/residual/SpreadsheetAbsolutesFactory.py b/geomagio/residual/SpreadsheetAbsolutesFactory.py
index 7e8596d28..964d51e60 100644
--- a/geomagio/residual/SpreadsheetAbsolutesFactory.py
+++ b/geomagio/residual/SpreadsheetAbsolutesFactory.py
@@ -26,7 +26,7 @@ SPREADSHEET_MEASUREMENTS = [
         "time": "B19",
         "h": "F19",
         "e": "G19",
-        "z": "F19",
+        "z": "H19",
         "f": "H19",
     },
     {
@@ -36,7 +36,7 @@ SPREADSHEET_MEASUREMENTS = [
         "time": "B20",
         "h": "F20",
         "e": "G20",
-        "z": "F20",
+        "z": "H20",
         "f": "H20",
     },
     {
-- 
GitLab