improver.standardise module

Plugin to standardise metadata

class StandardiseMetadata[source]

Bases: BasePlugin

Plugin to standardise cube metadata

_abc_impl = <_abc_data object>
static _collapse_scalar_dimensions(cube)[source]

Demote any scalar dimensions (excluding “realization”) on the input cube to auxiliary coordinates.

Parameters:

cube (Cube) – The cube

Return type:

Cube

Returns:

The collapsed cube

static _discard_redundant_cell_methods(cube)[source]

Removes cell method “point”: “time” from cube if present.

Return type:

None

static _remove_scalar_coords(cube, coords_to_remove)[source]

Removes named coordinates from the input cube.

Return type:

None

static _rm_air_temperature_status_flag(cube)[source]

Remove air_temperature status_flag coord by applying as NaN to cube data.

See https://github.com/metoppv/improver/pull/1839 for further details.

Return type:

Cube

static _standardise_dtypes_and_units(cube)[source]

Modify input cube in place to conform to mandatory dtype and unit standards.

Parameters:

cube (Cube) – Cube to be updated in place

Return type:

None

process(cube, new_name=None, new_units=None, coords_to_remove=None, attributes_dict=None)[source]

Perform compulsory and user-configurable metadata adjustments. The compulsory adjustments are:

  • to collapse any scalar dimensions apart from realization (which is expected always to be a dimension);

  • to cast the cube data and coordinates into suitable datatypes;

  • to convert time-related metadata into the required units

  • to remove cell method (“point”: “time”).

Parameters:
  • cube (Cube) – Input cube to be standardised

  • new_name (Optional[str]) – Optional rename for output cube

  • new_units (Optional[str]) – Optional unit conversion for output cube

  • coords_to_remove (Optional[List[str]]) – Optional list of scalar coordinates to remove from output cube

  • attributes_dict (Optional[Dict[str, Any]]) – Optional dictionary of required attribute updates. Keys are attribute names, and values are the required changes. See improver.metadata.amend.amend_attributes for details.

Return type:

Cube

Returns:

The processed cube