-
Notifications
You must be signed in to change notification settings - Fork 1
implicit shape #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: grib2_shape_of_earth
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # (C) British Crown Copyright 2014, Met Office | ||
| # (C) British Crown Copyright 2014 - 2015, Met Office | ||
| # | ||
| # This file is part of Iris. | ||
| # | ||
|
|
@@ -28,12 +28,12 @@ | |
|
|
||
| import numpy as np | ||
|
|
||
| from iris.coord_systems import GeogCS, TransverseMercator, OSGB | ||
| from iris.coord_systems import GeogCS, TransverseMercator, OSGB, RotatedGeogCS | ||
| from iris.exceptions import TranslationError | ||
| from iris.tests.unit.fileformats.grib.save_rules import GdtTestMixin | ||
|
|
||
| from iris.fileformats.grib._save_rules import shape_of_the_earth | ||
|
|
||
| from iris.fileformats.grib._save_rules import grid_definition_template_5 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function should not be imported in this test module as a test module for this function already exists. |
||
|
|
||
| class Test(tests.IrisTest, GdtTestMixin): | ||
| def setUp(self): | ||
|
|
@@ -57,7 +57,8 @@ def test_radius_of_earth_6367470(self): | |
| test_cube = self._make_test_cube(cs=cs) | ||
| shape_of_the_earth(test_cube, self.mock_grib) | ||
| self._check_key('shapeOfTheEarth', 0) | ||
| self._spherical_earth_test_common(radius) | ||
| self._check_key("scaleFactorOfRadiusOfSphericalEarth", 255) | ||
| self._check_key("scaledValueOfRadiusOfSphericalEarth", -1) | ||
|
|
||
| def test_radius_of_earth_6371229(self): | ||
| # Test setting shapeOfTheEarth = 6 | ||
|
|
@@ -66,7 +67,8 @@ def test_radius_of_earth_6371229(self): | |
| test_cube = self._make_test_cube(cs=cs) | ||
| shape_of_the_earth(test_cube, self.mock_grib) | ||
| self._check_key('shapeOfTheEarth', 6) | ||
| self._spherical_earth_test_common(radius) | ||
| self._check_key("scaleFactorOfRadiusOfSphericalEarth", 255) | ||
| self._check_key("scaledValueOfRadiusOfSphericalEarth", -1) | ||
|
|
||
| def test_spherical_earth(self): | ||
| # Test setting shapeOfTheEarth = 1 | ||
|
|
@@ -110,6 +112,28 @@ def test_TransverseMercator_spherical(self): | |
| self._check_key('shapeOfTheEarth', 1) | ||
| self._spherical_earth_test_common(radius) | ||
|
|
||
| def test__shape_of_earth_spherical(self): | ||
| cs = RotatedGeogCS(grid_north_pole_latitude=90.0, | ||
| grid_north_pole_longitude=0.0, | ||
| ellipsoid=GeogCS(52431.0)) | ||
| test_cube = self._make_test_cube(cs=cs) | ||
| grid_definition_template_5(test_cube, self.mock_grib) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per my above. This test should return the correct results without needing to be run through this function first, I believe. |
||
| self._check_key('shapeOfTheEarth', 1) | ||
| self._check_key('scaleFactorOfRadiusOfSphericalEarth', 0) | ||
| self._check_key('scaledValueOfRadiusOfSphericalEarth', 52431.0) | ||
|
|
||
| def test__shape_of_earth_flattened(self): | ||
| ellipsoid = GeogCS(semi_major_axis=1456.0, semi_minor_axis=1123.0) | ||
| cs = RotatedGeogCS(grid_north_pole_latitude=90.0, | ||
| grid_north_pole_longitude=0.0, | ||
| ellipsoid=ellipsoid) | ||
| test_cube = self._make_test_cube(cs=cs) | ||
| grid_definition_template_5(test_cube, self.mock_grib) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
| self._check_key('shapeOfTheEarth', 7) | ||
| self._check_key('scaleFactorOfEarthMajorAxis', 0) | ||
| self._check_key('scaledValueOfEarthMajorAxis', 1456.0) | ||
| self._check_key('scaleFactorOfEarthMinorAxis', 0) | ||
| self._check_key('scaledValueOfEarthMinorAxis', 1123.0) | ||
|
|
||
| if __name__ == "__main__": | ||
| tests.main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this tightening necessary? See SciTools#1491 (comment)