home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 538380868

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
538380868 MDU6SXNzdWU1MzgzODA4Njg= 3627 Error time slicing for some CMIP6 models 57364981 closed 0     10 2019-12-16T12:25:42Z 2019-12-16T15:42:56Z 2019-12-16T15:42:56Z NONE      

Hi there,

I'm using xarray's open_zarr() function to analyse CMIP6 data:

```python

Function to load data: df_data has the catalogue of the variable of interest

def load_data(df_data, source_id, expt_id): """ Load data for given variable, source and expt ids. """ uri = df_data[(df_data.source_id == source_id) & (df_data.experiment_id == expt_id)].zstore.values[0]

gcs = gcsfs.GCSFileSystem(token='anon')
ds = xr.open_zarr(gcs.get_mapper(uri), consolidated=True)
return ds

Just test with 1 model for now:

source_ids_tmp = ['CESM2']

for model_name in source_ids_tmp: print('\n\nStarting ' + model_name +'\n') ds_hist = load_data(df_mon_tas, model_name, experiment_ids[0]).sel(time=slice('1976', '2005')) ```

Problem Description

However, the time slicing fails with the following error:

TypeError: cannot compare netcdftime._netcdftime.DatetimeNoLeap(1932, 7, 15, 12, 0, 0, 0, 1, 196) and '1976'

Looking at the Dataset metedata, the time variable is described as follows:

  • time (time) object 1850-01-15 12:00:00 ... 2014-12-15 12:00:00 time_bnds (time, nbnd) object dask.array<chunksize=(1980, 2)>

For another CMIP6 model (MIROC6), the time slicing works fine. That model has the following metadat for time:

  • time (time) datetime64[ns] 1850-01-16T12:00:00 ... 2014-12-16T12:00:00 time_bnds (time, bnds) datetime64[ns] dask.array<chunksize=(1980, 2)>

When the time variable is converted to a datetime[ns] object, time slicing seems to work. Any idea what the problem is?

Thanks,

Mike

Output of xr.show_versions()

INSTALLED VERSIONS ------------------ commit: None libhdf5: 1.10.1 libnetcdf: 4.4.1.1 xarray: 0.14.0 pandas: 0.25.1 numpy: 1.16.2 scipy: 1.2.1 netCDF4: 1.3.1 pydap: installed h5netcdf: 0.5.0 h5py: 2.7.0 Nio: None zarr: 2.3.2 cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 0.15.3 distributed: 1.19.1 matplotlib: 3.0.0 cartopy: 0.16.0 seaborn: 0.9.0 numbagg: None setuptools: 36.5.0.post20170921 pip: 19.0.3 conda: 4.4.6 pytest: 3.3.0 IPython: 6.1.0 sphinx: 1.6.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/3627/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 10 rows from issue in issue_comments
Powered by Datasette · Queries took 79.65ms · About: xarray-datasette