Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save complex/Hilbert models with engine=netcdf4 #214

Open
nicrie opened this issue Sep 3, 2024 · 2 comments
Open

Cannot save complex/Hilbert models with engine=netcdf4 #214

nicrie opened this issue Sep 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nicrie
Copy link
Contributor

nicrie commented Sep 3, 2024

Describe the bug
Trying to save a complex/Hilbert model with engine=netcdf4 results in the following error:

TypeError: illegal primitive data type, must be one of dict_keys(['S1', 'i1', 'u1', 'i2', 'u2', 'i4', 'u4', 'i8', 'u8', 'f4', 'f8']), got complex128

Reproducible Minimal Working Example
Provide a concise Python code snippet that demonstrates the issue. To display the code clearly, use GitHub Flavored Markdown for formatting:

import xarray as xr
import xeofs as xe

t2m = xr.tutorial.open_dataset("air_temperature").air
heof = xe.models.HilbertEOF()
heof.fit(t2m, "time")
heof.save("test.nc", engine="netcdf4")

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: Ubuntu 22
  • xeofs version 2.4.1

Additional context
None

@nicrie nicrie added the bug Something isn't working label Sep 3, 2024
@slevang
Copy link
Contributor

slevang commented Sep 3, 2024

Complex support has only very recently been added upstream to netcdf4, and I don't think it's quite available from xarray yet.

engine='h5netcdf', invalid_netcdf=True should work so long as we are properly passing through extra kwargs. engine='zarr' should also work.

@nicrie
Copy link
Contributor Author

nicrie commented Sep 3, 2024

nice, good to know! I think a clearer error message could be really helpful for the user, maybe just mentioning that the other formats are supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants