Functions for LFRic output

Utilities for working with LFRic output.

aeolus.lfric.add_um_height_coord(cube: Cube, field: str, filename: str, path_to_levels_file: Path) Cube[source]

Callback for iris.load specifically for LFRic data with vertical coord.

Adds a vertical coordinate of level heights from a UM vertical levels file.

Parameters:

path_to_levels_file (Path-like) – Path to the vertical levels file.

Examples

>>> from functools import partial
>>> iris.load(
    filename,
    callback=partial(
        add_um_height_coord,
        path_to_levels_file=Path('/path/to/vertlevs_L38_29t_9s_40km')
    )
)
aeolus.lfric.add_equally_spaced_height_coord(cube: Cube, field: str, filename: str, model_top_height: float) Cube[source]

Callback for iris.load specifically for LFRic data with vertical coord.

Adds a vertical coordinate of level heights assuming equally spaced levels.

Examples

>>> from functools import partial
>>> iris.load(
    filename,
    callback=partial(
        add_equally_spaced_height_coord,
        model_top_height=32000
    )
)
aeolus.lfric.clean_attrs(cube: Cube, field: str, filename: str) Cube[source]

Callback for iris.load to clean up trivial attributes in LFRic data.

Needed for concatenating cubes.

aeolus.lfric.fix_time_coord(cube: Cube, field: str, filename: str, downgrade_to_scalar: bool | None = False) Cube[source]

Callback function for iris.load specifically for UGRID data.

All field variables should have time as a coord, and mesh variables will not have a time coord. So ignore anything that doesn’t have a time coord. Note that mesh info will still be loaded in the coordinate part of the cube.

Make sure that time coordinate is correct type, seems to always be loaded as a basic AuxCoord rather than a Scalar or DimCoord.

aeolus.lfric.load_lfric_mesh(fname: str = 'mesh.nc', var_name: str = 'dynamics') Mesh[source]

Load LFRic mesh from a netCDF file.

aeolus.lfric.load_lfric_raw(fnames: Sequence[Path | str], callback: Callable | None = None, drop_coord: Sequence[str] | None = ()) CubeList[source]

Load raw LFRic data.

aeolus.lfric.replace_level_coord_with_height(cube: Cube) Cube[source]

Remove full_ or half_levels coordinate and replace it with level_height.

Assumes that the cube contains level_height already.

aeolus.lfric.replace_mesh(cube: Cube, new_mesh: Mesh) Cube[source]

Replace mesh in a 1d cube by creating a new copy of that cube.

aeolus.lfric.simple_regrid_lfric(cube_list: ~iris.cube.CubeList, tgt_cube: ~iris.cube.Cube, ref_cube_constr: str | None = 'air_potential_temperature', interp_vertically: bool | None = True, model: ~aeolus.model.base.Model | None = Model [99 fields]) CubeList[source]

Quick&dirty regridding of LFRic data to a common height/lat/lon grid.

aeolus.lfric.ugrid_spatial(cube: ~iris.cube.Cube, aggr: str, model: ~aeolus.model.base.Model | None = Model [99 fields], **kwargs) Cube[source]

Collapse a UGRID iris.cube.Cube over x and y coord with no weights.

aeolus.lfric.ugrid_spatial_mean(cube: ~iris.cube.Cube, model: ~aeolus.model.base.Model | None = Model [99 fields], **kwargs) Cube[source]

Average a UGRID iris.cube.Cube spatially.