metoppv / improver

IMPROVER is a library of algorithms for meteorological post-processing.
http://improver.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
103 stars 85 forks source link

Refactor weather code plugins and CLIs #1944

Closed MoseleyS closed 10 months ago

MoseleyS commented 1 year ago

Time spent on this ticket should be charged to a specific code. Ask @MoseleyS.

As Enhancing Post Processing Science Lead, I want the IMPROVER weather code plugin to be refactored so that I can run a precipitation type code configuration.

The essential changes are around metadata. The output cube name and categorical attributes are now derived from the decision tree, which has been updated as a result and is now also a required input to the modal categories plugin.

To achieve this, I have done some refactoring:

Acceptance test data updates in https://github.com/metoppv/improver_test_data/pull/28

For reviewing, I recommend looking in two parts:

  1. Most of the refactoring is in the first four commits: aaf3ae6c...5734e30
  2. Then everything else: 5734e30...99f68020

This PR MUST be merged with the accompanying suite PR: (https://github.com/MetOffice/improver_suite/pull/1823)

Testing:

codecov[bot] commented 1 year ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (aaf3ae6) 98.38% compared to head (01af03c) 98.40%. Report is 17 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1944 +/- ## ========================================== + Coverage 98.38% 98.40% +0.01% ========================================== Files 123 124 +1 Lines 11795 12028 +233 ========================================== + Hits 11605 11836 +231 - Misses 190 192 +2 ``` | [Files](https://app.codecov.io/gh/metoppv/improver/pull/1944?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv) | Coverage Δ | | |---|---|---| | [improver/categorical/decision\_tree.py](https://app.codecov.io/gh/metoppv/improver/pull/1944?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv#diff-aW1wcm92ZXIvY2F0ZWdvcmljYWwvZGVjaXNpb25fdHJlZS5weQ==) | `99.30% <100.00%> (ø)` | | | [improver/categorical/modal\_code.py](https://app.codecov.io/gh/metoppv/improver/pull/1944?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv#diff-aW1wcm92ZXIvY2F0ZWdvcmljYWwvbW9kYWxfY29kZS5weQ==) | `100.00% <100.00%> (ø)` | | | [improver/categorical/utilities.py](https://app.codecov.io/gh/metoppv/improver/pull/1944?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv#diff-aW1wcm92ZXIvY2F0ZWdvcmljYWwvdXRpbGl0aWVzLnB5) | `100.00% <100.00%> (ø)` | | | [improver/developer\_tools/metadata\_interpreter.py](https://app.codecov.io/gh/metoppv/improver/pull/1944?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv#diff-aW1wcm92ZXIvZGV2ZWxvcGVyX3Rvb2xzL21ldGFkYXRhX2ludGVycHJldGVyLnB5) | `99.05% <100.00%> (ø)` | | ... and [16 files with indirect coverage changes](https://app.codecov.io/gh/metoppv/improver/pull/1944/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=metoppv)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

MoseleyS commented 1 year ago

improver.categorical.utilities.categorical_attributes improver.developer_tools.metadata_interpreter.MOMetadataInterpreter (in function run)

The categorical utilities just has a few variables called wx_keys which probably wants updating but I'm not sure about the developer_tools one?

I've updated the variable names in both files. This allows us to add other categorical data to the metadata interpreter in the future, if required.