-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add curl computation function #16
Comments
I think xgcm has a curl operator. |
It might be nice then to add a utility here that converts raw POP output to an xGCM object, or xGCM compatible object, as we discussed before. Ryan Abernathy added a code snippet for this in #12, and it shows that it's not straight forward to a new user. |
Agreed. I think a |
Now that we have |
Yes this should be fairly trivial with the |
@dcherian may have perspective on how to move forward here. |
Hi All: |
Sorry for the late response; I was out of town. @ALDepp and I are working on this. Currently I have a rough implementation def x_divh(U, V, grid, boundary=None):
dy = grid.get_metric(U, "Y")
dzu = grid.get_metric(U, "Z")
dx = grid.get_metric(V, "X")
dzv = grid.get_metric(V, "Z")
UT = U * dy
VT = V * dx
if grid.arakawa == "C":
# c grid needs the dz multiply
# but we want to avoid this for b grid so that
# we don't create unnecessary tasks
UT = UT * dzu
VT = V * dzv
elif grid.arakawa == "B":
# B grid needs an interp step here
# U in Y; V in X
UT = grid.interp(UT, "Y", boundary="extend")
VT = grid.interp(VT, "X", boundary="extend")
div = grid.diff(UT, "X", boundary="extend") + grid.diff(VT, "Y", boundary="extend")
area = grid.get_metric(div, "XY")
div = div / area
# TODO: for C grid need (div / DZ) to get dimensionality right: ∂w/∂z
# but the xgcm example notebook does not do that.
return div
def x_curlz(U, V, grid):
Udx = U * grid.get_metric(U, "X")
Vdy = V * grid.get_metric(V, "Y")
if grid.arakawa == "B":
# B grid needs an interp step here
# Udx in X; Vdy in Y
Udx = grid.interp(Udx, "X", boundary="extend")
Vdy = grid.interp(Vdy, "Y", boundary="extend")
der = -grid.diff(Udx, "Y", boundary="extend") + grid.diff(Vdy, "X", boundary="extend")
area = grid.get_metric(der, "XY")
curlz = der / area
return curlz This leverages the new metrics functionality in xgcm: https://xgcm.readthedocs.io/en/latest/grid_metrics.html. The metrics setup could be added to I am envisioning the following aspiration syntax that would work regardless of model: vorticity = grid.curlz(ds.UVEL, ds.VVEL)
diveregence = grid.divh(ds.UVEL, ds.VVEL) We will iterate on this and start a PR/discussion over at xgcm on adding these higher order operators to xgcm soon. |
Hi @dcherian |
@DapengLi17 here's a gist that demonstrates one way to plot the POP grid using a |
|
|
Hi @matt-long |
You can apply |
Hi @matt-long |
@andersy005, @dcherian I think this can be closed in favor of xgcm/xgcm#187. |
I think it would be nice to have a function that computed wind stress curl (or perhaps vector curl agnostic to the variable) over the POP grid.
In past years, I had a lot of trouble getting this done effectively in python, and was under the impression that curl/divergence computations in python weren't supported too well. I turned to NCL for computing it (https://www.ncl.ucar.edu/Document/Functions/Built-in/uv2vrF-1.shtml). However, that function depends on a fixed (non-POP) grid.
Here's a reference that might be helpful for python: https://auckland.figshare.com/articles/Curl_of_a_vector_field/5768280/1.
cc @matt-long @andersy005. Any thoughts? Is this better for
pop-tools
oresmlab
? If the latter, this should be planned to handle all grid types. If the former, just POP. I'd be happy to lead this effort with some feedback, but #12 is higher priority when I can put it to the top of the docket.This of course should be straight forward following:
The text was updated successfully, but these errors were encountered: