diff --git a/pyicon/pyicon_calc_xr.py b/pyicon/pyicon_calc_xr.py index afd12af67396a98fb2ea9e4b6e4d996eccce77df..26bb740a2d838d84e3d0adcb95a27f3557b65071 100644 --- a/pyicon/pyicon_calc_xr.py +++ b/pyicon/pyicon_calc_xr.py @@ -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 diff --git a/pyicon/tests/test_pyicon_calc_xr.py b/pyicon/tests/test_pyicon_calc_xr.py index c8eb7be64e2b8e9499dfeeb1d8eb9e4e18d9f065..0121600c8bcc0a4a882e1155d58f047ff41c4f10 100644 --- a/pyicon/tests/test_pyicon_calc_xr.py +++ b/pyicon/tests/test_pyicon_calc_xr.py @@ -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