-
Notifications
You must be signed in to change notification settings - Fork 3
xarray datetime limitations #6
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
@wwicker, thanks for raising the issue related to timestamp limitations (limited to approximately 584 years). Your workaround may not be necessary if this xarray's issue would be solved. Otherwise, I would rather suggest the following workaround: ds = xr.open_dataset(in_netcdf, decode_times=False)
ntime = ds.time.shape[0]
times = pd.period_range(str(s_year)+'-01-01', name='time', periods=ntime, freq='M')
ds['time'] = times
ds['month'] = ('time', times.month)
ds['year'] = ('time', times.year)
climatology = ds.groupby(ds.month).mean('time')
anomalies = ds.groupby(ds.month) - climatology |
However, I found out that plotting and netcdf outputting is not possible due to object dtype of time coordinate. |
+1 to this issue. I'm struggling big time with an 1800-year climate model dataset that I need to resample in order to make different annual means (June-May). Two remarks.
|
Uh oh!
There was an error while loading. Please reload this page.
Hi,
xarray is using pandas DateTimeIndex for the time axis of xarrays. Due to the representation of time in nanoseconds the investigated period is limited to something like 550 years. There is much on this issue on the web. A widely recommended workaround is to use PeriodIndex instead. Unfortunately many xarray functionalities are affected by this, e.g. groupby and encoding.
I propose an adaptation like this in eofs_univ_ccmi_xarray.py and something equivalent in the other scripts.
line 96:
line 164:
The text was updated successfully, but these errors were encountered: