At the moment, output from MOM6 returns BGC variables on the z* grid which I understand varies in time, given by e or h. Is there a neat way to regrid the BGC data onto a fixed grid and then interp it onto the same vertical grid as the physical data which is output on the z grid?
I was trying something like this but it doesn’t work!
import xarray as xr
import xgcm
from xgcm import transform
# bgc data
ds = bgc3d_m_05_tides
# Cell interface depth to cell centre depth
grid = Grid(phy_m_05_tides, coords={'Z': {'center': 'z_l', 'left': 'z_i'}},autoparse_metadata=False)
z= grid.interp(phy_m_05_tides.e, 'Z', boundary='fill', fill_value=None)
# add the depth field to the ds
ds= ds.assign_coords(z=z)
# this is the target depth I want to eventually put the BGC data onto
z_fixed = phy_m_05_tides.z_l
# this is where I get stuck!?
ds=ds.interp(z=zl,kwargs={"fill_value": "extrapolate"})
#check to see if it now plots as a nice cross section. (At the moment it doesn’t!)
ds.no3.isel(time=1).isel(xh=100).plot(vmin=0,vmax=2.5e-5)