home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 171956399

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
171956399 MDU6SXNzdWUxNzE5NTYzOTk= 975 invalid timestamps in the future 10194086 closed 0     6 2016-08-18T17:29:02Z 2016-08-25T22:39:26Z 2016-08-25T22:39:26Z MEMBER      

If I have a netCDF file that has invalid timesteps from the 'future', it is wrongly converted to datetime64[ns].

``` import netCDF4 as nc import numpy as np import xarray as xr

create netCDF file

ncf = nc.Dataset('test_future.nc', 'w') ncf.createDimension('time') ncf.createVariable('time', np.int, dimensions=('time')) ncf.variables['time'].units = 'days since 1850-01-01 00:00:00' ncf.variables['time'].calendar = 'standard' ncf.variables['time'][:] = np.arange(850) * 365 ncf.close()

open with xr

ds = xr.open_dataset('test_future.nc')

this works

ds

ds.time is a datetime64[ns] object

this fails

ds.time ```

If I choose chalendar='noleap' the dates wrap around!

``` ncf = nc.Dataset('test_future_noleap.nc', 'w') ncf.createDimension('time') ncf.createVariable('time', np.int, dimensions=('time')) ncf.variables['time'].units = 'days since 1850-01-01 00:00:00' ncf.variables['time'].calendar = 'noleap' ncf.variables['time'][:] = np.arange(850) * 365 ncf.close()

open with xr

ds = xr.open_dataset('test_future_noleap.nc')

after 2262 they go back to 1678!

ds.time ```

If my 'invalid' time is from the 'past' it works as expected:

``` ncf = nc.Dataset('test_past.nc', 'w') ncf.createDimension('time') ncf.createVariable('time', np.int, dimensions=('time')) ncf.variables['time'].units = 'days since 1000-01-01 00:00:00' ncf.variables['time'].calendar = 'standard' ncf.variables['time'][:] = np.arange(850) * 365 ncf.close()

open with xr

ds = xr.open_dataset('test_past.nc')

this works

ds

ds.time is a object

ds.time ```

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/975/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 6 rows from issue in issue_comments
Powered by Datasette · Queries took 0.571ms · About: xarray-datasette