Open matt-long opened 4 years ago
with xgcm master and metrics specified this becomes
# TGRID to UGRID
Xu = grid.interp(Xt, axis=“XY”, metric_weighted=”XY”)
#UGRID to TGRID
Xt = grid.interp(Xu, axis=“XY”)
Do you think it's worth having a method in grid
? It could look something like this.
def ugrid_to_tgrid(arr_ugrid):
"""
Interpolates values at U points on a B grid to T points.
"""
with xr.set_options(keep_attrs=True):
return 0.25 * (
arr_ugrid + # j, i
arr_ugrid.roll(nlat=1, roll_coords=False) + # j-1, i
arr_ugrid.roll(nlon=1, roll_coords=False) + # j, i-1
arr_ugrid.roll(nlat=1, nlon=1, roll_coords=False) #j-1, i-1
)
Maybe as a convenience method so you can do it without xgcm?
it is really convenient once xgcm makes a release...
We should have a UGRID to TGRID function...and the reverse.