Skip to content

Commit 19f2e3c

Browse files
committed
Integration test for iris.plot.contour with 2d coords.
1 parent 2b02967 commit 19f2e3c

2 files changed

Lines changed: 556 additions & 523 deletions

File tree

lib/iris/tests/integration/plot/test_plot_2d_coords.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,16 @@
2626
# importing anything else
2727
import iris.tests as tests
2828

29-
import cartopy.crs as ccrs
29+
import numpy as np
30+
3031
import matplotlib.pyplot as plt
3132

33+
import cartopy.crs as ccrs
3234
import iris
35+
from iris.analysis.cartography import unrotate_pole
36+
from iris.cube import Cube
37+
from iris.coords import AuxCoord
38+
from iris.coord_systems import RotatedGeogCS
3339

3440
# Run tests in no graphics mode if matplotlib is not available.
3541
if tests.MPL_AVAILABLE:
@@ -63,5 +69,29 @@ def test_2d_coord_bounds_northpolarstereo(self):
6369
self.check_graphic()
6470

6571

72+
@tests.skip_plot
73+
@tests.skip_data
74+
class Test2dContour(tests.GraphicsTest):
75+
def test_2d_coords_contour(self):
76+
ny, nx = 4, 6
77+
x1 = np.linspace(-20, 70, nx)
78+
y1 = np.linspace(10, 60, ny)
79+
data = np.zeros((ny, nx))
80+
data.flat[:] = np.arange(nx * ny) % 7
81+
cube = Cube(data, long_name='Odd data')
82+
x2, y2 = np.meshgrid(x1, y1)
83+
true_lons, true_lats = unrotate_pole(x2, y2, -130., 77.)
84+
co_x = AuxCoord(true_lons, standard_name='longitude', units='degrees')
85+
co_y = AuxCoord(true_lats, standard_name='latitude', units='degrees')
86+
cube.add_aux_coord(co_y, (0, 1))
87+
cube.add_aux_coord(co_x, (0, 1))
88+
ax = plt.axes(projection=ccrs.PlateCarree())
89+
qplt.contourf(cube)
90+
ax.coastlines(color='red')
91+
ax.gridlines(draw_labels=True)
92+
ax.set_extent((0, 180, 0, 90))
93+
self.check_graphic()
94+
95+
6696
if __name__ == "__main__":
6797
tests.main()

0 commit comments

Comments
 (0)