home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 128735308

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
128735308 MDU6SXNzdWUxMjg3MzUzMDg= 725 Replacing coord with coord of same name results in NaNs 6200806 closed 0     2 2016-01-26T06:12:42Z 2016-02-16T05:19:07Z 2016-02-16T05:19:07Z CONTRIBUTOR      

I think this is another unintended consequence of #648. Consider the following case:

python In [20]: arr = xr.DataArray(range(3), dims=['abc']) In [21]: new_coord = xr.DataArray([1,2,3], dims=['abc'], coords=[[1,2,3]]) In [22]: arr['abc'] = new_coord In [23]: arr Out[24]: <xarray.DataArray (abc: 3)> array([0, 1, 2]) Coordinates: * abc (abc) float64 nan 1.0 2.0

Note the nan. Before #648, this worked, in that arr's coordinates would consist of new_coord.

The use case: we have some data defined on the edges of pressure levels in an atmospheric model, and other data defined at the center of the pressure levels. In order to perform calculations involving both kinds of data, we average the edge-defined data (i.e. 0.5*(value at top edge + value at bottom edge)) to get the value at the level centers. But the resulting DataArray still has as its coord (from xarray's perspective, that is) the level edges, and so we replace that coord with the DataArray of the level centers.

A workaround would be arr['abc'].values = new_coord.values, but then any other metadata associated with the original coord is retained, which is not good.

Somewhat involved and not sure I described clearly, so let me know if clarification needed. Also I vaguely suspect there's a cleaner way of doing this in the first place. Thanks!

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