-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Roundtrip serialization of coordinate variables with spaces in their names #1689
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
Comments
I would be in favour of issuing a warning only and discourage using spaces in variable names altogether. |
Even if we eventually implement this in some form, adding the warning would certainly be a good place to start. |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
Still valid in xarray 0.13, netcdf4-1.4.3.2 |
Current state of affairs: xr.open_dataset(xr.Dataset(coords={'name with spaces': 1}).to_netcdf()) SerializationWarning: coordinate 'name with spaces' has a space in its name, which means it cannot be marked as a coordinate on disk and will be saved as a data variable instead
xr.open_dataset(xr.Dataset(coords={'name with spaces': 1}).to_netcdf()) Shall we close here or are there any actions which should be taken? |
Please reopen, if still relevant. |
If coordinates have spaces in their names, they get restored from netCDF files as data variables instead:
This happens because the CF convention is to indicate coordinates as a space separated string, e.g.,
coordinates='latitude longitude'
.Even though these aren't CF compliant variable names (which cannot have strings) It would be nice to have an ad-hoc convention for xarray that allows us to serialize/deserialize coordinates in all/most cases. Maybe we could use escape characters for spaces (e.g.,
coordinates='name\ with\ spaces'
) or quote names if they have spaces (e.g.,coordinates='"name\ with\ spaces"'
?At the very least, we should issue a warning in these cases.
The text was updated successfully, but these errors were encountered: