improver.cli.categorical module

CLI to generate categorical data.

process(*cubes, decision_tree=None, model_id_attr=None, record_run_attr=None, target_period=None, check_tree=False, title=None)[source]

Generates categorical data. Uses a decision tree to determine which category represents each location in the input cubes. Used to generate categorical data like weather symbols.

Parameters:
  • cubes (iris.cube.CubeList) – A cubelist containing the diagnostics required for the decision tree, these at co-incident times.

  • decision_tree (dict) – A JSON file containing a decision tree definition. Full information on decision trees can be found in improver.categorical.decision_tree.

  • model_id_attr (str) – Name of attribute recording source models that should be inherited by the output cube. The source models are expected as a space-separated string.

  • record_run_attr (Optional[str]) – Name of attribute used to record models and cycles used in constructing the categorical data.

  • target_period (Optional[int]) – The period in seconds that the categorical data being produced should represent. This should correspond with any period diagnostics, e.g. precipitation accumulation, being used as input. This is used to scale any threshold values that are defined with an associated period in the decision tree. It will only be used if the decision tree provided has threshold values defined with an associated period.

  • check_tree (bool) – If set, the decision tree will be checked to see if it conforms to the expected format and that all nodes can be reached; the only other argument required is the path to the decision tree. If the tree is found to be valid the required inputs will be listed. Setting this flag will prevent the CLI performing any other actions.

  • title (str) – An optional title to assign to the title attribute of the resulting output. This will override the title generated from the inputs, where this generated title is only set if all of the inputs share a common title.

Returns:

A cube of categorical data.

Return type:

iris.cube.Cube