Skip to content

Fix convert calendar on non-temporal data in datasets - #10268

Merged
dcherian merged 1 commit into
pydata:mainfrom
Ouranosinc:fix-conv-cal-on-ds
Apr 29, 2025
Merged

Fix convert calendar on non-temporal data in datasets#10268
dcherian merged 1 commit into
pydata:mainfrom
Ouranosinc:fix-conv-cal-on-ds

Conversation

@aulemahal

Copy link
Copy Markdown
Contributor

When calling convert_calendar on dataset with non-temporal variable (no time dimension), the time dimension was added. This is because the function was using where(time.notnull(), drop=True) to drop the time elements of the source that did not map to a valid time in the target calendar.

Given that time is always 1D and always loaded (no dask), using sel(time=time.notnull()) fixes the bug, and, in fact, makes more sense to me. (I don't remember why I didn't use that in my first version of the method...)

I added a minimal test that detects the bug raised in the issue.

@spencerkclarkspencerkclark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @aulemahal—this makes more sense to me too!

@spencerkclarkspencerkclark added the plan to merge Final call for comments label Apr 29, 2025
@dcherian
dcherian merged commit d7a6f2b into pydata:mainApr 29, 2025
dcherian added a commit to dcherian/xarray that referenced this pull request Apr 29, 2025
* main:
Fix convert calendar on non-temporal data in datasets (pydata#10268)
BinGrouper: reduce indirection (pydata#10270)
Fix reduction by subset of grouper dimensions (pydata#10258)
Shorten text repr for ``DataTree`` (pydata#10139)
Fix benchmarks runners (pydata#10265)
Fix infinite recursion when calling `np.fix` (pydata#10248)
BinGrouper: Support setting labels when provided with IntervalIndex (pydata#10259)
Avoid stacking when grouping by chunked array (pydata#10254)
Improve alignment checks (pydata#10251)
Update how-to-add-new-backend.rst (pydata#10240)
Support extension array indexes (pydata#9671)
Switch documentation to pydata-sphinx-theme (pydata#8708)
Bump codecov/codecov-action from 5.4.0 to 5.4.2 in the actions group (pydata#10239)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan to mergeFinal call for commentstopic-documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convert_calendar adds a time dimension to all variables

3 participants

@aulemahal@dcherian@spencerkclark