post_processors

accumulate

class anemoi.inference.post_processors.accumulate.Accumulate(context: Context, metadata: Metadata, *, accumulations: list[str] | None = None, allow_negative: bool = False)

Bases: Processor

Accumulate fields from zero and return the accumulated fields.

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

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

  • accumulations (Optional[List[str]], optional) – List of fields to accumulate, by default None. If None, the fields are taken from the context’s checkpoint.

  • allow_negative (bool, optional) – Whether to allow negative values in the accumulation, by default False.

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

Process the state to accumulate specified fields.

Parameters:

state (State) – The state containing fields to be accumulated.

Returns:

The updated state with accumulated fields.

Return type:

State

assign

backward_transform_filter

class anemoi.inference.post_processors.backward_transform_filter.ForwardTransformFilter(*args: Any, use_forward: bool = False, **kwargs: Any)

Bases: BackwardTransformFilter

Apply a transform forward or reversed backward as a post-processor.

earthkit_state

Code to wrap and unwrap state dictionaries into earthkit.data field lists. So that we can pass them through anemoi-transorm filters.

class anemoi.inference.post_processors.earthkit_state.StateFieldGeography(field: Any)

Bases: object

Geographical information of a state field.

Parameters:

field (Any) – The field containing geographical data.

property shape: tuple[int, ...]

Shape of the geographical field.

Type:

Tuple

class anemoi.inference.post_processors.earthkit_state.StateFieldMetadata(field: Any)

Bases: RawMetadata

Metadata for a state field.

Parameters:

field (Any) – The field containing metadata.

as_namespace(ns: str) dict[str, Any]

Convert metadata to a specific namespace.

Parameters:

ns (str) – The namespace to convert the metadata to.

Returns:

The metadata in the specified namespace.

Return type:

Dict[str, Any]

property geography: StateFieldGeography

Geographical information of the field.

Type:

StateFieldGeography

class anemoi.inference.post_processors.earthkit_state.StateField(*args, **kwargs)

Bases: Field

State field containing name, values, and state information.

Parameters:
  • name (str) – The name of the field.

  • values (FloatArray) – The values of the field.

  • state (Dict[str, Any]) – The state information associated with the field.

property shape: tuple[int, ...]

Shape of the field.

Type:

Tuple

anemoi.inference.post_processors.earthkit_state.wrap_state(state: dict[str, Any]) FieldList

Transform a state dictionary into an earthkit.data field list.

Parameters:

state (Dict[str, Any]) – The state dictionary to be transformed.

Returns:

The transformed field list.

Return type:

ekd.FieldList

anemoi.inference.post_processors.earthkit_state.unwrap_state(fields: FieldList, state: dict[str, Any], namer: Callable) dict[str, Any]

Transform a earthkit.data field list into a state dictionary.

Parameters:
  • fields (ekd.FieldList) – The field list to be transformed.

  • state (State) – The original state dictionary.

  • namer (Callable) – A function to generate new field names.

Returns:

The transformed state dictionary.

Return type:

Dict[str, Any]

extract

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

Bases: Processor

Base class for 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.

Parameters:

state (State) – The state containing fields to be extracted.

Returns:

The updated state with extracted fields.

Return type:

State

class anemoi.inference.post_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.