issues: 1619835929
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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1619835929 | I_kwDOAMm_X85gjLwZ | 7608 | dataset attrs list of strings to_netcdf() error | 3792276 | open | 0 | 7 | 2023-03-11T01:58:26Z | 2023-03-16T18:19:43Z | NONE | What happened?when I try and save the dataset with an attribute as a list of strings it fails. See example code ```python import xarray as xr import pandas as pd import numpy as np ds = xr.Dataset() temp = 15 + 8 * np.random.randn(2, 2, 3) precip = 10 * np.random.rand(2, 2, 3) lon = [[-99.83, -99.32], [-99.79, -99.23]] lat = [[42.25, 42.21], [42.63, 42.59]] ds["temperature"] = (("x", "y", "time"), temp) ds["temperature_double"] = (("x", "y", "time"), temp * 2) ds["precipitation"] = (("x", "y", "time"), precip) ds.coords["lat"] = (("x", "y"), lat) ds.coords["lon"] = (("x", "y"), lon) ds.coords["time"] = pd.date_range("2014-09-06", periods=3) ds.coords["reference_time"] = pd.Timestamp("2014-09-05") ds.attrs['test'] = [1,2,3] ds.to_netcdf('test.nc') no errords.attrs['test'] = ['1','2','3'] ds.to_netcdf('test.nc') ``` ```bash File "C:\Users\xxxx\Anaconda3\envs\base1\lib\site-packages\scipy\io_netcdf.py", line 555, in _write_att_values nc_type = REVERSE[values.dtype.char, values.dtype.itemsize] KeyError: ('U', 4) ``` What did you expect to happen?No response Minimal Complete Verifiable ExampleNo response MVCE confirmation
Relevant log outputNo response Anything else we need to know?No response Environment
xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.10.9 | packaged by conda-forge | (main, Jan 11 2023, 15:15:40) [MSC v.1916 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 165 Stepping 2, GenuineIntel
byteorder: little
LC_ALL: None
LANG: en
LOCALE: ('English_United States', '1252')
libhdf5: 1.10.6
libnetcdf: None
xarray: 2022.11.0
pandas: 1.5.2
numpy: 1.21.5
scipy: 1.9.3
netCDF4: None
pydap: None
h5netcdf: None
h5py: 3.7.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.5
dask: 2022.05.0
distributed: 2022.5.0
matplotlib: 3.6.2
cartopy: None
seaborn: 0.12.2
numbagg: None
fsspec: 2022.11.0
cupy: None
pint: 0.20.1
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.6.3
pip: 22.3.1
conda: None
pytest: 7.1.2
IPython: 7.31.1
sphinx: 5.0.2
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/7608/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |