-
Notifications
You must be signed in to change notification settings - Fork 84
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
_FillValue from a classic netCDF file does not end up in the kerchunk json #385
Comments
For what it's worth, if I start with same netCDF file above and first convert it to netCDF4, then kerchunk it using SingleHdf5ToZarr the "fill value" is converted to a nan as expected when reading the resulting json file with xarray.
|
In netCDF3,oy, we have fill = var._attributes.get("missing_value", None)
...
arr.attrs.update(
{
k: v.decode() if isinstance(v, bytes) else str(v)
for k, v in var._attributes.items()
if k not in ["_FillValue", "missing_value"]
}
) so perhaps the first line should consider both possible versions of fill as done in the second block? - fill = var._attributes.get("missing_value", None)
+ fill = var._attributes.get("missing_value", None) or var._attributes.get("_FillValue", None) |
I tested this change yesterday and it worked as I expected, so considering the _FillValue as well as the missing in whatever way makes sense to you would likely solve my problem.
|
Let's make it a PR |
So I spent some time reading through all of the discussion of #177 and it seems like I'm having the exact same problem with a classic netCDF file (not an HDF file under the hood). I am using these versions:
I using this file: wget https://data.pmel.noaa.gov/aclim/thredds/fileServer/B10K-K20_CORECFS/Level1/1995-1999/B10K-K20_CORECFS_1995-1999_average_Jel.nc
When I open the netCDF using xarray, the "fill values" are set to nan:
array(nan, dtype=float32)
And I naively kerchunk it with this code, read the result with xarray, the "file value" is set to 1.e37:
When I write from the netCDF xarray data set to zarr, the "fill value" is preserved when reading the resulting zarr.
array(nan, dtype=float32)
The use of decode_cf=True didn't change anything regarding the value of the "fill value".
The text was updated successfully, but these errors were encountered: