Skip to content

input_key_retrieval_rules

Classes:

Name Description
InputKeyRetrievalRules

Gathers variable retrieval rules for the given input key.

Attributes#

Classes#

InputKeyRetrievalRules #

InputKeyRetrievalRules(
    input_key: InputKey,
    coord_rules: Dict[
        VarName, Dict[Pattern[Any], RetrievedVariable]
    ],
    data_var_rules: Dict[
        VarName, Dict[Pattern[Any], RetrievedVariable]
    ],
)

Gathers variable retrieval rules for the given input key.

Attributes:

Name Type Description
coords Dict[VarName, RetrievedVariable]
data_vars Dict[VarName, RetrievedVariable]
input_key
Source code in tsdat/io/retrievers/input_key_retrieval_rules.py
def __init__(
    self,
    input_key: InputKey,
    coord_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
    data_var_rules: Dict[VarName, Dict[Pattern[Any], RetrievedVariable]],
):
    self.input_key = input_key
    self.coords: Dict[VarName, RetrievedVariable] = {}
    self.data_vars: Dict[VarName, RetrievedVariable] = {}

    for name, retriever_dict in coord_rules.items():
        for pattern, variable_retriever in retriever_dict.items():
            if pattern.match(input_key):
                self.coords[name] = variable_retriever
            break

    for name, retriever_dict in data_var_rules.items():
        for pattern, variable_retriever in retriever_dict.items():
            if pattern.match(input_key):
                self.data_vars[name] = variable_retriever
            break

Attributes#

coords instance-attribute #
coords: Dict[VarName, RetrievedVariable] = {}
data_vars instance-attribute #
data_vars: Dict[VarName, RetrievedVariable] = {}
input_key instance-attribute #
input_key = input_key