MCPcopy Create free account
hub / github.com/RolnickLab/climart / get_target_variable

Function get_target_variable

climart/utils/utils.py:289–308  ·  view source on GitHub ↗
(target_variable: Union[str, List[str]])

Source from the content-addressed store, hash-verified

287
288
289def get_target_variable(target_variable: Union[str, List[str]]) -> List[str]:
290 if isinstance(target_variable, list):
291 if len(target_variable) == 1 and 'flux' in target_variable[0]:
292 target_variable = target_variable[0]
293 else:
294 return target_variable
295 target_variable2 = target_variable.lower().replace('&', '+').replace('-', '').replace('_', '')
296 target_variable2 = target_variable2.replace('fluxes', 'flux').replace('heatingrate', 'hr')
297 target_vars: List[str] = []
298 if target_variable2 == 'hr':
299 return [constants.SURFACE_FLUXES, constants.TOA_FLUXES, constants.HEATING_RATES]
300 else:
301 if 'flux' in target_variable2:
302 target_vars += [constants.FLUXES]
303 if 'hr' in target_variable2:
304 target_vars += [constants.HEATING_RATES]
305
306 if len(target_vars) == 0:
307 raise ValueError(f"Target var `{target_variable2}` must be one of fluxes, heating_rate.")
308 return target_vars
309
310
311def pressure_from_level_array(levels_array):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected