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

allow custom 'units' when saving datetimes to netCDF #540

Closed
andreas-h opened this issue Aug 19, 2015 · 2 comments
Closed

allow custom 'units' when saving datetimes to netCDF #540

andreas-h opened this issue Aug 19, 2015 · 2 comments

Comments

@andreas-h
Copy link
Contributor

when manually setting the units attribute of a DataArray containing datetime types, the error

ValueError: Failed hard to prevent overwriting key 'units'

is raised.

It would be good to allow custom units, because currently the units seem to be days since FIRST_TIMESTEP, which leads to different units for different variables within the same Dataset.

@shoyer
Copy link
Member

shoyer commented Aug 19, 2015

We should raise a better error message. You can indeed actually customize this by setting an appropriate encoding on the DataArray, e.g.,
ds.time.encoding['units'] = 'hours since 1900-01-01T00

@shoyer
Copy link
Member

shoyer commented Apr 8, 2016

This is now describing on the IO docs page under "encoding"

@shoyer shoyer closed this as completed Apr 8, 2016
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

2 participants