improver.developer_tools.metadata_interpreter module

Module containing classes for metadata interpretation

CATEGORICAL_MODE_CM(hour)
class MOMetadataInterpreter[source]

Bases: object

Class to interpret an iris cube according to the Met Office specific IMPROVER standard. This is intended as a debugging tool to aid developers in adding and modifying metadata within the code base.

ANCIL = 'ancillary'
DIAG = 'realizations'
PERC = 'percentiles'
PROB = 'probabilities'
__init__()[source]

Initialise class parameters, which store information about a cube to be parsed into a human-readable string by the display_interpretation() function.

_check_blend_and_model_attributes(attrs)[source]

Interprets attributes for model and blending information and checks for self-consistency

Return type:

None

_check_coord_bounds(cube, coord)[source]

If coordinate has bounds, check points are equal to upper bound

Return type:

None

_check_coords_are_horizontal(cube, coords)[source]

Checks that all the mentioned coords share the same dimensions as the x and y coords

Return type:

None

_check_coords_present(coords, expected_coords)[source]

Check whether all expected coordinates are present

Return type:

None

check_attributes(attrs)[source]

Checks for unexpected attributes, then interprets values for model information and checks for self-consistency

Return type:

None

check_cell_methods(cube)[source]

Checks cell methods are permitted and correct

Return type:

None

check_probability_cube_metadata(cube)[source]

Checks probability-specific metadata

Return type:

None

check_spot_data(cube, coords)[source]

Check spot coordinates

Return type:

None

check_threshold_coordinate_properties(cube_name, threshold_coord)[source]

Checks threshold coordinate properties are correct and consistent with cube name

Return type:

None

run(cube)[source]

Populates self-consistent interpreted parameters, or raises collated errors describing (as far as posible) how the metadata are a) not self-consistent, and / or b) not consistent with the Met Office IMPROVER standard.

Although every effort has been made to return as much information as possible, collated errors may not be complete if the issue is fundamental. The developer is advised to rerun this tool after each fix, until no further problems are raised.

Return type:

None

_format_standard_cases(interpreter, verbose, vstring)[source]

Format prob / perc / diagnostic information from a MOMetadataInterpreter instance

Return type:

List[str]

display_interpretation(interpreter, verbose=False)[source]

Prints metadata interpretation in human-readable form. This should not be run on a MOMetadataInterpreter instance that has raised errors.

Parameters:
  • interpreter (MOMetadataInterpreter) – Populated instance of MOMetadataInterpreter

  • verbose (bool) – Optional flag to include information about the source of the metadata interpretation (eg name, coordinates, attributes, etc)

Return type:

str

Returns:

Formatted string describing metadata in human-readable form