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

custom "coordinates" attribute #3351

Closed
dcherian opened this issue Sep 27, 2019 · 0 comments · Fixed by #3487
Closed

custom "coordinates" attribute #3351

dcherian opened this issue Sep 27, 2019 · 0 comments · Fixed by #3487

Comments

@dcherian
Copy link
Contributor

This set of lines prevents users from writing files with a handcrafted coordinates attribute. This is useful when not all non-dimensional coordinates in a Dataset are appropriate for every data variable in a dataset.

# These coordinates are saved according to CF conventions
for var_name, coord_names in variable_coordinates.items():
attrs = variables[var_name].attrs
if "coordinates" in attrs:
raise ValueError(
"cannot serialize coordinates because variable "
"%s already has an attribute 'coordinates'" % var_name
)
attrs["coordinates"] = " ".join(map(str, coord_names))

It seems to me like we should only automatically set "coordinates" when "coordinates" not in attrs. We could raise a warning saying that setting attrs["coordinates"] prevents full roundtripping of Datasets.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant