home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 456769766

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
456769766 MDU6SXNzdWU0NTY3Njk3NjY= 3026 Rename dims independently from coords? 43126798 closed 0     11 2019-06-17T06:48:40Z 2019-07-02T20:24:55Z 2019-07-02T20:24:55Z CONTRIBUTOR      

I have a dataset that looks like this:

python <xarray.Dataset> Dimensions: (lat: 226, lon: 261, time: 7300) Coordinates: * lat (lat) float32 -32.0 -31.9 -31.8 -31.7 ... -9.700001 -9.6 -9.5 * lon (lon) float32 132.0 132.1 132.2 132.3 ... 157.7 157.8 157.9 158.0 * time (time) object 1980-01-01 15:00:00 ... 1999-12-31 15:00:00 Data variables: rnd24 (time, lat, lon) float32 ...

Problem description

I would like to be able to rename the dataset dimensions, without renaming the coordinates.

Expected Output

python <xarray.Dataset> Dimensions: (y: 226, x: 261, time: 7300) Coordinates: * lat (y) float32 -32.0 -31.9 -31.8 -31.7 ... -9.700001 -9.6 -9.5 * lon (x) float32 132.0 132.1 132.2 132.3 ... 157.7 157.8 157.9 158.0 * time (time) object 1980-01-01 15:00:00 ... 1999-12-31 15:00:00 Data variables: rnd24 (time, y, x) float32 ...

As far as I can tell, there is no way to do this. I can rename the existing dims/coords to x/y, and then manually create new coordinates that are copies of x and y, which gets me to:

python <xarray.Dataset> Dimensions: (time: 7300, x: 261, y: 226) Coordinates: * y (y) float32 -32.0 -31.9 -31.8 -31.7 ... -9.700001 -9.6 -9.5 * x (x) float32 132.0 132.1 132.2 132.3 ... 157.7 157.8 157.9 158.0 * time (time) object 1980-01-01 15:00:00 ... 1999-12-31 15:00:00 lat (y) float32 -32.0 -31.9 -31.8 -31.7 ... -9.700001 -9.6 -9.5 lon (x) float32 132.0 132.1 132.2 132.3 ... 157.7 157.8 157.9 158.0 Data variables: rnd24 (time, y, x) float32 ...

But it doesn't seem to be possible to re-assign the new coordinates as the indexes for the existing dims.

In this case, it may seem a bit redundant, because the coordinates are equal to the grid. But I'm trying to get this output to work with code that also deals with other datasets that have non- rectilinear grids.

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