My dataset has 3 dimensions in the order (time, y, x) and I use apply_ufunc to apply a computation along the time dimension. This rearranges the order of the dimensions as (y, x, time). I need to restructure the xarray so its in the (time, y, x) order as the original dataset. How would I go along doing this?
Here is a visual description of what's happening:
Before:
Then I apply my function:
dcube = xr.apply_ufunc(
bc.clip_and_normalize_percentile,
dcube,
input_core_dims=[["time"]],
output_core_dims=[["time"]],
dask = 'allowed',
vectorize=True
)
as expected time is moved to the last dimension:
How do I rearrange this so that its in the order of the original array? Are there parameters that prevent apply_ufunc from moving the dims?

