Skip to content
Snippets Groups Projects
Commit da1f4398 authored by Carsten Hinz's avatar Carsten Hinz
Browse files

added option to get variable from ID instead of name or cf_standard_name

parent 9aa0c60b
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,26 @@ class TOARVariable:
return var
msg = f"TOAR Database contains no variable {name}"
raise ValueError(msg)
@classmethod
def get_from_id(cls, id : int) -> "TOARVariable":
"""searches the known variables for the given id
Parameters:
----------
id:
id of the variable according to the TOAR database config
return:
provides direct access to the meta data of the selected variable
"""
if id == None:
raise ValueError("No id provided for variable.")
for var in cls.vars:
if var.id == id:
return var
msg = f"TOAR Database contains no variable with id {id}"
raise ValueError(msg)
@property
def toar_id(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment