I am creating a xarray dataset as below:
import numpy as np
import xarray as xr
x_example = np.random.rand(1488,)
y_example = np.random.rand(1331,)
time_example = np.random.rand(120,)
rainfall_example = np.random.rand(120, 1331, 1488)
rainfall_dataset = xr.Dataset(
data_vars=dict(
rainfall_depth=(['time', 'y', 'x'], rainfall_example),
),
coords=dict(
time=(['time'], time_example),
x=(['x'], x_example),
y=(['y'], y_example)
)
)
The results are like this
And the dimensions when I run rainfall_example.dims
are like this Frozen({'time': 120, 'y': 1331, 'x': 1488})
(this can also be seen in the above results). I know the xarray.Dataset.dims
cannot be modified according to here
My question is: How can we change the order of those dimensions into the dimensions like this Frozen({'time': 120, 'x': 1488, 'y': 1331})
without changing anything else (everything will be the same only the order in dimensions is changed)?