Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyicon-fraser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fraser William Goldsworth
pyicon-fraser
Commits
957fcd9a
Commit
957fcd9a
authored
2 years ago
by
fraserwg
Browse files
Options
Downloads
Patches
Plain Diff
added tests for vector calculus functions
parent
a2a9ae30
Branches
revised-caroline
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#29426
passed
2 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyicon/pyicon_calc_xr.py
+5
-11
5 additions, 11 deletions
pyicon/pyicon_calc_xr.py
pyicon/tests/test_pyicon_calc_xr.py
+9
-0
9 additions, 0 deletions
pyicon/tests/test_pyicon_calc_xr.py
with
14 additions
and
11 deletions
pyicon/pyicon_calc_xr.py
+
5
−
11
View file @
957fcd9a
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
pyicon/tests/test_pyicon_calc_xr.py
+
9
−
0
View file @
957fcd9a
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment