-
Notifications
You must be signed in to change notification settings - Fork 54
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
Switch feature detection to use xarray internally #354
Switch feature detection to use xarray internally #354
Conversation
# Conflicts: # tobac/feature_detection.py
…_xarray_work_fd_julia_avgs # Conflicts: # tobac/feature_detection.py # tobac/utils/__init__.py # tobac/utils/general.py
…_xarray_work_fd_julia_avgs # Conflicts: # tobac/utils/__init__.py # tobac/utils/general.py
…y_work_fd_julia_avgs # Conflicts: # tobac/utils/general.py
…y_work_fd_julia_avgs # Conflicts: # tobac/feature_detection.py # tobac/utils/internal/xarray_utils.py
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## RC_v1.6.0 #354 +/- ##
=============================================
+ Coverage 60.91% 62.27% +1.36%
=============================================
Files 23 23
Lines 3541 3690 +149
=============================================
+ Hits 2157 2298 +141
- Misses 1384 1392 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…y_work_fd_julia_avgs
I can do the second review within the next couple of days! I also started a |
…y_work_fd_julia_avgs # Conflicts: # tobac/analysis.py # tobac/feature_detection.py
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 a lot for this pR @freemansw1! This is seems like a great step towards the xarray transition.
It all looks good to me besides two small comments. And I have tested this on two real data sets which works fine and without any major issues. However, the only thing that does not seem to work is is passing the argument preserve_iris_datetime_type
to feature_detection_multithreshold()
. The dtypes for time are different in the output feature dataframe no matter if I set preserve_iris_datetime_type
to False or True. They are always objects/dtype('O')
when I input an iris cube and datetime64/dtype('<M8[ns]')
when I input an xarray.
Ok, @JuliaKukulies, I think I've addressed your concerns. Ready for your re-review. Hopefully we can get this merged! |
Excellent, @freemansw1! This looks good except for that there is still the issue with Sorry I had not marked the bug at the actual code locations, so I get that you might have overseen this. I also cannot really figure out where this bug comes from, since everywhere in the code where |
Apologies, yeah, I had missed this. I will work to reproduce and try this out this weekend/early next week. |
I think I've noticed this before, and the issue is to do with calculating the timesteps from |
Note to self: |
OK, I think I have resolved the datetime issues. It's somewhat of a hacky solution, but basically, |
I have now also resolved this issue. The solution here results in some decisions that were contrary to the discussion we had at the last dev meeting (notably that len(1) coordinates are still appended to the dataframe), but I think we are otherwise okay. We can talk about this at the dev meeting tomorrow. |
@w-k-jones and @JuliaKukulies I am now ready for a re-review. |
OK, I have tested this again with my data and I thought I understood what you explained in the dev meeting today, but now i am a little confused again :) I basically get:
Is that what we want? |
Ok, the first of those three are all correct, but the last one isn't. |
Thats what I thought, and we would expect |
Ok this one was easy- we didn't actually expect the kwarg in |
…y_work_fd_julia_avgs
Perfect, thanks for looking into this and fixing this. I am happy to approve this now once the latest changes from RC_v1.5.x are merged in |
OK, changes all merged in and everything. @JuliaKukulies and @w-k-jones are you happy for me to merge into |
Yes, please go ahead:) ! |
Also happy for this to be merged :) |
This is a draft PR that contains my work switching feature detection to use xarray internally, using many of the concepts (and some of the code) from #275. This code uses entirely xarray and pandas for processing feature detection, and removes all iris calls; instead using our internal conversion utilities to convert input iris data to xarray (which should always work, unlike
xarray
->iris
. Further, this change should allow users to provide their data as anxarray.DataArray
.This PR will remain in draft form until at least #293 is merged and intentionally includes those changes.
More tests (particularly around times on different OS versions) should be added, but I wanted to get this into a form that we could discuss.