metadata¶
Manage GRIB metadata.
Functions
|
Compute horizontal components of the origin dict. |
|
|
|
Extract horizontal coordinates. |
|
Extract hybrid level coefficients. |
|
Determine if the field is on a staggered horizontal grid. |
|
Construct a grid from a reference parameter. |
|
Override GRIB metadata. |
|
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.extract_hcoords(metadata: Metadata) dict[str, DataArray] [source]¶
Extract horizontal coordinates.
- Parameters:
metadata (Metadata) – GRIB metadata containing the grid definition.
- Returns:
Horizontal coordinates in geolatlon.
- Return type:
dict[str, xarray.DataArray]
- meteodatalab.metadata.extract_pv(metadata: Metadata) dict[str, DataArray] [source]¶
Extract hybrid level coefficients.
- Parameters:
metadata (Metadata) – GRIB metadata containing the pv metadata.
- Returns:
Hybrid level coefficients.
- 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(metadata: Metadata) Grid [source]¶
Construct a grid from a reference parameter.
- Parameters:
metadata (Metadata) – GRIB metadata defining the reference grid.
- Returns:
reference grid
- Return type:
- meteodatalab.metadata.override(metadata: Metadata, **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. Note that the origin components in x and y are left untouched.
- Parameters:
metadata (Metadata) – Metadata of the input GRIB metadata
kwargs (Any) – Keyword arguments forwarded to earthkit-data GribMetadata override method
- Returns:
Updated metadata along with the geography and parameter namespaces
- Return type:
dict[str, Any]
- 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