You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to use the xarray.cftime_range function to get a set of datetimes between two cftime.datetime objects that use the proleptic_gregorian calendar. However, when I use this function with this calendar, I receive the following error:
File "/Users/Alexander/miniconda3/envs/xrtest/lib/python3.11/site-packages/xarray/core/resample_cftime.py", line 491, in exact_cftime_datetime_difference
seconds = b.replace(microsecond=0) - a.replace(microsecond=0)
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
File "src/cftime/_cftime.pyx", line 1574, in cftime._cftime.datetime.__sub__
TypeError: cannot compute the time difference between dates with different calendars
What did you expect to happen?
I expect this function to return a list of dates between the two dates I selected, with each date spaced by one day. In the minimal example, I provide the expected output obtained when I instead use the cftime.DatetimeProlepticGregorian object.
Thanks for opening your first issue here at xarray! Be sure to follow the issue template!
If you have an idea for a solution, we would really welcome a Pull Request with proposed changes.
See the Contributing Guide for more.
It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better.
Thank you!
Indeed for the time being xarray only supports the calendar-specific cftime.datetime subclasses like cftime.DatetimeProlepticGregorian. I started a PR to enable support for calendar-aware cftime.datetime instances in #8942. In principle it should not be too hard, though it will take some time to make sure everything is tested thoroughly enough.
What happened?
I want to use the xarray.cftime_range function to get a set of datetimes between two
cftime.datetime
objects that use theproleptic_gregorian
calendar. However, when I use this function with this calendar, I receive the following error:What did you expect to happen?
I expect this function to return a list of dates between the two dates I selected, with each date spaced by one day. In the minimal example, I provide the expected output obtained when I instead use the
cftime.DatetimeProlepticGregorian
object.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment
The text was updated successfully, but these errors were encountered: