Repository navigation
Fix dropping incomplete seasons for sub-monthly (e.g., daily) data - #856
Merged
Merged
Conversation
Count distinct months (not time steps) per season in _drop_incomplete_seasons, and drop all time steps of incomplete months in _drop_incomplete_djf. Fixes xCDAT#855.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the incomplete-season filtering changes.
No open issues 🎉
What changed in this PR
This PR addresses #855 by correcting incomplete-season filtering for daily and other sub-monthly data in xCDAT’s temporal averaging APIs.
Changes:
- Determine season completeness by counting distinct months rather than time steps.
- Update the deprecated DJF filter to remove every time step in incomplete endpoint months.
- Add daily-data regression tests for seasonal group averages and climatology.
| File | Description |
|---|---|
xcdat/temporal.py |
Corrects distinct-month counting and removal of incomplete DJF months. |
tests/test_temporal.py |
Adds daily-data coverage for both filtering options and seasonal climatology. |
Review effort: Balanced
Collaborator
|
Thank you for opening a PR @klemmeri. I will merge after the build passes and will release a new version of xCDAT soon. I'll let you know once I do. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #856 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 18 18
Lines 2010 2010
=========================================
Hits 2010 2010 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
drop_incomplete_seasons=Trueraises on daily data (counts time steps, not months); deprecateddrop_incomplete_djf=Truesilently keeps partial DJF for daily data #855_drop_incomplete_seasonscounted time steps per (year, season) and compared that with the number of months in the season. That works for monthly data, but with daily data every season looks incomplete andgroup_average/climatologyraiseRuntimeError: No time coordinates remain. It now counts distinct months (transform("nunique")on themonthcolumn).The deprecated
_drop_incomplete_djfremoved only the first time step of each incomplete month, so with daily data the partial DJF seasons at the ends were silently kept. It now drops every time step in those months.Tests: added daily-data tests for
group_average(both options; 4 complete years give exactly 15 seasons, with the leading Jan–Feb and trailing Dec removed) and forclimatologywithdrop_incomplete_seasons=True. Monthly behaviour is unchanged.Prepared with AI assistance (Claude); I reviewed the changes.
Checklist
If applicable: