-
Notifications
You must be signed in to change notification settings - Fork 24
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 B-grid vector Laplacian #128
Changes from 6 commits
7c77bd6
bd6ce70
219d681
5aed547
6098884
3c423f9
61323fd
a715297
cc8f9b1
0fb2314
c8d3c8b
d2e01ac
562f804
072dab8
8cff179
0179806
93d2bcc
bbb2d4f
e2799b0
5c0f495
19f0913
57fd8ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ flake8-print | |
interrogate | ||
isort | ||
nbsphinx | ||
netcdf4 | ||
pooch | ||
pre-commit | ||
pylint | ||
pytest | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
required_grid_vars, | ||
) | ||
|
||
from .conftest import spherical_geometry | ||
|
||
paigem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_conservation(scalar_grid_type_data_and_extra_kwargs): | ||
"""This test checks that scalar Laplacians preserve the area integral.""" | ||
|
@@ -229,15 +231,15 @@ def test_tripolar_exchanges(tripolar_grid_type_data_and_extra_kwargs): | |
#################### Vector Laplacian tests ######################################## | ||
|
||
|
||
def test_conservation_under_solid_body_rotation( | ||
vector_grid_type_data_and_extra_kwargs, spherical_geometry | ||
): | ||
def test_conservation_under_solid_body_rotation(vector_grid_type_data_and_extra_kwargs): | ||
paigem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""This test checks that vector Laplacians are invariant under solid body rotations: | ||
a corollary of conserving angular momentum.""" | ||
|
||
grid_type, _, extra_kwargs = vector_grid_type_data_and_extra_kwargs | ||
grid_type, (u, _), extra_kwargs = vector_grid_type_data_and_extra_kwargs | ||
paigem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_, geolat_u, _, _ = spherical_geometry | ||
ny, nx = u.shape | ||
paigem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
_, geolat_u, _, _ = spherical_geometry(ny, nx) | ||
paigem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# u = cos(lat), v=0 is solid body rotation | ||
data_u = np.cos(geolat_u / 360 * 2 * np.pi) | ||
data_v = np.zeros_like(data_u) | ||
|
@@ -255,16 +257,8 @@ def test_zero_area(vector_grid_type_data_and_extra_kwargs): | |
|
||
grid_type, (data_u, data_v), extra_kwargs = vector_grid_type_data_and_extra_kwargs | ||
|
||
test_kwargs = copy.deepcopy(extra_kwargs) | ||
# fill area_u, area_v with zeros over land; e.g., you will find that in MOM6 model output | ||
test_kwargs["area_u"] = np.where( | ||
extra_kwargs["wet_mask_t"] > 0, test_kwargs["area_u"], 0 | ||
) | ||
test_kwargs["area_v"] = np.where( | ||
extra_kwargs["wet_mask_t"] > 0, test_kwargs["area_v"], 0 | ||
) | ||
Comment on lines
-277
to
-284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NoraLoose - I took this block and moved it into the fixture for the mom vector grid data. Do you see any problem with that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it fits better in the fixture for the mom vector grid data (where you have moved it). The solid body rotation test itself should not need |
||
LaplacianClass = ALL_KERNELS[grid_type] | ||
laplacian = LaplacianClass(**test_kwargs) | ||
laplacian = LaplacianClass(**extra_kwargs) | ||
res_u, res_v = laplacian(data_u, data_v) | ||
assert not np.any(np.isinf(res_u)) | ||
assert not np.any(np.isnan(res_u)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need these packages for the testing framework?