Skip to content

Commit 5e0f730

Browse files
committed
Added new variable names as they differ between datasets. Found and not found variables are now printed when creating OG1 dataset
1 parent 5b6e1f6 commit 5e0f730

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

seagliderOG1/config/OG1_var_names.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ sound_velocity: SOUND_VELOCITY
8888

8989
### flight model parameters ###
9090
sg_cal_vbd_min_cnts: VBD_MIN_CNTS
91+
log_VBD_MIN: VBD_MIN_CNTS
9192
sg_cal_vbd_cnts_per_cc: VBD_CNTS_PER_CC
93+
log_VBD_CNV: VBD_CC_PER_CNTS
9294
sg_cal_mass: MASS
9395
sg_cal_volmax: VOLMAX
9496
log_C_VBD: C_VBD
9597
sg_cal_hd_a: HD_A
9698
sg_cal_hd_b: HD_B
9799
sg_cal_hd_c: HD_C
100+
sg_cal_vbdbias: VBD_BIAS
98101

99102
sbe41: Seabird unpumped CTD
100103
wlbb2f: Wetlabs BB2FL-VMT

seagliderOG1/tools.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,10 +1139,8 @@ def extract_hdm_parameters(list_datasets):
11391139
dict: A nested dictionary where keys are standard names and values contain
11401140
the 'data' and 'attributes'.
11411141
"""
1142-
potential_parameters = [
1143-
"sg_cal_vbd_min_cnts", "sg_cal_vbd_cnts_per_cc", "sg_cal_mass",
1144-
"sg_cal_volmax", "log_C_VBD", "sg_cal_hd_a", "sg_cal_hd_b", "sg_cal_hd_c"
1145-
]
1142+
potential_parameters_OG1 = ['VBD_MIN_CNTS','VBD_CNTS_PER_CC','VBD_CC_PER_CNTS','VBD_BIAS','MASS','VOLMAX','C_VBD','HD_A','HD_B','HD_C']
1143+
potential_parameters = [key for key, value in standard_names.items() if value in potential_parameters_OG1]
11461144
hdm_variables = {}
11471145

11481146
for param in potential_parameters:
@@ -1153,7 +1151,6 @@ def extract_hdm_parameters(list_datasets):
11531151

11541152
# 1. Check if the parameter exists in the datasets
11551153
if param not in list_datasets[0].variables:
1156-
print(f"Variable '{param}' not found in dataset. Skipping.")
11571154
continue
11581155

11591156
# 2. Extract values from all datasets
@@ -1168,11 +1165,19 @@ def extract_hdm_parameters(list_datasets):
11681165
if isinstance(final_value, list):
11691166
final_value = np.array(final_value)
11701167

1171-
# 4. Store as a dictionary to accommodate both value and attributes
1168+
# 4. Store as a dictionary to accommodate both value and attributes and add long_name attribute
11721169
hdm_variables[param_key] = {
11731170
"values": final_value,
1174-
"attributes": list_datasets[0][param].attrs
1171+
"attributes": list_datasets[0][param].attrs # Add long_name attribute
11751172
}
1173+
hdm_variables[param_key]["attributes"]["original_name"] = param_key
1174+
1175+
# 5. Print what parameters from potential_parameters were found and which couldn't not be found in the datasets
1176+
found_params = [param for param in potential_parameters_OG1 if param in hdm_variables]
1177+
not_found_params = [param for param in potential_parameters_OG1 if param not in hdm_variables]
1178+
print(f"The following HDM parameters were found: {found_params}")
1179+
if not_found_params:
1180+
print(f"Warning: The following potential HDM parameters were not found in the datasets: {not_found_params}")
11761181

11771182
return hdm_variables
11781183

0 commit comments

Comments
 (0)