home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 129843955

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
129843955 MDU6SXNzdWUxMjk4NDM5NTU= 734 Coords that look like ranges are not written in netcdf files. 242610 closed 0     1 2016-01-29T18:21:02Z 2016-01-30T01:04:26Z 2016-01-30T01:04:26Z NONE      

This may be related to #733, but I am not sure, so I create a new one to keep it clean. It was discovered when creating the second example for #722 .

When the coords from #722 are changed to coords=[np.array([0, 1], np.int64)], they are not written to the netcdf file.

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([0, 1], np.int64)], dims=["coor1",], name = "var1")

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

In [5]: ds = xr.Dataset({"var1": var1, "var2": var2})

In [6]: ds Out[6]: <xray.Dataset> Dimensions: (coor1: 2, dim1: 2) Coordinates: * coor1 (coor1) int64 0 1 * dim1 (dim1) int64 0 1 Data variables: var1 (coor1) float64 1.0 2.0 var2 (dim1) float64 3.0 4.0

In [7]: ds.to_netcdf("/tmp/from_xr_2.nc") ```

And then, no coor1 data variable in the file:

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

var1 = 1, 2 ;

var2 = 3, 4 ; } ```

Change it back:

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

In [9]: ds = xr.Dataset({"var1": var1, "var2": var2})

In [10]: ds.to_netcdf("/tmp/from_xr_3.nc") ```

and coor1 is back in the file:

``` $ ncdump /tmp/from_xr_3.nc netcdf from_xr_3 { 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 ; } ```

That is, when the coords seem like they are similar to a range.

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