Skip to content

Fix dropping incomplete seasons for sub-monthly (e.g., daily) data - #856

Merged
tomvothecoder merged 2 commits into
xCDAT:mainfrom
klemmeri:fix-daily-incomplete-seasons
Nov 17, 2026
Merged

tomvothecoder merged 2 commits into
xCDAT:mainfrom
klemmeri:fix-daily-incomplete-seasons

Conversation

@klemmeri

@klemmeri klemmeri commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

_drop_incomplete_seasons counted 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 and group_average/climatology raise RuntimeError: No time coordinates remain. It now counts distinct months (transform("nunique") on the month column).

The deprecated _drop_incomplete_djf removed 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 for climatology with drop_incomplete_seasons=True. Monthly behaviour is unchanged.

Prepared with AI assistance (Claude); I reviewed the changes.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

If applicable:

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass with my changes (locally and CI/CD build)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have noted that this is a breaking change for a major release (fix or feature that would cause existing functionality to not work as expected)

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@tomvothecoder

Copy link
Copy Markdown
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

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (3ced029) to head (6f93c7b).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

3 participants