2828
2929import numpy as np
3030
31- from iris .coord_systems import GeogCS , TransverseMercator , OSGB
31+ from iris .coord_systems import GeogCS , TransverseMercator , OSGB , RotatedGeogCS
3232from iris .exceptions import TranslationError
3333from iris .tests .unit .fileformats .grib .save_rules import GdtTestMixin
3434
3535from iris .fileformats .grib ._save_rules import shape_of_the_earth
36-
36+ from iris . fileformats . grib . _save_rules import grid_definition_template_5
3737
3838class Test (tests .IrisTest , GdtTestMixin ):
3939 def setUp (self ):
@@ -57,7 +57,8 @@ def test_radius_of_earth_6367470(self):
5757 test_cube = self ._make_test_cube (cs = cs )
5858 shape_of_the_earth (test_cube , self .mock_grib )
5959 self ._check_key ('shapeOfTheEarth' , 0 )
60- self ._spherical_earth_test_common (radius )
60+ self ._check_key ("scaleFactorOfRadiusOfSphericalEarth" , 255 )
61+ self ._check_key ("scaledValueOfRadiusOfSphericalEarth" , - 1 )
6162
6263 def test_radius_of_earth_6371229 (self ):
6364 # Test setting shapeOfTheEarth = 6
@@ -66,7 +67,8 @@ def test_radius_of_earth_6371229(self):
6667 test_cube = self ._make_test_cube (cs = cs )
6768 shape_of_the_earth (test_cube , self .mock_grib )
6869 self ._check_key ('shapeOfTheEarth' , 6 )
69- self ._spherical_earth_test_common (radius )
70+ self ._check_key ("scaleFactorOfRadiusOfSphericalEarth" , 255 )
71+ self ._check_key ("scaledValueOfRadiusOfSphericalEarth" , - 1 )
7072
7173 def test_spherical_earth (self ):
7274 # Test setting shapeOfTheEarth = 1
@@ -110,6 +112,28 @@ def test_TransverseMercator_spherical(self):
110112 self ._check_key ('shapeOfTheEarth' , 1 )
111113 self ._spherical_earth_test_common (radius )
112114
115+ def test__shape_of_earth_spherical (self ):
116+ cs = RotatedGeogCS (grid_north_pole_latitude = 90.0 ,
117+ grid_north_pole_longitude = 0.0 ,
118+ ellipsoid = GeogCS (52431.0 ))
119+ test_cube = self ._make_test_cube (cs = cs )
120+ grid_definition_template_5 (test_cube , self .mock_grib )
121+ self ._check_key ('shapeOfTheEarth' , 1 )
122+ self ._check_key ('scaleFactorOfRadiusOfSphericalEarth' , 0 )
123+ self ._check_key ('scaledValueOfRadiusOfSphericalEarth' , 52431.0 )
124+
125+ def test__shape_of_earth_flattened (self ):
126+ ellipsoid = GeogCS (semi_major_axis = 1456.0 , semi_minor_axis = 1123.0 )
127+ cs = RotatedGeogCS (grid_north_pole_latitude = 90.0 ,
128+ grid_north_pole_longitude = 0.0 ,
129+ ellipsoid = ellipsoid )
130+ test_cube = self ._make_test_cube (cs = cs )
131+ grid_definition_template_5 (test_cube , self .mock_grib )
132+ self ._check_key ('shapeOfTheEarth' , 7 )
133+ self ._check_key ('scaleFactorOfEarthMajorAxis' , 0 )
134+ self ._check_key ('scaledValueOfEarthMajorAxis' , 1456.0 )
135+ self ._check_key ('scaleFactorOfEarthMinorAxis' , 0 )
136+ self ._check_key ('scaledValueOfEarthMinorAxis' , 1123.0 )
113137
114138if __name__ == "__main__" :
115139 tests .main ()
0 commit comments