|
16 | 16 |
|
17 | 17 | import iris.coords |
18 | 18 | from iris.coord_systems import GeogCS, LambertAzimuthalEqualArea |
| 19 | +from iris.exceptions import TranslationError |
19 | 20 |
|
20 | 21 | from iris_grib._save_rules import ( |
21 | 22 | grid_definition_template_140 as grid_definition_template, |
@@ -53,9 +54,11 @@ def _make_test_cube(self, cs=None, x_points=None, y_points=None): |
53 | 54 | test_cube.add_dim_coord(x_coord, 1) |
54 | 55 | return test_cube |
55 | 56 |
|
56 | | - def _default_coord_system(self): |
| 57 | + def _default_coord_system(self, false_easting=0, false_northing=0): |
57 | 58 | return LambertAzimuthalEqualArea(latitude_of_projection_origin=54.9, |
58 | 59 | longitude_of_projection_origin=-2.5, |
| 60 | + false_easting=false_easting, |
| 61 | + false_northing=false_northing, |
59 | 62 | ellipsoid=self.default_ellipsoid) |
60 | 63 |
|
61 | 64 | def test__template_number(self): |
@@ -103,6 +106,28 @@ def test__scanmode_reverse(self): |
103 | 106 | self._check_key('iScansPositively', 0) |
104 | 107 | self._check_key('jScansPositively', 1) |
105 | 108 |
|
| 109 | + def __fail_false_easting_northing(self, false_easting, false_northing): |
| 110 | + cs = self._default_coord_system(false_easting=false_easting, |
| 111 | + false_northing=false_northing) |
| 112 | + test_cube = self._make_test_cube(cs=cs) |
| 113 | + msg = ('non zero false easting ({:.2f}) or ' |
| 114 | + 'non zero false northing ({:.2f})' |
| 115 | + '; unsupported by GRIB Template 3.140' |
| 116 | + '.').format(false_easting, false_northing) |
| 117 | + with self.assertRaisesRegex( |
| 118 | + TranslationError, |
| 119 | + rf"{msg}"): |
| 120 | + grid_definition_template(test_cube, self.mock_grib) |
| 121 | + |
| 122 | + def test__fail_false_easting(self): |
| 123 | + self.__fail_false_easting_northing(10, 0) |
| 124 | + |
| 125 | + def test__fail_false_northing(self): |
| 126 | + self.__fail_false_easting_northing(0, 10) |
| 127 | + |
| 128 | + def test__fail_false_easting_northing(self): |
| 129 | + self.__fail_false_easting_northing(10, 10) |
| 130 | + |
106 | 131 |
|
107 | 132 | if __name__ == "__main__": |
108 | 133 | tests.main() |
0 commit comments