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

MOBT-430: Synthetic data utilities for creating spot-cubes #1993

Merged
merged 7 commits into from
May 14, 2024

Conversation

bayliffe
Copy link
Contributor

@bayliffe bayliffe commented May 7, 2024

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

  • Adds the following helper functions for use in creating unit tests that use spot-cubes:
    • set_up_spot_variable_cube
    • set_up_spot_percentile_cube
    • set_up_spot_probability_cube
  • Adds associated unit tests
  • Modifies calls to the existing gridded functions where these did not use the keyword arguments explicitly.
  • Modifies some unit tests as an example of how this can be used.
  • Centralises the date-time format "%Y%m%dT%H%MZ" as we use this in several places and have never done so.

The commits are broken up as follows:

  1. new functions, tests, fix-up existing calls, and (sorry) a partially modified choose weights test.
  2. centralise the date-time format
  3. modify some unit tests as examples of usage.

Testing:

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

bayliffe added 3 commits May 7, 2024 15:00
Adds the ability to generate spot-data cubes for use in unit tests.
Fixes up calls to the existing gridded synthetic data functions that did not use the keyword arguments explicitly.
Adds unit tests for the new spot-data utilities.
One unit test partially modified as an example.
@@ -443,7 +446,7 @@ def test_error_unmatched_realizations(self):
"""Test error is raised if the realizations provided do not match the
data dimensions"""
realizations_len = 4
data_len = len(self.data_3d[0])
data_len = self.data_3d.shape[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug in original test.

@@ -456,7 +459,7 @@ def test_error_unmatched_height_levels(self):
"""Test error is raised if the heights provided do not match the
data dimensions"""
height_levels_len = 4
data_len = len(self.data_3d[0])
data_len = self.data_3d.shape[0]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug in original test.

Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.40%. Comparing base (84a8944) to head (93d5760).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1993      +/-   ##
==========================================
+ Coverage   98.39%   98.40%   +0.01%     
==========================================
  Files         124      124              
  Lines       12212    12322     +110     
==========================================
+ Hits        12016    12126     +110     
  Misses        196      196              

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

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 @bayliffe 👍

I think that this PR is largely fine. I've only added some very minor comments.

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 @bayliffe 👍

This looks fine. I've suggested one minor docstring edit.

improver/synthetic_data/set_up_test_cubes.py Outdated Show resolved Hide resolved
gavinevans
gavinevans previously approved these changes May 13, 2024
Copy link
Contributor

@brhooper brhooper left a comment

Choose a reason for hiding this comment

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

Thanks @bayliffe, the functionality added here should be really useful.

I've added 2 extremely minor comments.

improver/synthetic_data/set_up_test_cubes.py Outdated Show resolved Hide resolved
improver_tests/synthetic_data/test_set_up_test_cubes.py Outdated Show resolved Hide resolved
Copy link
Contributor

@brhooper brhooper left a comment

Choose a reason for hiding this comment

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

Thanks @bayliffe, I'm happy to approve this now.

@brhooper brhooper merged commit ccdc68f into metoppv:master May 14, 2024
10 checks passed
MoseleyS pushed a commit to MoseleyS/improver that referenced this pull request Aug 22, 2024
)

* Synthetic spot data creation utilities added.

Adds the ability to generate spot-data cubes for use in unit tests.
Fixes up calls to the existing gridded synthetic data functions that did not use the keyword arguments explicitly.
Adds unit tests for the new spot-data utilities.
One unit test partially modified as an example.

* Centralise the datetime format definition that corresponds to our typical format.

* Some unit tests that use spot-cubes adapted as a demonstration.

* Fix doc-string indentation issue for sphinx.

* Review response. Improved doc-strings and use of global variables.

* Typo correction.

* Corrects typos highlighted 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