diff --git a/src/toargridding/static_metadata.py b/src/toargridding/static_metadata.py index 9ab2717498f2337f5e21ba4c58732dd0285eb417..924ddaae51a1fdf70642f3b99c4ac098df959ccb 100644 --- a/src/toargridding/static_metadata.py +++ b/src/toargridding/static_metadata.py @@ -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):