-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
date_range needs more flexibility : generate date at middle of months/hours like cftime_range can #10206
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
Comments
With
In case it is helpful to you or anyone else who comes across this issue, if you would like values exactly at monthly midpoints, it is not too difficult to achieve with timedelta arithmetic:
|
I am going to go ahead and close this issue, but please feel free to re-open if you feel more discussion is needed. |
What is your issue?
Hi,
When runnning :
xr.date_range(start="1900-01-15 00:00:00", periods=12, freq="1MS", normalize=True , name='time', inclusive='both', calendar='gregorian', unit='s', use_cftime=True)
I get the time values :
It starts at the end of January/start of February. Not at the middle of January.
I would like to use
date_range
to generate a time axis with values every month, but at (approximate) middle of months.Most CMIP models provides a time axis with value at the middle of a period, and provides
time_bounds
at the start/end of the periods.For tests cases, I need to generate such time values.
I can generates them by this rather ugly :
time = [ xr.date_range(start=f"{1900+ii//12:04}-{ii%12+1:02}-15 00:00", periods=1, **kwargs).values[0] for ii in np.arange(12) ]
or by a using the deprecated function
cftime_range
Could it be possible to get back the flexibility of
cftime_range
?Note that the problem is the same when generating an axis with hourly values at the middle of each hour.
Thanks,
Olivier
The text was updated successfully, but these errors were encountered: