home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 176884522

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/722#issuecomment-176884522 https://api.github.com/repos/pydata/xarray/issues/722 176884522 MDEyOklzc3VlQ29tbWVudDE3Njg4NDUyMg== 242610 2016-01-29T17:48:15Z 2016-01-29T17:48:15Z NONE

Thank you!

I was just wondering how you know then, which one is an "actual" coordinate and which one is an indexed ("default") coordinate?

xarray seem to know this.

Example:

``` In [1]: import xray as xr

In [2]: import numpy as np

In [3]: var1 = xr.DataArray(np.array([1, 2], np.float64), coords=[np.array([1, 2], np.int64)], dims=["coor1",], name = "var1")

In [4]: var2 = xr.DataArray(np.array([3, 4], np.float64), dims=["dim1",], name = "var2")

In [5]: ds.var1 Out[5]: <xray.DataArray 'var1' (coor1: 2)> array([ 1., 2.]) Coordinates: * coor1 (coor1) int64 1 2

In [6]: ds.var2 Out[6]: <xray.DataArray 'var2' (dim1: 2)> array([ 3., 4.]) Coordinates: * dim1 (dim1) int64 0 1

In [7]: ds.var1.coords Out[7]: Coordinates: * coor1 (coor1) int64 1 2

In [8]: ds.var2.coords Out[8]: Coordinates: * dim1 (dim1) int64 0 1

In [9]: ds.to_netcdf("/tmp/from_xr.nc") ```

And then

``` $ ncdump /tmp/from_xr.nc netcdf from_xr { dimensions: coor1 = 2 ; dim1 = 2 ; variables: int64 coor1(coor1) ; double var1(coor1) ; double var2(dim1) ; data:

coor1 = 1, 2 ;

var1 = 1, 2 ;

var2 = 3, 4 ; } ```

As dim1 is not written in the file, xarray somehow knows?

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