@@ -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