Add rainfall depth to rate converter#2122
Conversation
James Frost (jfrost-mo)
left a comment
There was a problem hiding this comment.
Useful functionality for enabling rainfall comparison. It needs tests adding, and ideally should be made non-Cardington specific, so other data can make use of it.
|
|
||
| # --- convert depth -> rate --- | ||
| # mm / s == kg m-2 s-1 | ||
| cube.data = cube.core_data() / duration_seconds |
There was a problem hiding this comment.
| cube.data = cube.core_data() / duration_seconds | |
| cube = cube / duration_seconds |
I believe this will perform the calculation while maintaining lazy data.
There was a problem hiding this comment.
Does your suggestion create a new cube? Is this risky? Perhaps it should be
cube.data = cube.data / duration_seconds
instead?
There was a problem hiding this comment.
We will want a test for this function in tests/operators/test_misc.py. Maybe one for it successfully running, then one for each of the errors raised.
There was a problem hiding this comment.
Tests added: seven in total. This number seems necessary given how the function has changed. I have generated a set of tiny .nc files of synthetic data rather than create data on the fly. Is this appropriate? Perhaps you need to "test the tests" ??
Check that time units are in seconds, convert if necessary. Make function work for all datasets containing a rainfall amount(accumulation).
use iter_maybe Co-authored-by: James Frost <james.frost@metoffice.gov.uk>
check cube has time coords; then check if time.bounds exists; if not, work out dt's and hence duration_seconds
Contribution checklist
Aim to have all relevant checks ticked off before merging. See the developer's guide for more detail.
rose-suite.conf.examplehas been updated if new diagnostic added.