Skip to content

Improve QRF change capping - #2458

Merged
brhooper merged 5 commits into
metoppv:masterfrom
brhooper:mobt1292_qrf_clipping_fix
Oct 2, 2026
Merged

brhooper merged 5 commits into
metoppv:masterfrom
brhooper:mobt1292_qrf_clipping_fix

Conversation

@brhooper

@brhooper brhooper commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Addresses https://github.com/metoppv/mo-blue-team/issues/1292

Modifies how QRF calibrated forecasts are clipped to be within some range of the uncalibrated forecast. Previously, the clipping used bounds which were a function of the maximum and minimum of the uncalibrated forecast at each site, however this meant that calibrated forecasts which were entirely outside of this range would be clipped so that all of their percentiles were equal. The new approach applies per-quantile bounds when clipping the calibrated forecast.

This PR removes the old implementation and unit tests in favour of a new approach utilising the EnforceConsistentForecasts plugin. New unit tests are added for this approach.

Testing:

  • Ran tests and they passed OK

@mo-kbogue
mo-kbogue self-requested a review September 30, 2026 13:18

@mo-kbogue mo-kbogue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, great that we can reuse existing functionality rather than needing to add more lines of code, good thinking. Minor suggestions on implementation that are not a necessity. Found the tests a bit difficult to follow, due to not having the uncalibrated and calibrated result in the same place as the quantiles, max_allowed_difference and expected. I understand in general however that this is following the existing convention for these tests and shouldn't be changed. Ran the tests and they all passed.

@mo-kbogue mo-kbogue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a typo to fix (I think), happy with everything else, thanks for those changes.

If not provided, no maximum difference check will be applied. Defaults to None.
The maximum allowed difference between the uncalibrated and calibrated
forecast. If not provided, no maximum difference check will be applied.
If provided, must be a non-negative integer. Defaults to None.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you mean must be a non-negative float? That's what is written below

Suggested change
If provided, must be a non-negative integer. Defaults to None.
If provided, must be a non-negative float. Defaults to None.

assert result.coord("forecast_period").points[0] == 12 * 3600


@pytest.mark.parametrize(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this could do with a comment explaining what the forecast values are, and what the reference forecast values are - so it's easier to reason about the expected output

@jdjonathandavies jdjonathandavies left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great - especially liked the removal of the now unneeded code from the QRF plugin.

Happy to approve, although I had a minor comment that would help the readability of the tests.

…ve defunct unit tests of ApplyQuantileRegressionRandomForests. Fix mistake when deleting sections of ApplyQuantileRegressionRandomForests. Fix typo.
… plugin. Add unit tests for this validation. Fix typo in unit test description.
@brhooper
brhooper force-pushed the mobt1292_qrf_clipping_fix branch from 4f0e7a0 to 8c2175b Compare October 2, 2026 08:24
@brhooper
brhooper merged commit 25cb9a8 into metoppv:master Oct 2, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants