Skip to content

Commit 6052fec

Browse files
committed
add test for plotting curvilinear datagrid
1 parent 9fba5a5 commit 6052fec

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/curvilinear-with-bounds.nc

2.09 MB
Binary file not shown.

tests/test_plotters.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,5 +1774,30 @@ def test_datagrid_3D_bounds():
17741774
assert abs(ymax - ymin - 52) < 2
17751775

17761776

1777+
def test_plot_curvilinear_datagrid(tmpdir):
1778+
"""Test if the there is no datagrid plotted over land
1779+
1780+
This implicitly checks, if grid cells at the boundary are warped correctly.
1781+
The file ``'curvilinear-with-bounds.nc'`` contains a variable on a
1782+
curvilinear grid that is only defined over the ocean (derived from MPI-OM).
1783+
Within this test, we focus on a region over land far away from
1784+
the ocean (Czech Republic) where there are no grid cells. If the datagrid
1785+
is plotted correctly, it should be all white.
1786+
"""
1787+
from matplotlib.testing.compare import compare_images
1788+
fname = os.path.join(bt.test_dir, 'curvilinear-with-bounds.nc')
1789+
# make a white plot without datagrid
1790+
kws = dict(plot=None, xgrid=False, ygrid=False, map_extent='Czech Republic')
1791+
with psy.plot.mapplot(fname, **kws) as sp:
1792+
sp.export(str(tmpdir / "ref.png")) # this is all white
1793+
# now draw the datagrid, it should still be empty (as the input file only
1794+
# defines the data over the ocean)
1795+
with psy.plot.mapplot(fname, datagrid='k-', **kws) as sp:
1796+
sp.export(str(tmpdir / "test.png")) # this should be all white, too
1797+
results = compare_images(
1798+
str(tmpdir / "ref.png"), str(tmpdir / "test.png"), tol=1)
1799+
assert results is None, results
1800+
1801+
17771802
if __name__ == '__main__':
17781803
bt.RefTestProgram()

0 commit comments

Comments
 (0)