Issue interpolating dx in the meridional direction with `xgcm`

I was investigating this issue in the cosima recipes where the calculation of the curl of the velocity field with xgcmgives different results depending on the choice of dxt or dxu and interpolation steps. To me this should not be the case - otherwise xgcm is not handling grid info appropriately.

I ended up reducing the problem to the interpolation of dx in the meridional direction. Weirdly, interpolating dxu in the y-direction (such that dxu_interp(xu_ocean, xt_ocean)) is not the same as interpolating dxt in the x-direction (such that dxt_interp(xu_ocean, yt_ocean)). The same goes for the interpolation of area and volume given these depend on dx.

To me this is a tad worrying as it will have an effect on any gradient, differentiation, interpolation, etc operation - I don’t know if its an xgcm problem or a grid problem. I’ve done a minimal working example here for both 0.1 and 0.25 degrees.

Thank you very much in advance

Just in case it is useful, I’ve also tried mom6 grids and have the same issue - might be an xgcm thing?

I find it difficult to say this is a bug: I think it might just be the nature of spherical grids. Can we expect a linear interpolation of neighbouring quantities to match the spherical grid metrics?

Yeah, true! I guess I find it to be a problem because operations become subjective to your choice of interpolation and I couldn’t find any mention of that in xgcm documentation or anywhere else.