Hello everyone!
Hopefully this is the right place to ask this question:
I am currently trying to create initial conditions for a high-resolution, regional ocean model (based on ROMS) from the GLORYS12v1 reanalysis dataset. Since the model grids and vertical coordinate systems are different I am interpolating the three-dimensional (longitude, latitude, depth) GLORYS data horizontally onto the model grid using the xESMF module which generally works like a charm.
To account for the differences in the land/sea masks between my model and the reanalysis, I am using the extrapolation feature described here. This requires a mask
variable which can only be 2D because of the underlying ESMF design.
However, the land/sea mask in GLORYS12v1 changes with depth, so that I have to apply the regridding for each vertical level separately. Is there any preferred way to do that?
Suppose that ds
a xarray.Dataset()
with dimensions depth
, lon
, and lat
containing multiple variables including a 3D mask
. Off the top of my hat, I can think of two options (both untested):
- Iterate over
depth
dimension, build thexesmf.Regridder()
for each level and manually create an output datasetds_int
with the interpolated data. I’m afraid that this could be quite slow. - Write a dummy function that takes 2D fields as input arguments and applies the regridding for an individual model level. I would then apply this function to all depth levels using the
xarray.apply_ufunc()
method.
Do you have any other suggestions, tips, or tricks how to best approach this (in the best case computationally efficiently)?
Many thanks in advance!