-
Notifications
You must be signed in to change notification settings - Fork 61
Fix remaining issues with datetime conversions and coordinate naming for iris/xarray compatibility #489
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
Fix remaining issues with datetime conversions and coordinate naming for iris/xarray compatibility #489
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## RC_v1.6.0 #489 +/- ##
=============================================
+ Coverage 59.14% 63.52% +4.38%
=============================================
Files 25 27 +2
Lines 3892 3836 -56
=============================================
+ Hits 2302 2437 +135
+ Misses 1590 1399 -191
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Linting results by Pylint:Your code has been rated at 8.21/10 (previous run: 8.21/10, +0.00) |
@freemansw1 @JuliaKukulies @kelcyno This fixes the bug with datetime conversions in feature detection that I mentioned earlier, edit: Fixing the datetime issues found in #490 ended up being a bigger job. I've created two new utils submodules:
In addition, datetime conversions are fully handled in the iris to xarray conversion decorator now, rather than being sorted by the coordinate interpolation function, which helps ensure that time coordinates remain in the same format as the input |
…ough a paired dataarray and features dataframe
…that datetime conversion is handled when converting to/from iris
…and set the default to be True for iris and False for xarray
Right, I think all the issues that have cropped up have been resolved and that this is now ready for review. Hopefully this should make the v1.6 release more stable and make future development easier |
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.
Fantastic work, @w-k-jones. Honestly, that datetime utility would be extremely useful for the broader community, not even just tobac internally.
… and hdim_2 had to be provided even if only calculating PBCs over one dimension
Happy with the new changes! |
@w-k-jones : Great development! From the first impression I noticed that some docstrings are missing:
Could you update everything accordingly? Thanks! |
Thanks for flagging this @fsenf , I'll work on fixing those asap |
@w-k-jones : Do you need support for finishing the docstrings? |
@fsenf I should have addressed your points now |
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.
Great achievement! I am happy with the PR!
@w-k-jones : Please go ahead and merge.
This PR has expanded to cover a number of remaining issues with iris/xarray compatibility in
RC_v1.6.0
:Datetime conversion:
Feature times are always converted to
cftime
if not usingmin_distance
parameter with 2d data, andadd_coordinates
is called multiple times. This was likely caused by a merge conflict, whenadd_coordinates
was moved to before distance filtering thepreserve_iris_datetime_types
parameter was missing.https://github.com/tobac-project/tobac/blame/f05da214511da70e0ee54dcdec892d08f7f8f6be/tobac/feature_detection.py#L1423
This PR fixes this bug, removes the duplicate
add_coordinates
call and adds test for various datetime outputs.I also fixed
test_feature_detection_coords
, as it turned out that this wasn't actually testing anything as the input dataset had no coords...Coordinate naming:
Implements the previously unused
use_standard_name
parameter for coordinate interpolation in feature detection. Now the default behaviour is to use standard names for iris cube input and variable names for xarray dataarrays, but either can be chosen by the user by settinguse_standard_name
to True or False.This resulted in a couple of issues, as a number of utils/analysis functions in tobac currently expect dataframe columns to always have standard names (e.g.
projection_x_coordinate
). To avoid this, I added new functionality to find horizontal coordinate names from dataframes in the same manner as the existingfind_dataframe_vertical_coord
Internal utils
At some point during
RC_v1.6.0
,tobac.utils.general_utils
was added to the branch along withtobac.utils.basic
. These contained both duplicate functions to each other, as well as duplicate, outdated versions of functions now in other modules. I have resolved this issue, and also splitbasic
into two modulescoordinates
andlabel_props
to clarify what these module are used for