From 821b8e11fee6e9aa6e2164a0e13e3cc54a7be9fb Mon Sep 17 00:00:00 2001
From: "E. Joshua Rigler" <erigler@usgs.gov>
Date: Thu, 13 Mar 2025 14:24:37 -0600
Subject: [PATCH] Fix IAGA2002 channel parser:

Handles case of broken IAGA2002 file where the channel headers don't align perfectly with the expected columns. Our IAGA2002 files never did this, but some from others did.
---
 geomagio/iaga2002/IAGA2002Parser.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/geomagio/iaga2002/IAGA2002Parser.py b/geomagio/iaga2002/IAGA2002Parser.py
index 7e861157..0d475169 100644
--- a/geomagio/iaga2002/IAGA2002Parser.py
+++ b/geomagio/iaga2002/IAGA2002Parser.py
@@ -132,10 +132,11 @@ class IAGA2002Parser(object):
         Creates empty values arrays in ``self.data``.
         """
         iaga_code = self.metadata["station"]
-        self.channels.append(line[30:40].strip().replace(iaga_code, ""))
-        self.channels.append(line[40:50].strip().replace(iaga_code, ""))
-        self.channels.append(line[50:60].strip().replace(iaga_code, ""))
-        self.channels.append(line[60:69].strip().replace(iaga_code, ""))
+        # self.channels.append(line[30:40].strip().replace(iaga_code, ""))
+        # self.channels.append(line[40:50].strip().replace(iaga_code, ""))
+        # self.channels.append(line[50:60].strip().replace(iaga_code, ""))
+        # self.channels.append(line[60:69].strip().replace(iaga_code, ""))
+        self.channels.extend(line.replace("|", "").replace(iaga_code, "").split()[3:7])
 
     def _parse_data(self, line):
         """Parse one data point in the timeseries.
-- 
GitLab