issues: 374070147
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
374070147 | MDU6SXNzdWUzNzQwNzAxNDc= | 2512 | to_netcdf() fails because of datetime encoding | 22665917 | closed | 0 | 2 | 2018-10-25T18:17:47Z | 2018-10-27T16:34:54Z | 2018-10-27T16:34:54Z | NONE | Simple example:```python import numpy as np from datetime import datetime, timedelta import xarray "time" coordinatedt = datetime(1999, 1, 1) dts = np.array([dt + timedelta(days=x) for x in range(10)]) coords = {'time': dts} simple float datadata = np.arange(10) vrbls = {'foo': (('time',), data)} create the Datasetds = xarray.Dataset(vrbls, coords) encode the time coordinateunits = 'days since 1900-01-01' ds.time.encoding['units'] = units write to netcdfds.to_netcdf('test.nc') ``` Problem descriptionWhen I run the above, I get the following error when executing the last line:
The documentation indicates that datetime and datetime64 objects are both supported by xarray and should write to netcdf just fine when supplied "units" for encoding (this code fails with or without the encoding lines). Any Idea when is going wrong here? Output of
|
{ "url": "https://api.github.com/repos/pydata/xarray/issues/2512/reactions", "total_count": 1, "+1": 1, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |