pre_processors

extract

class anemoi.inference.pre_processors.extract.ExtractBase(context: Context, metadata: Metadata)

Bases: Processor

Base class for pre-processors that extract data from the state.

property indexer: ndarray[tuple[Any, ...], dtype[Any]] | slice
process(state: dict[str, Any]) dict[str, Any]

Process the state to extract a subset of points based on the indexer.

class anemoi.inference.pre_processors.extract.ExtractSlice(context: Context, metadata: Metadata, *slice_args: int)

Bases: ExtractBase

Extract a subset of points from the state based on a slice.

Parameters:
  • context (Context) – The context in which the processor is running.

  • metadata (Metadata) – Metadata corresponding to the dataset this processor is handling.

  • slice_args (int) – Arguments to create a slice object. This can be a single integer or a tuple of integers representing the start, stop, and step of the slice.

forward_transform_filter

mask

class anemoi.inference.pre_processors.mask.MaskValues(context: Context, *, mask: str, param: str | list[str], **kwargs)

Bases: Processor

Replace values in a field with nans from a specified mask in the supporting arrays.

process(state: dict[str, Any]) dict[str, Any]

Apply the mask to the specified parameters in the state.

Parameters:

state (State) – The state containing the fields to be masked.

Returns:

The state with the specified parameters masked.

Return type:

State

no_missing_values

class anemoi.inference.pre_processors.no_missing_values.NoMissingValues(context: Context, metadata: Metadata, **kwargs: Any)

Bases: Processor

Replace NaNs with mean.

process(state: dict[str, Any]) dict[str, Any]

Process the fields to replace NaNs with the mean value.

Parameters:

state (State) – The state to process.

Returns:

List of processed state with NaNs replaced by the mean value.

Return type:

list