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

apply_bias_correction fix: add handling for missing forecast cube #1995

Conversation

benowen-bom
Copy link
Contributor

@benowen-bom benowen-bom commented May 13, 2024

Addresses #1994

This PR the function split_forecasts_and_bias_files to separate out the forecast cube from the forecast_error (bias) cubes based on cube.name(). Raises a Value Error when the forecast cube is not present, or when multiple forecast cubes have been passed in.

The CLI now adds a warning when no bias_cubes are present and adds a comment to the attributes in the forecast (in line with how apply_emos_coefficients handles similar use case.

Acceptance tests have been added to test this behaviour explicitly to ensure #1994 has been resolved. There is a new kgo that has been added for the case where no bias-cubes are added, included in the following PR: metoppv/improver_test_data#47.

Testing:

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

Copy link

codecov bot commented May 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (84a8944) to head (766ae96).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1995      +/-   ##
==========================================
+ Coverage   98.39%   98.41%   +0.01%     
==========================================
  Files         124      124              
  Lines       12212    12337     +125     
==========================================
+ Hits        12016    12141     +125     
  Misses        196      196              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benowen-bom benowen-bom changed the title WIP: apply_bias_correction fix: add handling for missing forecast cube apply_bias_correction fix: add handling for missing forecast cube May 14, 2024
btrotta-bom
btrotta-bom previously approved these changes May 14, 2024
Copy link
Contributor

@btrotta-bom btrotta-bom left a comment

Choose a reason for hiding this comment

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

This looks fine, a couple of small suggestions for your consideration

improver/calibration/__init__.py Show resolved Hide resolved
improver/cli/apply_bias_correction.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 @benowen-bom 👍

I think that this essentially looks fine. I've suggested some minor typo corrections.

improver/cli/apply_bias_correction.py Outdated Show resolved Hide resolved
improver_tests/calibration/test_init.py Outdated Show resolved Hide resolved
improver_tests/calibration/test_init.py Outdated Show resolved Hide resolved
improver_tests/calibration/test_init.py Outdated Show resolved Hide resolved
@benowen-bom
Copy link
Contributor Author

Thanks @benowen-bom 👍

I think that this essentially looks fine. I've suggested some minor typo corrections.

Thanks Gavin for the review and picking up those typos. All fixed.

@gavinevans gavinevans merged commit 94245e4 into metoppv:master May 16, 2024
10 checks passed
MoseleyS pushed a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
…etoppv#1995)

* Update the cli signature for bias-correction cli and add tests for missing files.

* Add function to separate forecast and forecast-error (bias) cubes

* Tidy up split_forecasts_and_bias_files function and update acceptance tests.

* Add unit tests for split_forecasts_and_bias_files function.

* Update the apply_bias_correction CLI to raise warning when no calibration is applied.

* Add unit test to check comment on output when no bias cubes supplied.

* Fix typos picked up in review.
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