|
26 | 26 | # importing anything else |
27 | 27 | import iris.tests as tests |
28 | 28 |
|
29 | | -import cartopy.crs as ccrs |
| 29 | +import numpy as np |
| 30 | + |
30 | 31 | import matplotlib.pyplot as plt |
31 | 32 |
|
| 33 | +import cartopy.crs as ccrs |
32 | 34 | 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 |
33 | 39 |
|
34 | 40 | # Run tests in no graphics mode if matplotlib is not available. |
35 | 41 | if tests.MPL_AVAILABLE: |
@@ -63,5 +69,29 @@ def test_2d_coord_bounds_northpolarstereo(self): |
63 | 69 | self.check_graphic() |
64 | 70 |
|
65 | 71 |
|
| 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 | + |
66 | 96 | if __name__ == "__main__": |
67 | 97 | tests.main() |
0 commit comments