-
Notifications
You must be signed in to change notification settings - Fork 48
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
Attributes added by intake-esm contain invalid characters for netCDF #490
Comments
👍🏽 for using a reasonable alternative. i'm curious... is i've always wondered without it's worth keeping these attributes after we're done with merging datasets. should we add a global option to keep or drop these attributes whenever intake-esm finishes assembling the datasets? |
@aulemahal, if you have time, a PR is welcome :) |
Test: import xarray as xr
ds = xr.tutorial.open_dataset('air_temperature')
for char in ['-', ':', '.', '/', "\\", ';', '·', '~', '|', '=', '>', '▶', '🪕']:
print(char, ':')
ds2 = ds.copy()
ds2.attrs[f'cat{char}name'] = 'attr'
for engine in ['netcdf4', 'h5netcdf', 'scipy']:
try:
ds2.to_netcdf('/tmp/test.nc', engine=engine)
except Exception as err:
print(f' {engine}: {err}')
else:
print(f' {engine}: ok!') Prints:
It really looks like the '/' is the only character that netCDF4 doesn't support. While I'm not suggesting using the banjo 🪕, it shows that the UTF8 support is quite good. I like I might have time for a PR. I'll want to tackle a few other attribute issues at the same time I think. |
intake-esm creates global attributes based on the catalog. By default, they follow the format: intake_esm_attr/(x). While the first part of the "path" is customizable (#460), the separator character "/" is not. However, it is an illegal character when writing netCDF files (it is valid for zarr datasets though).
Would it be reasonable to have this character:
?
The text was updated successfully, but these errors were encountered: