metadata#
Manage GRIB metadata.
Functions
|
Compute horizontal components of the origin dict. |
|
Deserialise a base64-encoded GRIB message to a Field object. |
|
Extract GRIB field metadata. |
|
Extract horizontal coordinates. |
|
Determine if the field is on a staggered horizontal grid. |
|
Construct a grid from a reference parameter. |
|
Override GRIB metadata. |
|
Serialise a GRIB field to a base64-encoded string. |
|
Set horizontal components of the origin attribute. |
Classes
|
Coordinates of the reference grid. |
- class meteodatalab.metadata.Grid(lon_first_grid_point: float, lat_first_grid_point: float)[source]#
Coordinates of the reference grid.
- lon_first_grid_point#
longitude of first grid point in rotated lat-lon CRS
- Type:
float
- lat_first_grid_point#
latitude of first grid point in rotated lat-lon CRS
- Type:
float
- meteodatalab.metadata.compute_origin(ref_grid: Grid, field: DataArray) dict[str, float][source]#
Compute horizontal components of the origin dict.
- Parameters:
ref_grid (Grid) – reference grid
field (xarray.DataArray) – field for which to compute the origin
- Returns:
Horizontal components of the origin
- Return type:
dict[str, float]
- meteodatalab.metadata.deserialise_field(value: str) Field[source]#
Deserialise a base64-encoded GRIB message to a Field object.
- Parameters:
value (str) – Base64-encoded GRIB message.
- Returns:
GRIB field with no values loaded.
- Return type:
earthkit.data.Field
- meteodatalab.metadata.extract(field: Field) dict[str, Any][source]#
Extract GRIB field metadata.
- Parameters:
field (earthkit.data.Field) – GRIB field from which to extract metadata.
- Returns:
Dictionary containing parameter, geography, vref, vcoord_type, and origin_z metadata extracted from the field.
- Return type:
dict[str, Any]
- meteodatalab.metadata.extract_hcoords(message_b64: str) dict[str, DataArray][source]#
Extract horizontal coordinates.
- Parameters:
message_b64 (str) – Serialised GRIB message containing the grid definition.
- Returns:
Horizontal coordinates in geolatlon.
- Return type:
dict[str, xarray.DataArray]
- meteodatalab.metadata.is_staggered_horizontal(field: DataArray) bool[source]#
Determine if the field is on a staggered horizontal grid.
- Parameters:
field (xr.DataArray) – Field containing the grid definition.
- Raises:
ValueError – if the field is a on regular grid without origin_x and origin_y set.
- Returns:
True if the field is on a staggered horizontal grid.
- Return type:
bool
- meteodatalab.metadata.load_grid_reference(field: Field) Grid[source]#
Construct a grid from a reference parameter.
- Parameters:
field (earthkit.data.Field) – Field defining the reference grid.
- Returns:
reference grid
- Return type:
- meteodatalab.metadata.override(message: str, **kwargs: Any) dict[str, Any][source]#
Override GRIB metadata.
Note that no special consideration is made for maintaining consistency when overriding template definition keys such as productDefinitionTemplateNumber.
- Parameters:
message (str) – Serialised GRIB message with original values
kwargs (Any) – Metadata keys and values that are overridden in the output
- Returns:
Updated metadata along with the geography and parameter namespaces
- Return type:
dict[str, Any]
- meteodatalab.metadata.serialise_field(field: Field) str[source]#
Serialise a GRIB field to a base64-encoded string.
- Parameters:
field (earthkit.data.Field) – GRIB field to serialise.
- Returns:
Base64-encoded GRIB message.
- Return type:
str
- meteodatalab.metadata.set_origin_xy(ds: dict[str, DataArray], ref_param: str) None[source]#
Set horizontal components of the origin attribute.
- Parameters:
ds (dict[str, xarray.DataArray]) – Dataset of fields to update.
ref_param (str) – Name of the parameter field to use as a reference. Must be a key of ds.
- Raises:
KeyError – if the ref_param key is not found in the input dataset