home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 1688779793

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
1688779793 I_kwDOAMm_X85kqLwR 7794 TypeError for time_bnds variable when calling Dataset.to_netcdf 10836031 open 0     7 2023-04-28T15:48:25Z 2024-03-12T06:38:49Z   NONE      

What happened?

In the workflow I load the dataset (clisops), remap it (xesmf), chunk it according to the available memory, then write it to disk (clisops). I encounter however a TypeError when writing the Dataset to disk, since xarray>=2023.3.0.

What did you expect to happen?

The Dataset to be written to disk.

Minimal Complete Verifiable Example

```Python import xarray as xr import os

ds_url="https://github.com/roocs/mini-esgf-data/raw/master/test_data/badc/cmip5/data/cmip5/output1/MOHC/HadGEM2-ES/rcp85/day/land/day/r1i1p1/latest/mrsos/mrsos_day_HadGEM2-ES_rcp85_r1i1p1_20051201.nc" ds_path="mrsos_day_HadGEM2-ES_rcp85_r1i1p1_20051201.nc" if not os.path.isfile(ds_path): os.system(f"wget {ds_url}")

ds=xr.open_dataset(ds_path)

With printing the values of the time_bnds variable, the to_netcdf-call later fails

This is basically simulating the processing of the data

print(ds["time_bnds"].values)

chunked_ds_in = ds.chunk({"time":1})

chunked_ds_in.to_netcdf(path="input.nc", compute=True) ```

MVCE confirmation

  • [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • [X] Complete example — the example is self-contained, including all data and the text of any traceback.
  • [X] Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • [X] New issue — a search of GitHub Issues suggests this is not a duplicate.

Relevant log output

```Python

TypeError: Invalid array type: <class 'cftime._cftime.Datetime360Day'>

I think the problem comes mainly from the change in

xarray/core/common.py", line 1811, in _contains_cftime_datetimes with xarray 2023.3.0

At least the problems disappears when I use the old implementation of _contains_cftime_datetimes. ```

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS ------------------ commit: None python: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0] python-bits: 64 OS: Linux OS-release: 5.4.0-147-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.14.0 libnetcdf: 4.9.2 xarray: 2023.4.2 pandas: 1.5.3 numpy: 1.23.5 scipy: 1.10.1 netCDF4: 1.6.3 pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None iris: None bottleneck: 1.3.7 dask: 2023.3.2 distributed: 2023.3.2 matplotlib: 3.7.1 cartopy: None seaborn: None numbagg: None fsspec: 2023.3.0 cupy: None pint: None sparse: 0.14.0 flox: None numpy_groupies: None setuptools: 67.6.1 pip: 23.0.1 conda: None pytest: 7.2.2 mypy: None IPython: 8.12.0 sphinx: 6.1.3
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/7794/reactions",
    "total_count": 1,
    "+1": 1,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    13221727 issue

Links from other tables

  • 2 rows from issues_id in issues_labels
  • 3 rows from issue in issue_comments
Powered by Datasette · Queries took 85.378ms · About: xarray-datasette