-
Notifications
You must be signed in to change notification settings - Fork 90
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 2066 convert forecast to climatological anomaly #2072
Mobt 2066 convert forecast to climatological anomaly #2072
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2072 +/- ##
==========================================
+ Coverage 98.39% 98.42% +0.02%
==========================================
Files 124 135 +11
Lines 12212 13380 +1168
==========================================
+ Hits 12016 13169 +1153
- Misses 196 211 +15 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @maxwhitemet, it's a good start to fulfilling the requirements t have a plugin which calculates anomaly data for use in the SAMOS work.
I've added some comments to the plugin and what I think are some spurious changes to the checksums. Once these have been resolved, I'll review the unit tests more thoroughly. I've not done this in detail yet as I think that some of the changes I've suggested to the plugin will necessitate changes to the tests anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet - I think we're heading in the correct direction on this. I've added some comments to the plugin changes you've made. Once we get the plugin finalised we can talk in more depth about the tests, though I will say that codecov bot thinks that some lines of code are not being touched by the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet, I think we're getting there with this PR. I've left a few comments on the plugin itself. We've also had a chat about how the unit tests can be re-written to make it easier for people reading the code to understand what is being tested, as well as sketching out what tests are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet, your latest changes have really improved the unit tests. I've made some additional requests for changes, but overall I think that the PR is close to be ready for another review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet. I've suggested a few small changes.
Thank you for your review @brhooper. I have implemented the suggested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet, I think I'm happy with this now. I've added 3 very minor comments. I think we might also need to talk about running the formatting tests (black, isort, flake8 etc) detailed here using, for example bin/improver-tests black
.
I also think that your checking of the reference_epoch
coordinate could be replaced with a simple function to reduce repeated code. Something like:
def check_reference_epoch_coord(result_cube, reference_cube):
"""Check that the reference_epoch coordinate on the result cube is as expected."""
if "reference_epoch" not in [coord.name() for coord in result_cube.coords()]:
return False
else:
results = []
results.append(
result_cube.coord("reference_epoch").points
== reference_cube.coord("time").points
)
results.append(
np.array_equal(
result_cube.coord("reference_epoch").bounds,
reference_cube.coord("time").bounds,
)
)
results.append(
result_cube.coord("reference_epoch").units
== reference_cube.coord("time").units
)
return all(results)
and then using the following within each test:
assert check_reference_epoch_coord(result_cube, mean_cube)
though I'm happy to leave this decision to you/the 2nd reviewer.
Overall, I'm happy to move this ticket into 2nd review now, with you making the 3 minor changes indicated in my comments. Thanks for all your work on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet 👍
I've added some comments mainly related to getting rid of the long times from docstrings and code comments, and the addition of type hints.
…ical anomaly, and appropriate tests. **Main Script** The structure of the new CalculateClimateAnomalies class follows that agreed with @brhooper. - Initialisation - Verification of inputs - Matching standard names - Matching units - Matching grids - Matching time coordinates - Calculation of anomalies: both unstandardised and standardised - Creation of output cube with appropriate metadata
Resolved prior requests from Ben Hooper following review. Only now require implementation of further metadata adjustments.
… conventions for anomalies. Metadata added for outputed cube: - Standard names suffixed with "anomaly" if mean cube provided or "standard anomaly" if variance cube also provided - Units set to None if variance cube used and copied from the provided diagnostic cube if no variance cube provided - "Reference epoch" scalar coordinate with (1) timebound from mean cube for anomaly cube, and (2) validity time from diagnostic cube - Cell method of "reference epoch: anomaly"
…ng '==' and not 'is'
…riable assigned but never used
…t.mark.xfail' with 'pytest.raises(AssertionError)' to ensure the test fails for the correct reason.
…e and variance cube do not match.
…the user incorrectly sets 'standardised_anomaly' to false when instantiating and yet provides a variance cube
…eviously hidden behind faulty fixture setup
…h was different for one check
…epoch metadata with Ben's function from last review
…_metadata function as this was mistakenly added
cb489a6
to
fc31ff5
Compare
Thank you for your review @gavinevans. I have made the requested changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet 👍
I've added a few more minor comments.
Thanks for the further comments @gavinevans 👍 |
…y' to reflect requested cf-convention changes in previous review + fixed incorrect type annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maxwhitemet, this all looks fine to me. Good work.
Addresses #2066
Testing:
The structure of the new CalculateClimateAnomalies class follows that agreed with @brhooper