Skip to content
Snippets Groups Projects
Commit 957fcd9a authored by fraserwg's avatar fraserwg
Browse files

added tests for vector calculus functions

parent a2a9ae30
No related branches found
No related tags found
1 merge request!11Updates to calculate_xr and addition of tests
......@@ -471,28 +471,22 @@ def xr_calc_curl(ds_IcD, vector, rot_coeff=None):
Dataarray containing vector variable on cell edges.
rot_coeff : xr.DataArray or None
Array with dims ("vertex", "ne")
Array containing dims ("vertex", "ne")
Returns
-------
curl_vec : xr.DataArray
vertical component of the curl of the vector
vertical component of the curl of the vector defined on vertex points
Notes
-----
We calculate the curl through the use of Stokes' theorem (technically
Green's theorem as we're working with 2D velocity!), however, only the
vertical component is calculated. A similar procedure can be used to
calculate the horizontal components of the curl (oriented along cell edges
and defined at intermediate Z levels.) This will be implemented in a future
release.
We calculate the curl through the use of Stokes'/Green's theorem
Green's theorem as we're working with 2D velocity!), A similar procedure can be used to calculate the horizontal components of the curl (oriented
along cell edges and defined at intermediate Z levels.) This will be implemented in a future release.
If you're using this function on large datasets, performance gains may be
made if you play around with the dimension order.
When applying to a gradient we get identically zero. Should add this as a
test to the testing suite
"""
assert "edge" in vector.dims
......
......@@ -86,3 +86,12 @@ def test_xr_crop_tgrid(tgrid, request):
assert cropped_tgrid["ireg_v"].sum() == 135385
assert cropped_tgrid["ireg_v"].prod() == -1427286351937536000
def test_nabla_funcs(processed_tgrid):
# Want to check curl of a gradient
gradient = pyic.xr_calc_grad(processed_tgrid, processed_tgrid["clon"])
curl_of_grad = pyic.xr_calc_curl(processed_tgrid, gradient)
assert np.allclose(curl_of_grad, 0)
# Should include other tests in the future if any refactoring is done
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment