Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ugrid_to_tgrid.... #46

Open
matt-long opened this issue Apr 8, 2020 · 3 comments
Open

ugrid_to_tgrid.... #46

matt-long opened this issue Apr 8, 2020 · 3 comments

Comments

@matt-long
Copy link
Collaborator

matt-long commented Apr 8, 2020

We should have a UGRID to TGRID function...and the reverse.

@dcherian
Copy link
Contributor

dcherian commented Apr 8, 2020

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”)

@matt-long
Copy link
Collaborator Author

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
        )

@dcherian
Copy link
Contributor

Maybe as a convenience method so you can do it without xgcm?

it is really convenient once xgcm makes a release...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants