Irregular grid, 3-dim interpolation [depth,lat,lon] using python/dask?

Dear community,

I am looking for suggestions on irregular grid, 3-dim interpolation [depth,lat,lon] using python/dask. My data is stored in a zarr store. Specifically, I need to interpolate u and v on gridT. I need to do so for each time step. Since I have hourly output (8760 time steps), I am interested in the most efficient procedure. Total domain size is [125,853,788].

The reason for the 3-dim interpolation lies in the fact that the water column depths may strongly vary among the different grids (gridU,gridV,gridT) for a given grid point, particularly in regions with strong bathymetric slopes. Also note that my model-configuration features a partial-step z-coordinate, where each e3* metric may vary from its horizontal neighbors.

Any advice on this? I also appreciate recommendations for interpolation not using python.

Thanks!

Hi, I use xarray - below some code I wrote to regrid u,v components from U and V grids, resepctively, to T-grid for a model using generalised vertical coordinates (i.e., e3(i,j,k,t)).

Tgrd = 'path_to_your_T_grid_file'
Ugrd = 'path_to_your_U_grid_file'
Vgrd = 'path_to_your_V_grid_file'

ds_T = xr.open_dataset(Tgrd, chunks={}, drop_variables=("deptht"))
ds_U = xr.open_dataset(Ugrd, chunks={}, drop_variables=("depthu"))
ds_V = xr.open_dataset(Vgrd, chunks={}, drop_variables=("depthv"))
ds_T = ds_T.rename_dims({'deptht':'z'})
ds_U = ds_U.rename_dims({'depthu':'z'})
ds_V = ds_V.rename_dims({'depthv':'z'})

# Computing cell's volume
vol_t = ds_T.area * ds_T.thkcello
vol_u = ds_U.area * ds_U.thkcello
vol_v = ds_V.area * ds_V.thkcello

# Interpolating (u,v) from U and V grids on T grids
uT = (ds_U.uo * vol_u).rolling(x=2).mean().fillna(0.) / vol_t
vT = (ds_V.vo * vol_v).rolling(y=2).mean().fillna(0.) / vol_t

This code should be consistent with NEMO - see subroutine trd_ken in trdken.F90 module.

I hope this helps a bit.

Cheers,

Diego