tsdat.config.dataset_definition
¶
Module Contents¶
Classes¶
Wrapper for the dataset_definition portion of the pipeline config |
-
class
tsdat.config.dataset_definition.
DatasetDefinition
(dictionary: Dict, datastream_name: str)¶ Wrapper for the dataset_definition portion of the pipeline config file.
- Parameters
dictionary (Dict) – The portion of the config file corresponding with the dataset definition.
datastream_name (str) – The name of the datastream that the config file is for.
-
_parse_dimensions
(self, dictionary: Dict) → Dict[str, tsdat.config.dimension_definition.DimensionDefinition]¶ Extracts the dimensions from the dataset_definition portion of the config file.
- Parameters
dictionary (Dict) – The dataset_definition dictionary from the config file.
- Returns
Returns a mapping of output dimension names to DimensionDefinition objects.
- Return type
Dict[str, DimensionDefinition]
-
_parse_variables
(self, dictionary: Dict, available_dimensions: Dict[str, tsdat.config.dimension_definition.DimensionDefinition]) → Dict[str, tsdat.config.variable_definition.VariableDefinition]¶ Extracts the variables from the dataset_definition portion of the config file.
- Parameters
dictionary (Dict) – The dataset_definition dictionary from the config file.
available_dimensions (Dict[str, DimensionDefinition]) – The DimensionDefinition objects that have already been parsed.
- Returns
Returns a mapping of output variable names to VariableDefinition objects.
- Return type
Dict[str, VariableDefinition]
-
_parse_coordinates
(self, vars: Dict[str, tsdat.config.variable_definition.VariableDefinition]) → Tuple[Dict[str, tsdat.config.variable_definition.VariableDefinition], Dict[str, tsdat.config.variable_definition.VariableDefinition]]¶ Separates coordinate variables and data variables.
Determines which variables are coordinate variables and moves those variables from
self.vars
toself.coords
. Coordinate variables are defined as variables that are dimensioned by themselves, i.e.,var.name == var.dim.name
is a true statement for coordinate variables, but false for data variables.- Parameters
vars (Dict[str, VariableDefinition]) – The dictionary of VariableDefinition objects to check.
- Returns
The dictionary of dimensions in the dataset.
- Return type
Tuple[Dict[str, VariableDefinition], Dict[str, VariableDefinition]]
-
_validate_dataset_definition
(self)¶ Performs sanity checks on the DatasetDefinition object.
- Raises
DefinitionError – If any sanity checks fail.
-
get_attr
(self, attribute_name) → Any¶ Retrieves the value of the attribute requested, or None if it does not exist.
- Parameters
attribute_name (str) – The name of the attribute to retrieve.
- Returns
The value of the attribute, or None.
- Return type
Any
-
get_variable_names
(self) → List[str]¶ Retrieves the list of variable names. Note that this excludes coordinate variables.
- Returns
The list of variable names.
- Return type
List[str]
-
get_variable
(self, variable_name: str) → tsdat.config.variable_definition.VariableDefinition¶ Attemps to retrieve the requested variable. First searches the data variables, then searches the coordinate variables. Returns
None
if no data or coordinate variables have been defined with the requested variable name.- Parameters
variable_name (str) – The name of the variable to retrieve.
- Returns
Returns the VariableDefinition for the variable, or
None
if the variable could not be found.- Return type
VariableDefinition
-
get_coordinates
(self, variable: tsdat.config.variable_definition.VariableDefinition) → List[tsdat.config.variable_definition.VariableDefinition]¶ Returns the coordinate VariableDefinition object(s) that dimension the requested VariableDefinition.
- Parameters
variable (VariableDefinition) – The VariableDefinition whose coordinate variables should be retrieved.
- Returns
A list of VariableDefinition coordinate variables that dimension the provided VariableDefinition.
- Return type
List[VariableDefinition]
-
get_static_variables
(self) → List[tsdat.config.variable_definition.VariableDefinition]¶ Retrieves a list of static VariableDefinition objects. A variable is defined as static if it has a “data” section in the config file, which would mean that the variable’s data is defined statically. For example, in the config file snippet below, “depth” is a static variable:
depth: data: [4, 8, 12] dims: [depth] type: int attrs: long_name: Depth units: m
- Returns
The list of static VariableDefinition objects.
- Return type
List[VariableDefinition]