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

NetCDF3ToZarr: `KeyError: '__padding_16' when translating #365

Closed
mpiannucci opened this issue Sep 29, 2023 · 1 comment
Closed

NetCDF3ToZarr: `KeyError: '__padding_16' when translating #365

mpiannucci opened this issue Sep 29, 2023 · 1 comment

Comments

@mpiannucci
Copy link
Contributor

mpiannucci commented Sep 29, 2023

To Reproduce:

Download https://noaa-ofs-pds.s3.amazonaws.com/ngofs2.20230929/nos.ngofs2.2ds.f001.20230929.t15z.nc , then:

from kerchunk.netCDF3 import NetCDF3ToZarr

chunks = NetCDF3ToZarr('./nos.ngofs2.2ds.f001.20230929.t15z.nc')
translated = chunks.translate()

This yields:

File [~/Developer/ocean-notebooks/env/lib/python3.10/site-packages/kerchunk/netCDF3.py:214](https://file+.vscode-resource.vscode-cdn.net/Users/matthewiannucci/Developer/ocean-notebooks/~/Developer/ocean-notebooks/env/lib/python3.10/site-packages/kerchunk/netCDF3.py:214), in NetCDF3ToZarr.translate(self)
    211 offset = start
    212 for name in dt.names:
    213     # the order of the names if fixed and important!
--> 214     var = self.variables[name]
    215     dtype = dt[name]
    216     base = dtype.base  # actual dtype

KeyError: '_padding_16'

in netcdf3.py changing this on line 210 seems make it work fine but i am not sure if this breaks anything. Im not sure the impact the padding has.

        if "record_array" in self.chunks:
            # native chunks version (no codec, no options)
            start, size, dt = self.chunks["record_array"][0]
            dt = np.dtype(dt)
            outer_shape = size // dt.itemsize
            offset = start
            for name in dt.names:
 +               if name not in variables: 
 +                  continue

Any hints would help, happy to make PR if necessary

@mpiannucci
Copy link
Contributor Author

Fixed with #367

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

1 participant