-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
I have a dataset that looks like this:
<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
<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:
<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.
Metadata
Metadata
Assignees
Labels
No labels