-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
coordinate variable not written in netcdf file in some cases #733
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
This is an unadvertised feature, though I agree that it may be more trouble than it's worth -- xarray implicitly creates coordinates like The original intent (see #245) was for more faithful roundtripping of netCDF files, which may not have all coordinate variables defined. Arguably, it would make more sense to only do this when a certain |
At the very least, we should advertise this feature in the documentation. But given how surprising people find it, it might be even better to remove it... |
I personally find it useful - maybe not too intuitive though that the behaviour changes depending on whether there are attrs defined for that coordinate variable or not. I agree some documentation on this would be definitely helpful! |
I also find it useful, now that I understand it. But I also find it useful to know if the xarray coordinate is a netcdf coordinate or netcdf dimension: "A variable with the same name as a dimension is called a coordinate variable". But I guess that is the same as "indicating that xarray created the coordinate itself", as @shoyer mentioned above? |
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 |
Given the age of this issue, let's close it. Please reopen with updated MCVE, if the issue still persists. |
I came across a situation where my coordinate variable was not dumped as a variable in the output netcdf file using
dataset.to_netcdf
. In my case I managed to fix it by simply adding variable attributes to this coordinate variable (which didn't have any).The situation where that happened was while creating a sliced dataset with
dataset.isel_points
method which automatically defines a new coordinate calledpoints
in the sliced dataset. If I dump that dataset as is, the coordinate isn't written as a variable in the netcdf. adding attributes topoints
however changes that. Here is an example:Here is the ncdump output for these two files:
The text was updated successfully, but these errors were encountered: