From 18446df0f990ddcf5eef66616f07b33a3cb9a08f Mon Sep 17 00:00:00 2001 From: Ilay Falach Date: Sun, 24 May 2026 14:51:41 +0300 Subject: [PATCH] Fix TOA5 parser for TRH devices: handle case-insensitivity and column naming Co-Authored-By: Claude Sonnet 4.6 --- .../measurements/meteorology/highfreqdata/parsers/TOA5.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hera/measurements/meteorology/highfreqdata/parsers/TOA5.py b/hera/measurements/meteorology/highfreqdata/parsers/TOA5.py index 1fe6ed8bd..2c1b0e574 100644 --- a/hera/measurements/meteorology/highfreqdata/parsers/TOA5.py +++ b/hera/measurements/meteorology/highfreqdata/parsers/TOA5.py @@ -74,8 +74,8 @@ def getPandasFromFile(self, path, fromTime, toTime): columnNameMapping = dict([(f"{x}_{device_ID}", f"{x}") for x in cols]) device = "Raw_Sonic" else: - columnsName = ['TIMESTAMP', 'RECORD'] + [f"{x}_{device_ID}" for x in cols] ## For TCT there is no _ - columnNameMapping = dict([(f"{x}_{device_ID}", f"{x}") for x in cols]) + columnsName = ['TIMESTAMP', 'RECORD'] + [f"{x}{device_ID}" for x in cols] ## For TCT there is no _ before device number + columnNameMapping = dict([(f"{x}{device_ID}", f"{x}") for x in cols]) device = "TCT_TRH" columnNameMapping['TIMESTAMP'] = 'TIMESTAMP' @@ -105,14 +105,14 @@ def get_columns(self,path): if device_type[-1]=="Raw_Sonic": cols = ['U','V','W','T'] number_of_devices = len([word for word in next(meta_data_reader) if word.startswith(cols[0])]) - elif device_type[-1]=="Tct_Trh": + elif device_type[-1].lower() == "tct_trh": cols = ['TC_T', 'TRH', 'RH'] number_of_devices = len([word for word in next(meta_data_reader) if word.startswith(cols[0])]) else: ##No metadata in file include_metadata = False if 'Raw_Sonic' in path: cols = ['U', 'V', 'W', 'T'] - elif 'TcT' in path: + elif 'tct' in path.lower(): cols = ['TC_T', 'TRH', 'RH'] else: raise ValueError("No Device could be detected by given file. File should include metadata or device name in file name.")