-
From the docs, I was under the impression that this script to save to two different groups in the NetCDF file would work: import numpy as np
from xarray import Dataset, DataArray
data_arrays = []
for i in range(4):
data_arrays.append(DataArray(np.ones(3)*i))
ds1 = Dataset({"A": data_arrays[0], "B": data_arrays[1]})
ds2 = Dataset({"A": data_arrays[2], "B": data_arrays[3]})
ds1.to_netcdf("test.nc", "a", group="apple", format="NETCDF4")
ds2.to_netcdf("test.nc", "a", group="banana", format="NETCDF4") Alas, it doesn't. I get the following Traceback: Traceback (most recent call last):
File "/home/lukas/Desktop/EDEO-Sensing/edeo_sensing/untitled0.py", line 19, in <module>
ds1.to_netcdf("test.nc", "a", group="apple", format="NETCDF4")
File "/home/lukas/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/xarray/core/dataset.py", line 1799, in to_netcdf
return to_netcdf(
File "/home/lukas/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/xarray/backends/api.py", line 1059, in to_netcdf
store = store_open(target, mode, format, group, **kwargs)
File "/home/lukas/anaconda3/envs/tf_gpu/lib/python3.9/site-packages/xarray/backends/scipy_.py", line 128, in __init__
raise ValueError("cannot save to a group with the scipy.io.netcdf backend")
ValueError: cannot save to a group with the scipy.io.netcdf backend How can I save my datasets to groups? |
Beta Was this translation helpful? Give feedback.
Answered by
keewis
May 25, 2021
Replies: 1 comment 9 replies
-
if I understand the error correctly, you're using the |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
joooeey
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if I understand the error correctly, you're using the
scipy
backend which doesn't support saving to groups. To get this to work you should be able to specifyengine="netcdf4"
(assuming thatnetcdf4
is installed).