Skip to content

Commit 945708e

Browse files
committed
Add regression test for spherical angleEdge in mesh conversion
Add a conversion test that runs `MpasMeshConverter.x` on the low-resolution QU test mesh, recomputes `angleEdge` in Python from spherical geometry, and verifies the converted mesh agrees to tight tolerance. This gives us a lightweight regression test for the polar `angleEdge` fix without introducing a dedicated C++ unit-test harness.
1 parent 118cf27 commit 945708e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

conda_package/tests/test_conversion.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env python
22

33
import matplotlib
4+
import numpy as np
45

56
from mpas_tools.io import write_netcdf
67
from mpas_tools.mesh.conversion import convert, cull, mask
8+
from mpas_tools.mesh.spherical import recompute_angle_edge
79

810
from .util import get_test_data_file
911

@@ -30,5 +32,21 @@ def test_conversion():
3032
write_netcdf(dsMask, 'antarctic_mask.nc')
3133

3234

35+
def test_conversion_angle_edge():
36+
ds_mesh = xarray.open_dataset(
37+
get_test_data_file('mesh.QU.1920km.151026.nc')
38+
)
39+
ds_mesh = convert(dsIn=ds_mesh)
40+
41+
angle_edge_python = recompute_angle_edge(ds_mesh)
42+
angle_diff = np.angle(
43+
np.exp(1j * (angle_edge_python.values - ds_mesh.angleEdge.values))
44+
)
45+
46+
assert np.all(np.isfinite(angle_diff))
47+
assert np.max(np.abs(angle_diff)) < 1.0e-10
48+
49+
3350
if __name__ == '__main__':
3451
test_conversion()
52+
test_conversion_angle_edge()

0 commit comments

Comments
 (0)