grib
Subpackages
encoding
- anemoi.inference.grib.encoding.encode_time_processing(*, result: dict[str, Any], template: Field, variable: Variable, date: datetime, step: timedelta, previous_step: timedelta | None, start_steps: dict[str, timedelta], edition: int, ensemble: bool) None
Encode time processing information into the result dictionary.
- Parameters:
template (ekd.Field) – The template field.
variable (Variable) – The variable containing time processing information.
date (datetime) – The date and time.
step (timedelta) – The current step.
previous_step (timedelta | None) – The previous step.
start_steps (dict[str, timedelta]) – The start steps dictionary.
edition (int) – The GRIB edition.
ensemble (bool) – Whether the data is part of an ensemble.
- anemoi.inference.grib.encoding.grib_keys(*, values: ndarray[tuple[Any, ...], dtype[Any]], template: Field, variable: Variable, ensemble: bool, param: int | float | str | None, date: datetime, step: timedelta, previous_step: timedelta | None, start_steps: dict[str, timedelta], keys: dict[str, Any], grib1_keys: dict[int | float | str, dict[str, Any]] = {}, grib2_keys: dict[int | float | str, dict[str, Any]] = {}) dict[str, Any]
Generate GRIB keys for encoding.
- Parameters:
values (FloatArray) – The values to encode.
template (ekd.Field) – The template to use.
variable (Variable) – The variable containing GRIB keys.
ensemble (bool) – Whether the data is part of an ensemble.
date (datetime) – The date and time.
step (Any) – The current step.
previous_step (timedelta | None) – The previous step.
start_steps (dict[str, timedelta]) – The start steps dictionary.
grib1_keys (dict[int | float | str, dict[str, Any]], optional) – Additional GRIB1 keys.
grib2_keys (dict[int | float | str, dict[str, Any]], optional) – Additional GRIB2 keys.
- Returns:
The generated GRIB keys.
- Return type:
- anemoi.inference.grib.encoding.check_encoding(handle: Any, keys: dict[str, Any], first: bool = True) None
Check if the GRIB encoding matches the expected keys.
- Parameters:
- Raises:
ValueError – If the GRIB field could not be encoded.
- anemoi.inference.grib.encoding.encode_message(*, values: Any | None, template: Any, metadata: dict[str, Any], check_nans: bool = False, missing_value: int | float = 9999) Any
Encode a GRIB message.
- Parameters:
- Returns:
The encoded GRIB handle.
- Return type:
Any
- class anemoi.inference.grib.encoding.GribWriter(out: Path | IOBase, split_output: bool = True)
Bases:
objectWrite GRIB messages to one or more files.