home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 235224055

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
235224055 MDU6SXNzdWUyMzUyMjQwNTU= 1449 time.units truncated when saving to_netcdf 10194086 closed 0     6 2017-06-12T12:58:37Z 2023-09-13T13:25:25Z 2023-09-13T13:25:24Z MEMBER      

When I manually specify the units attribute for time, and then save the Dataset to_netcdf the string is truncated. See exaple

import pandas as pd
import xarray as xr

time = pd.date_range('2000-01-01', '2000-01-31', freq='6h')
ds = xr.Dataset(coords=dict(time=time))

units = 'days since 1975-01-01 00:00:00'
calendar = 'gregorian'
encoding=dict(time=dict(units=units, calendar=calendar))

ds.to_netcdf('test.nc', format='NETCDF4_CLASSIC', encoding=encoding)

! ncdump -h test.nc
# time:units = "days since 1975-01-01" ;

Some programs seem to require the hours to be present to interpret the time properly (e.g. panoply). When specifying the hour, a 'T' is added.

units = 'days since 1975-01-01 01:00:00'

! ncdump -h test.nc
# time:units = "days since 1975-01-01T01:00:00" ;

When xarray defines the time.units it works fine.

ds = xr.Dataset(coords=dict(time=time))
ds.to_netcdf('test.nc', format='NETCDF4_CLASSIC',)

! ncdump -h test.nc
# time:units = "hours since 2000-01-01 00:00:00" ;

xarray version 0.9.6

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/1449/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

  • 1 row from issues_id in issues_labels
  • 5 rows from issue in issue_comments
Powered by Datasette · Queries took 241.519ms · About: xarray-datasette