Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rainforests calibration: separate models for each lead time and fixed thresholds #1940

Merged

Conversation

btrotta-bom
Copy link
Contributor

@btrotta-bom btrotta-bom commented Sep 12, 2023

This needs to be reviewed by BoM first. I will add the "MO review required" tag after that has happened.

This PR makes 2 changes to the rainforests calibration code:

  • Code now expects a set of models with different models for each lead time and threshold
  • Instead of predicting the probability that the forecast error (i.e. observation minus forecast) exceeds a threshold, the models are now expected to predict the probability that the rainfall exceeds a threshold.

Testing:

  • Ran tests and they passed OK
  • Added new tests for the new feature(s)
  • Updated acceptance tests.

benowen-bom
benowen-bom previously approved these changes Oct 5, 2023
Copy link
Contributor

@benowen-bom benowen-bom left a comment

Choose a reason for hiding this comment

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

Thanks @btrotta-bom. I'm now satisfied that all issues have been addressed and so I'm happy to approve. Overall I think these changes make significant improvements to both the method and the code presented herein.

I note that there is still an outstanding question around whether the interpolation functionality that is no longer used should be retained; MO input on this question would much appreciated.

Comment on lines 218 to 220
warnings.warn(
"Model config does not contain lead time keys; calibration will not work"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding this. I think you could go one step further and say that calibration process will fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you change this, you'll need to update the associated test.

improver/calibration/rainforest_calibration.py Outdated Show resolved Hide resolved
@benowen-bom benowen-bom added MO review required PRs opened by non-Met Office developers that require a Met Office review and removed BoM review required PRs opened by non-BoM developers that require a BoM review labels Oct 5, 2023
@gavinevans gavinevans self-assigned this Oct 6, 2023
Copy link
Contributor

@gavinevans gavinevans left a comment

Choose a reason for hiding this comment

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

Thanks @btrotta-bom 👍

I haven't fully wrapped my head around all these changes but these are my comments so far.

improver/calibration/rainforest_calibration.py Outdated Show resolved Hide resolved
improver/calibration/rainforest_calibration.py Outdated Show resolved Hide resolved
improver/calibration/rainforest_calibration.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gavinevans gavinevans left a comment

Choose a reason for hiding this comment

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

Thanks @btrotta-bom for the updates 👍

I've added some further minor comments.

@gavinevans gavinevans assigned btrotta-bom and unassigned gavinevans Oct 13, 2023
Copy link
Contributor

@gavinevans gavinevans left a comment

Choose a reason for hiding this comment

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

Thanks for the updates, @btrotta-bom 👍

@gavinevans gavinevans merged commit 602d665 into metoppv:master Oct 16, 2023
10 checks passed
btrotta-bom added a commit that referenced this pull request Oct 24, 2023
* clip predictions

* Update rainforests docs

* fix typo

* Incorporate review comments

* reverse change

* remove unrelated change

* remove unrelated change

* minor updates

* minor updates

* fix numbered list

* update

---------

Co-authored-by: Belinda Trotta <[email protected]>
MoseleyS pushed a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
… thresholds (metoppv#1940)

* Updates for log transform

* Changes for log transform

* Changes to blend probabilties

* add bounds

* different bounds methodology

* update monotone code

* minor fixes

* minor updates

* Remove temporary changes

* Tidy up code

* tidy up code

* Add tests for utilities and fix bugs.

* Add tests and fix code

* Reverse temporary change

* Update acceptance tests

* Formatting

* formatting

* Formatting

* Fix bug where arrays are not contiguous

* remove test code

* Changes for separate lead times

* update

* clip forecast between 0 and 1

* clip forecast between 0 and 1

* convert output thresholds to array

* Update tests

* formatting

* Use variable lower bound instead of 0

* Update checksums

* merge

* Remove unused code

* Minor fixes

* remove unused import

* Handle 3H forecast

* Ensure probability outputs are monotone

* match lead time to nearest available model

* Sort the model lead times

* Remove unused tests

* Fix tests

* Fix tests

* Formatting

* Fix docstrings

* Update docs

* Remove unused import

* Fix docstring

* Add test for specifying threshold units

* Fix bug and add tests

* Add test

* Formatting

* Remove testing code

* Remove testing code

* Remove precipitation error bound

* simplify code

* Simplify code

* Check same number of thresholds

* Simplify creating output cube

* Formatting

* Use float for lead times

* Update docstrings

* formatting

* typo

* rename variables

* update docstring

* Restore old documentation

* formatting

* Fix failing acceptance test

* Fix variable names

* typo

* formatting

* Add warning if no lead time keys present in config

* update checksums

* fix typo

* Refactor duplicated code

* Fix error message

* Minor updates

* Change lead time to float

* Fix error message

* Factor out parsing of model_config_dict

* Check error message

* Specify format of config dict everywhere

* Update comment

---------

Co-authored-by: Belinda Trotta <[email protected]>
MoseleyS pushed a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
* clip predictions

* Update rainforests docs

* fix typo

* Incorporate review comments

* reverse change

* remove unrelated change

* remove unrelated change

* minor updates

* minor updates

* fix numbered list

* update

---------

Co-authored-by: Belinda Trotta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MO review required PRs opened by non-Met Office developers that require a Met Office review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants