Skip to content

data_converter

Classes:

Name Description
DataConverter

Classes#

DataConverter #

Bases: ParameterizedClass, ABC


Base class for running data conversions on retrieved raw data.


Methods:

Name Description
convert

Functions#

convert abstractmethod #
convert(
    data: xr.DataArray,
    variable_name: str,
    dataset_config: DatasetConfig,
    retrieved_dataset: RetrievedDataset,
    **kwargs: Any
) -> Optional[xr.DataArray]

Runs the data converter on the retrieved data.

Parameters:

Name Type Description Default
data DataArray

The retrieved DataArray to convert.

required
retrieved_dataset RetrievedDataset

The retrieved dataset containing data to convert.

required
dataset_config DatasetConfig

The output dataset configuration.

required
variable_name str

The name of the variable to convert.

required

Returns:

Type Description
Optional[DataArray]

Optional[xr.DataArray]: The converted DataArray for the specified variable, or None if the conversion was done in-place.


Source code in tsdat/io/base/data_converter.py
@abstractmethod
def convert(
    self,
    data: xr.DataArray,
    variable_name: str,
    dataset_config: DatasetConfig,
    retrieved_dataset: RetrievedDataset,
    **kwargs: Any,
) -> Optional[xr.DataArray]:
    """-----------------------------------------------------------------------------
    Runs the data converter on the retrieved data.

    Args:
        data (xr.DataArray): The retrieved DataArray to convert.
        retrieved_dataset (RetrievedDataset): The retrieved dataset containing data
            to convert.
        dataset_config (DatasetConfig): The output dataset configuration.
        variable_name (str): The name of the variable to convert.

    Returns:
        Optional[xr.DataArray]: The converted DataArray for the specified variable,
            or None if the conversion was done in-place.

    -----------------------------------------------------------------------------"""
    ...