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

calculate vorticity using diff_2d_vector in LLC90 grid #599

Open
ruhuihuang opened this issue Apr 24, 2023 · 3 comments
Open

calculate vorticity using diff_2d_vector in LLC90 grid #599

ruhuihuang opened this issue Apr 24, 2023 · 3 comments
Labels

Comments

@ruhuihuang
Copy link

When I try to calculate the vorticity of velocity of ECCOv4 (LLC90 data) using the following python codes:
zeta0=grid_llc.diff_2d_vector({'X': (data_uv.VVELMASS * data_uv.dyC), 'Y': (data_uv.UVELMASS * data_uv.dxC)},boundary='fill')
zeta2 = (zeta0['X'] -zeta0['Y']) / (data_uv.rA)
---------------------------------------------------------------------------
NotImplementedError Traceback (most recent call last)
Cell In[18], line 1
----> 1 zeta0=grid_llc.diff_2d_vector({'X': (data_uv.VVELMASS * data_uv.dyC), \
2 'Y': (data_uv.UVELMASS * data_uv.dxC)},\
3 boundary='fill')

File /g/data/hh5/public/apps/miniconda3/envs/analysis3-23.01/lib/python3.9/site-packages/xgcm/grid.py:2422, in Grid.diff_2d_vector(self, vector, **kwargs)
2403 def diff_2d_vector(self, vector, **kwargs):
2404 """
2405 Difference a 2D vector to the intermediate grid point. This method is
2406 only necessary for complex grid topologies.
(...)
2420 are differenced vector components along each axis
2421 """
-> 2422 return self._apply_vector_function(self.diff, vector, **kwargs)

File /g/data/hh5/public/apps/miniconda3/envs/analysis3-23.01/lib/python3.9/site-packages/xgcm/grid.py:2378, in Grid._apply_vector_function(self, function, vector, **kwargs)
2376 position, coord = axis._get_position_name(component)
2377 if position == "center":
-> 2378 raise NotImplementedError(
2379 "Only vector interpolation to cell "
2380 "center is implemented, but vector "
2381 "%s component is defined at center "
2382 "(dims: %r)" % (axis_name, component.dims)
2383 )
2385 x_axis_name, y_axis_name = list(vector)
2387 # apply for each component

NotImplementedError: Only vector interpolation to cell center is implemented, but vector X component is defined at center (dims: ('k', 'face', 'j_g', 'i'))

Any help will be appreciated.
Thanks you.

@ruhuihuang
Copy link
Author

ruhuihuang commented Apr 24, 2023

The test data can be down load from here
uv_test.zip

@ifenty
Copy link

ifenty commented May 2, 2023

@ruhuihuang

I think you need to multiply the uvelmass, vvelmass by the grid cell edge lengths, dyG and dxG, not the grid cell center distances, dxC, dyC.

'''zeta0=grid_llc.diff_2d_vector({'X': (data_uv.VVELMASS * data_uv.dyC), 'Y': (data_uv.UVELMASS * data_uv.dxC)},boundary='fill')
zeta2 = (zeta0['X'] -zeta0['Y']) / (data_uv.rA)

@ruhuihuang
Copy link
Author

@ruhuihuang

I think you need to multiply the uvelmass, vvelmass by the grid cell edge lengths, dyG and dxG, not the grid cell center distances, dxC, dyC.

'''zeta0=grid_llc.diff_2d_vector({'X': (data_uv.VVELMASS * data_uv.dyC), 'Y': (data_uv.UVELMASS * data_uv.dxC)},boundary='fill') zeta2 = (zeta0['X'] -zeta0['Y']) / (data_uv.rA)

Thank you, but not this case.

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

No branches or pull requests

2 participants