home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 241470249

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions performed_via_github_app issue
https://github.com/pydata/xarray/issues/899#issuecomment-241470249 https://api.github.com/repos/pydata/xarray/issues/899 241470249 MDEyOklzc3VlQ29tbWVudDI0MTQ3MDI0OQ== 1217238 2016-08-22T16:31:19Z 2016-08-22T16:31:19Z MEMBER

Looks like we could use the bounds attribute in this dataset to set the bound variables as coordinates automatically:

``` In [2]: ds = xarray.open_dataset('/Users/shoyer/Downloads/20100101120000-ESACCI-L4_GHRSST-SSTdepth-OSTIA-GLOB_LT-v02.0-fv01.1.nc')

In [3]: ds Out[3]: <xarray.Dataset> Dimensions: (bnds: 2, lat: 3600, lon: 7200, time: 1) Coordinates: * time (time) datetime64[ns] 2010-01-01T12:00:00 * lat (lat) float32 -89.975 -89.925 -89.875 -89.825 ... * lon (lon) float32 -179.975 -179.925 -179.875 ... * bnds (bnds) int64 0 1 Data variables: time_bnds (time, bnds) datetime64[ns] 2010-01-01 2010-01-02 lat_bnds (lat, bnds) float32 -90.0 -89.95 -89.95 -89.9 ... lon_bnds (lon, bnds) float32 -180.0 -179.95 -179.95 ... analysed_sst (time, lat, lon) float64 nan nan nan nan nan nan ... analysis_error (time, lat, lon) float64 nan nan nan nan nan nan ... sea_ice_fraction (time, lat, lon) float64 nan nan nan nan nan nan ... sea_ice_fraction_error (time, lat, lon) float64 nan nan nan nan nan nan ... mask (time, lat, lon) float64 2.0 2.0 2.0 2.0 2.0 2.0 ...

In [5]: ds.time.attrs Out[5]: OrderedDict([('standard_name', 'time'), ('axis', 'T'), ('bounds', 'time_bnds'), ('comment', ''), ('long_name', 'reference time of sst file')])

In [9]: xarray.concat([ds], dim='time') Out[9]: <xarray.Dataset> Dimensions: (bnds: 2, lat: 3600, lon: 7200, time: 1) Coordinates: * lat (lat) float32 -89.975 -89.925 -89.875 -89.825 ... * lon (lon) float32 -179.975 -179.925 -179.875 ... * bnds (bnds) int64 0 1 * time (time) datetime64[ns] 2010-01-01T12:00:00 Data variables: sea_ice_fraction (time, lat, lon) float64 nan nan nan nan nan nan ... time_bnds (time, bnds) datetime64[ns] 2010-01-01 2010-01-02 mask (time, lat, lon) float64 2.0 2.0 2.0 2.0 2.0 2.0 ... lat_bnds (time, lat, bnds) float32 -90.0 -89.95 -89.95 ... analysis_error (time, lat, lon) float64 nan nan nan nan nan nan ... analysed_sst (time, lat, lon) float64 nan nan nan nan nan nan ... sea_ice_fraction_error (time, lat, lon) float64 nan nan nan nan nan nan ... lon_bnds (time, lon, bnds) float32 -180.0 -179.95 -179.95 ...

In [11]: xarray.concat([ds.set_coords(['time_bnds', 'lat_bnds', 'lon_bnds'])], dim='time') Out[11]: <xarray.Dataset> Dimensions: (bnds: 2, lat: 3600, lon: 7200, time: 1) Coordinates: * lat (lat) float32 -89.975 -89.925 -89.875 -89.825 ... lat_bnds (lat, bnds) float32 -90.0 -89.95 -89.95 -89.9 ... * lon (lon) float32 -179.975 -179.925 -179.875 ... lon_bnds (lon, bnds) float32 -180.0 -179.95 -179.95 ... * bnds (bnds) int64 0 1 * time (time) datetime64[ns] 2010-01-01T12:00:00 time_bnds (time, bnds) datetime64[ns] 2010-01-01 2010-01-02 Data variables: sea_ice_fraction (time, lat, lon) float64 nan nan nan nan nan nan ... mask (time, lat, lon) float64 2.0 2.0 2.0 2.0 2.0 2.0 ... analysis_error (time, lat, lon) float64 nan nan nan nan nan nan ... analysed_sst (time, lat, lon) float64 nan nan nan nan nan nan ... sea_ice_fraction_error (time, lat, lon) float64 nan nan nan nan nan nan ... ```

There's also a bigger issue with stacking vs concatenating, though. I'll open a new issue for that.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  165540933
Powered by Datasette · Queries took 0.668ms · About: xarray-datasette