-
Notifications
You must be signed in to change notification settings - Fork 0
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
Extract cubewrite
fill value modifications
#114
base: main
Are you sure you want to change the base?
Conversation
There's a slight amount of messiness with the added To prevent e.g. a float um2nc-standalone/umpost/um2netcdf.py Lines 334 to 340 in f3fbd44
This will also complain e.g. if a um2nc-standalone/umpost/um2netcdf.py Lines 342 to 350 in f3fbd44
I don't think it's too important, but mainly wanted to check whether we're happy for the type requirements for the |
Ah oops, didn't notice the additional places the |
to separate the fill value modifications into two steps
else: | ||
fill_value = get_default_fill_value(cube) | ||
|
||
if type(fill_value) == cube.data.dtype: |
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.
My linter (flake8) complains here, suggesting do not compare types, for exact checks use "is" / "is not", for instance checks use "isinstance()"
I've had a play around, however neither is
or isinstance
work as desired when using cube.data.dtype
in the comparison. Would be keen to gather any suggestions!
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.
... neither
is
orisinstance
work as desired when usingcube.data.dtype
in the comparison. Would be keen to gather any suggestions!
is
will fail if the instances are not the same object.
The second aspect is numpy
using internal types in place of Python's built in primitives:
>>> type(cube.data.dtype)
numpy.dtypes.Float64DType
>>> type(1.0)
<class 'float'>
That affects comparison operations (more on that in another comment).
Ok, I've fixed my problem where I omitted the return value, and tried to clean up the structure. Rather than combining both of the following in a single function:
I separated the first part into a There are a couple of things to note: The behaviour on the surface is not exactly the same as prior to this PR. In this PR, we apply the type conversion to um2nc-standalone/umpost/um2netcdf.py Line 354 in e0048d4
Previously, the um2nc-standalone/umpost/um2netcdf.py Lines 344 to 351 in e3b98f3
Converting an ESM1.5 monthly output file results in identical |
This pr closes #99.
It extract's the
cubewrite
fill value modifications into a seperate function, adds acustom_fill_val
optional argument, and adds unit tests.Any suggestions or ideas are welcome!