-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Is your feature request related to a problem?
Currently, the only supported method for saving complex numbers to netCDF is to use the h5netcdf
engine with invalid_netcdf=True
.
The latest release of netCDF4
, 1.7.1, now has support for complex numbers. Also, because it's built on the up-coming netCDF 4.9.3, it includes support for reading files written using h5netcdf
with invalid_netcdf=True
(and I think for pretty much all other types that fall under this, including enums and bools).
This means that there are now more options for users wanting to read/write complex numbers, although this depends on the version of netCDF4
in use and the flags used to open files.
Just to note that the complex number support in netCDF4
is done via converting to/from a compound datatype (or a complex
dimension for netCDF-3 files), and is completely standard netCDF -- it's basically just a wrapper in the Python API.
Describe the solution you'd like
Either expose the auto_complex
keyword for netCDF4.Dataset
to the backend or set this automatically. This will either require using netCDF4>=1.7.1
or detecting the version.
Additionally, invalid_netcdf
will no longer be strictly necessary for bools and complex numbers for h5netcdf
, although again this will be dependent on the version of netCDF used -- this is sort of outside of xarray though.
I'm happy to implement this as it's pretty trivial, but is it better
Describe alternatives you've considered
No response
Additional context
There is currently an issue mixing netCDF4==1.7.1
and h5py==3.11.0
in the same python process, see: Unidata/netcdf4-python#1343 and h5py/h5py#2453. This might need to be resolved before xarray can require netCDF4==1.7.1
Any insights on how to resolve this would be much appreciated!