src.FRAME_FM.transforms.transforms
Attributes
Classes
A transform that takes a Dataset or DataArray and breaks it into smaller tiles along specified dimensions. |
|
A transform that takes a list of variables from a Dataset and stacks them into a |
Functions
|
If a transform is a dictionary with a "type" key, resolve it to the corresponding transform class instance. |
|
Apply a list of preprocessing transforms to a data sample. |
Module Contents
- class src.FRAME_FM.transforms.transforms.FillMissingValueTransform(strategy: str = 'constant', fill_value: None | float = None, method: None | str = 'linear')[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.FillNaNTransform(strategy: str = 'constant', fill_value: None | float = None, method: None | str = 'linear')[source]
Bases:
FillMissingValueTransform
- class src.FRAME_FM.transforms.transforms.NormalizeTransform(mean: float, std: float)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.ScaleTransform(mean: float, std: float)[source]
Bases:
NormalizeTransform
- class src.FRAME_FM.transforms.transforms.RenameTransform(var_id: str, new_name: str)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.ResampleTransform(dim: str, freq: str | int, method: str = 'mean')[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.ReshapeTransform(shape: tuple)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.RollTransform(dim: str, shift: None | int)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.ReverseAxisTransform(dim: str)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.SortAxisTransform(dim: str, ascending: bool = True)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.SubsetTransform(**subset_selectors)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.SqueezeTransform(*args, **kwargs)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.TilerTransform(boundary: str = 'pad', **dim_tile_sizes)[source]
Bases:
BaseTransformA transform that takes a Dataset or DataArray and breaks it into smaller tiles along specified dimensions. This uses the xarray coarsen + construct pattern to create non-overlapping tiles of the data, which can be useful for training models on large spatial datasets by reducing memory usage and allowing for batch processing of smaller chunks of data.
- class src.FRAME_FM.transforms.transforms.ToDataArray(var_id: str)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.ToTensorTransform(*args, **kwargs)[source]
Bases:
BaseTransform- __call__(sample: DA | numpy.ndarray) torch.Tensor[source]
- class src.FRAME_FM.transforms.transforms.TransposeTransform(*args, **kwargs)[source]
Bases:
BaseTransform
- class src.FRAME_FM.transforms.transforms.VarsToDimensionTransform(variables: list, new_dim: str, only_vars_with_time: bool = True)[source]
Bases:
BaseTransformA transform that takes a list of variables from a Dataset and stacks them into a new dimension, effectively converting the variable dimension into a coordinate dimension. This is useful for models that expect a single multi-channel input rather than separate variables.
Since the purpose is to prepare the data for conversion to a Tensor, we assume that ancillary variables that are not genuine coordinates can be dropped.
- src.FRAME_FM.transforms.transforms.resolve_transform(transform_config: dict) BaseTransform[source]
If a transform is a dictionary with a “type” key, resolve it to the corresponding transform class instance. If it is already an instance of a transform class, return it as is. Args: - transform_config (dict or BaseTransform): The transform configuration to resolve. Returns: - BaseTransform: An instance of a transform class.
- src.FRAME_FM.transforms.transforms.apply_transforms(data: xarray.Dataset | xarray.DataArray, preprocessors: list) xarray.Dataset | xarray.DataArray[source]
Apply a list of preprocessing transforms to a data sample. :param sample: The input data sample to be transformed. :type sample: xr.Dataset | xr.DataArray :param preprocessors: A list of transform configurations to apply to the sample. :type preprocessors: list
- Returns:
The transformed data sample after applying all preprocessors.
- Return type:
xr.Dataset | xr.DataArray