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

NCZarr fill_value is Nan instead of NaN on Windows #2265

Closed
malmans2 opened this issue Mar 29, 2022 · 3 comments
Closed

NCZarr fill_value is Nan instead of NaN on Windows #2265

malmans2 opened this issue Mar 29, 2022 · 3 comments

Comments

@malmans2
Copy link

In this xarray's PR I found out that I'm having issues reading with python NCZarr data created on Windows.
Looks like the issue has to do with fill_value, which is Nan instead of NaN, and therefore can't be properly parsed by python's json.

Sorry, I don't have much more details as I don't have a Windows machine to explore this a bit better. I thought I would open an issue here in case you already have some ideas about what's causing the problem. I guess it's possible that the problem is actually related to netcdf4-python as I'm using it to create the NCZarr file.

This is the Python code I'm using to create the NCZarr data
from xarray.tests.test_dataset import create_test_data
ds = create_test_data()
ds = ds.drop_vars("dim3")
ds.to_netcdf("file://test_data.zarr#mode=nczarr")
@malmans2 malmans2 changed the title fill_value is Nan instead of NaN on Windows NCZarr fill_value is Nan instead of NaN on Windows Mar 29, 2022
@DennisHeimbigner
Copy link
Collaborator

Looks like a typo on my part.
You should be able to fix as follows:

  1. edit the file netcdf-c/libnczarr/zcvt.c
  2. Near line 308 you should see this line: strcpy(s,"Nan"); break;
  3. Change to this: strcpy(s,"NaN"); break;

I will submit a PR for this after I hear if it fixes the problem.

@malmans2
Copy link
Author

I don't have an easy way to test that change on Windows.

However, I replaced myself all Nan in .zattrs and .zarray with NaN, and I can confirm that I'm able to correctly read the data. Therefore, I'm pretty sure that changing strcpy(s,"Nan") to strcpy(s,"NaN") will fix the problem and I suggest to go ahead with the PR.

DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Mar 30, 2022
re: issue Unidata#2265

The zarr code is generating "Nan" instead of "NaN" on windows.
This causes failures.
Solution: fix typo.
@DennisHeimbigner
Copy link
Collaborator

See PR #2267

@malmans2 malmans2 closed this as completed Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants