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

[Bug]: angle_dx field in the Arctic domain is wrong #19

Open
kshedstrom opened this issue Jan 13, 2022 · 1 comment
Open

[Bug]: angle_dx field in the Arctic domain is wrong #19

kshedstrom opened this issue Jan 13, 2022 · 1 comment
Assignees
Labels
bug Something isn't working inwork should appear in a release soon

Comments

@kshedstrom
Copy link
Contributor

Contact Details

No response

What happened?

It ranges from zero to pi:
angle
!

How to replicate?

View angle_dx. I did a grep for 'angle_dx' and can't find that it is used anywhere. Is it?

Relevant log or error output

No response

global attributes

No response

@kshedstrom kshedstrom added the bug Something isn't working label Jan 13, 2022
@jr3cermak
Copy link
Collaborator

jr3cermak commented Feb 3, 2022

This was apparently fixed by uncommenting a section of code shown below.

If converting a ROMS grid to a MOM6 grid:

angle = numpy.zeros(lat.shape)
angle2 = numpy.zeros(lat.shape)
# angle[:,1:-1] = numpy.arctan2( (lat[:,2:] - lat[:,:-2]) , ((lon[:,2:] - lon[:,:-2]) * cos_lat[:,1:-1]) )
# angle[:, 0 ] = numpy.arctan2( (lat[:, 1] - lat[:, 0 ]) , ((lon[:, 1] - lon[:, 0 ]) * cos_lat[:, 0 ]) )
# angle[:,-1 ] = numpy.arctan2( (lat[:,-1] - lat[:,-2 ]) , ((lon[:,-1] - lon[:,-2 ]) * cos_lat[:,-1 ]) )
lon = numpy.where(lon < 0., lon+360, lon)
angle2[:,1:-1] = numpy.arctan2( (lat[:,2:] - lat[:,:-2]) , ((lon[:,2:] - lon[:,:-2]) * cos_lat[:,1:-1]) )
angle2[:, 0 ] = numpy.arctan2( (lat[:, 1] - lat[:, 0 ]) , ((lon[:, 1] - lon[:, 0 ]) * cos_lat[:, 0 ]) )
angle2[:,-1 ] = numpy.arctan2( (lat[:,-1] - lat[:,-2 ]) , ((lon[:,-1] - lon[:,-2 ]) * cos_lat[:,-1 ]) )
self.mom6_grid['supergrid']['angle'][:,:] = numpy.maximum(angle, angle2)

Uncomment lines 751-753, regenerate the MOM6 grid and check the angles again. A future release will document an additional keyword argument to pass to trigger the alternate calculation of the angle. It is not clearly understood the conditions that require the alternate calculation of the angle. By default, the gridtools library will maintain its current behavior.

If creating a MOM6 grid for the first time, this code needs to be altered:

# Presize the angle_dx array
angle_dx = np.zeros(lat.shape)
angle2_dx = np.zeros(lat.shape)
# This was commented out in the original conversion code?
#angle_dx[:,1:-1] = np.arctan2( (lat[:,2:] - lat[:,:-2]) , ((lon[:,2:] - lon[:,:-2]) * cos_lat[:,1:-1]) )
#angle_dx[:, 0 ] = np.arctan2( (lat[:, 1] - lat[:, 0 ]) , ((lon[:, 1] - lon[:, 0 ]) * cos_lat[:, 0 ]) )
#angle_dx[:,-1 ] = np.arctan2( (lat[:,-1] - lat[:,-2 ]) , ((lon[:,-1] - lon[:,-2 ]) * cos_lat[:,-1 ]) )
# Fix lon so they are 0 to 360 for computation of angle_dx
lon = np.where(lon < 0., lon+360, lon)
angle2_dx[:,1:-1] = np.arctan2( (lat[:,2:] - lat[:,:-2]) , ((lon[:,2:] - lon[:,:-2]) * cos_lat[:,1:-1]) )
angle2_dx[:, 0 ] = np.arctan2( (lat[:, 1] - lat[:, 0 ]) , ((lon[:, 1] - lon[:, 0 ]) * cos_lat[:, 0 ]) )
angle2_dx[:,-1 ] = np.arctan2( (lat[:,-1] - lat[:,-2 ]) , ((lon[:,-1] - lon[:,-2 ]) * cos_lat[:,-1 ]) )
self.grid['angle_dx'] = (('nyp', 'nxp'), np.maximum(angle_dx, angle2_dx))

Uncomment lines 573-575.

This only applies to spherical grids.

@jr3cermak jr3cermak added the inwork should appear in a release soon label Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inwork should appear in a release soon
Projects
None yet
Development

No branches or pull requests

2 participants