Skip to content

Commit

Permalink
define TranslatedVarlistEntry name attribute using data convention fi…
Browse files Browse the repository at this point in the history
…eld table variable id
  • Loading branch information
wrongkindofdoctor committed Dec 2, 2024
1 parent 7dc364a commit f6e0992
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,19 +488,21 @@ def translate(self, var, data_convention: str):
coords_copy = copy.deepcopy(var.dims) + copy.deepcopy(var.scalar_coords)
fieldlist_obj = VariableTranslator().get_convention(data_convention)
fieldlist_entry = dict()
for variable_id_dict in fieldlist_obj.lut.values():
variable_id = ""
for variable_id, variable_id_dict in fieldlist_obj.lut.items():
if variable_id_dict.get('standard_name', None) == var.standard_name \
or var.standard_name in variable_id_dict.get('alternate_standard_names'):
if variable_id_dict.get('realm', None) == var.realm \
and variable_id_dict.get('units', None) == var.units.units:
fieldlist_entry = variable_id_dict
var_id = variable_id

Check notice

Code scanning / CodeQL

Unused local variable Note

Variable var_id is not used.
break
if len(fieldlist_entry.keys()) < 1:
var.log.error(f'No {data_convention} fieldlist entry found for variable {var.name}')
return None
alt_standard_names = fieldlist_entry.get('alternate_standard_names')
return TranslatedVarlistEntry(
name=var.name,
name=variable_id,
standard_name=var.standard_name,
units=var.units,
convention=var.convention,
Expand Down

0 comments on commit f6e0992

Please sign in to comment.