forcings

class anemoi.inference.forcings.Forcings(context: TensorHandler)

Bases: ABC

Represents a forcings provider for the model.

Initialize the Forcings object.

Parameters:

context (TensorHandler) – The context for the forcings.

abstractmethod load_forcings_array(dates: list[str | datetime | int], current_state: dict[str, Any]) → ndarray[tuple[Any, ...], dtype[Any]]

Load the forcings for the given dates.

Parameters:
  • dates (List[Date]) – The list of dates for which to load the forcings.

  • current_state (State) – The current state of the model.

Returns:

The loaded forcings as a numpy array.

Return type:

FloatArray

class anemoi.inference.forcings.ComputedForcings(context: TensorHandler, variables: list[str], mask: Any)

Bases: Forcings

Compute forcings like cos_julian_day or insolation.

Initialize the ComputedForcings object.

Parameters:
  • context (TensorHandler) – The context for the forcings.

  • variables (List[str]) – The list of variables to compute.

  • mask (Any) – The mask to apply to the forcings.

load_forcings_array(dates: list[str | datetime | int], current_state: dict[str, Any]) → ndarray[tuple[Any, ...], dtype[Any]]

Load the computed forcings for the given dates.

Parameters:
  • dates (List[Date]) – The list of dates for which to load the forcings.

  • current_state (State) – The current state of the model.

Returns:

The loaded forcings as a numpy array.

Return type:

FloatArray

class anemoi.inference.forcings.CoupledForcings(context: TensorHandler, input: Input, variables: list[str], mask: ndarray[tuple[Any, ...], dtype[Any]])

Bases: Forcings

Retrieve forcings from the input.

Initialize the CoupledForcings object.

Parameters:
  • context (TensorHandler) – The context for the forcings.

  • input (Input) – The input object.

  • variables (List[str]) – The list of variables to retrieve.

  • mask (IntArray) – The mask to apply to the forcings.

property trace_name: str

Return the trace name of the input.

load_forcings_array(dates: list[str | datetime | int], current_state: dict[str, Any]) → ndarray[tuple[Any, ...], dtype[Any]]

Load the forcings for the given dates.

Parameters:
  • dates (List[Any]) – The list of dates for which to load the forcings.

  • current_state (State) – The current state of the model.

Returns:

The loaded forcings as a numpy array.

Return type:

FloatArray

class anemoi.inference.forcings.ConstantForcings(context: TensorHandler, input: Input, variables: list[str], mask: ndarray[tuple[Any, ...], dtype[Any]])

Bases: CoupledForcings

Initialize the CoupledForcings object.

Parameters:
  • context (TensorHandler) – The context for the forcings.

  • input (Input) – The input object.

  • variables (List[str]) – The list of variables to retrieve.

  • mask (IntArray) – The mask to apply to the forcings.

class anemoi.inference.forcings.BoundaryForcings(context: TensorHandler, input: DatasetInput, variables: list[str], variables_mask: ndarray[tuple[Any, ...], dtype[Any]])

Bases: Forcings

Retrieve boundary forcings from the input.

Initialize the BoundaryForcings object.

Parameters:
  • context (TensorHandler) – The context for the forcings.

  • input (DatasetInput) – The input object.

  • variables (List[str]) – The list of variables to retrieve.

  • variables_mask (IntArray) – The mask to apply to the forcings.

load_forcings_array(dates: list[str | datetime | int], current_state: dict[str, Any]) → ndarray[tuple[Any, ...], dtype[Any]]

Load the boundary forcings for the given dates.

Parameters:
  • dates (List[Date]) – The list of dates for which to load the forcings.

  • current_state (State) – The current state of the model.

Returns:

The loaded forcings as a numpy array.

Return type:

FloatArray