home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 383791450

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
383791450 MDU6SXNzdWUzODM3OTE0NTA= 2565 CF conventions: time_bnds and time units 10050469 closed 0     4 2018-11-23T11:32:37Z 2019-01-08T22:28:37Z 2019-01-08T22:28:37Z MEMBER      

Problem

Here is the dump of a NetCDF file (download):

``` netcdf cesm.TREFHT.160001-200512.selection { dimensions: time = UNLIMITED ; // (4872 currently) lat = 3 ; lon = 3 ; nbnd = 2 ; variables: float TREFHT(time, lat, lon) ; TREFHT:units = "K" ; TREFHT:long_name = "Reference height temperature" ; TREFHT:cell_methods = "time: mean" ; double lat(lat) ; lat:long_name = "latitude" ; lat:units = "degrees_north" ; double lon(lon) ; lon:long_name = "longitude" ; lon:units = "degrees_east" ; double time(time) ; time:long_name = "time" ; time:units = "days since 0850-01-01 00:00:00" ; time:calendar = "noleap" ; time:bounds = "time_bnds" ; double time_bnds(time, nbnd) ; time_bnds:long_name = "time interval endpoints" ;

// global attributes: :Conventions = "CF-1.0" ; :source = "CAM" ; ... } ```

When xarray decodes the time coordinates it also deletes the time:units attribute (this kind of makes sense, because the unit has no meaning when the time is converted to a CFTime object):

python import xarray as xr ds = xr.open_dataset(f) ds.time <xarray.DataArray 'time' (time: 4872)> array([cftime.DatetimeNoLeap(1600, 2, 1, 0, 0, 0, 0, 0, 32), cftime.DatetimeNoLeap(1600, 3, 1, 0, 0, 0, 0, 0, 60), cftime.DatetimeNoLeap(1600, 4, 1, 0, 0, 0, 0, 3, 91), ..., cftime.DatetimeNoLeap(2005, 11, 1, 0, 0, 0, 0, 6, 305), cftime.DatetimeNoLeap(2005, 12, 1, 0, 0, 0, 0, 1, 335), cftime.DatetimeNoLeap(2006, 1, 1, 0, 0, 0, 0, 4, 1)], dtype=object) Coordinates: * time (time) object 1600-02-01 00:00:00 ... 2006-01-01 00:00:00 Attributes: long_name: time bounds: time_bnds

The problem is that I have no way to actually decode the time_bnds variable from xarray alone now, because the time_bnds variable doesn't store the time units. First, I thought that my file was not CF compliant but I've looked into the CF conventions and it looks like they are not prescribing that time_bnds should also have a units attribute.

Solution

I actually don't know what we should do here. I see a couple of ways: 1. we don't care and leave it to the user (here: me) to open the file with netCDF4 to decode the time bounds 2. we don't delete the time:units attribute after decoding 3. we start to also decode the time_bnds when available, like we do with time

Thoughts? cc @spencerkclark @jhamman

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/2565/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
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 80.326ms · About: xarray-datasette