From 930f3bcb8afb420ec180cd1fe7fa7c666cc76bf8 Mon Sep 17 00:00:00 2001 From: Lars Barring Date: Tue, 12 Oct 2021 11:19:25 +0200 Subject: [PATCH 1/3] Accept inverse_flattening = 0 for spherical ellipsoid (closes #4146) --- docs/src/whatsnew/latest.rst | 4 ++++ lib/iris/coord_systems.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index 4548e334fa..892e08fd3f 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -86,6 +86,10 @@ This document explains the changes made to Iris for this release "Cube names differ: var1 != var1" if var1 appears multiple times in the list (:issue:`4342`, :pull:`4345`) +#. `@larsbarring`_ fixed :class:`~iris.coord_systems.GeoCS` to handle spherical ellipsoid + parameter inverse_flattening = 0 (:issue: `4146`, :pull:`4348`) + + 💣 Incompatible Changes ======================= diff --git a/lib/iris/coord_systems.py b/lib/iris/coord_systems.py index 4649204205..300f49014a 100644 --- a/lib/iris/coord_systems.py +++ b/lib/iris/coord_systems.py @@ -196,7 +196,7 @@ def __init__( # Perfect sphere (semi_major_axis only)? (1 0 0) elif semi_major_axis is not None and ( - semi_minor_axis is None and inverse_flattening is None + semi_minor_axis is None and not inverse_flattening ): semi_minor_axis = semi_major_axis inverse_flattening = 0.0 From f129e6149e0128af00545856dfeff340f2d784c3 Mon Sep 17 00:00:00 2001 From: James Penn Date: Wed, 13 Oct 2021 14:00:13 +0000 Subject: [PATCH 2/3] Added test --- lib/iris/tests/unit/coord_systems/test_GeogCS.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/iris/tests/unit/coord_systems/test_GeogCS.py b/lib/iris/tests/unit/coord_systems/test_GeogCS.py index 20ecb724e1..af17181ce3 100644 --- a/lib/iris/tests/unit/coord_systems/test_GeogCS.py +++ b/lib/iris/tests/unit/coord_systems/test_GeogCS.py @@ -46,6 +46,16 @@ def test_optional_args_None(self): ) self._check_crs_defaults(crs) + def test_zero_inverse_flattening_on_perfect_sphere(self): + # allow inverse_flattening to be 0 for a perfect sphere + # i.e. semi-major axis defined, semi-minor is None. + crs = GeogCS( + 1.0, + semi_minor_axis=None, + inverse_flattening=0.0, + longitude_of_prime_meridian=None, + ) + self._check_crs_defaults(crs) if __name__ == "__main__": tests.main() From 34b42ab5934c26e2dafcbaf4b0cd95ede53415e5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Oct 2021 15:06:04 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- lib/iris/tests/unit/coord_systems/test_GeogCS.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/iris/tests/unit/coord_systems/test_GeogCS.py b/lib/iris/tests/unit/coord_systems/test_GeogCS.py index af17181ce3..f3f9531dbb 100644 --- a/lib/iris/tests/unit/coord_systems/test_GeogCS.py +++ b/lib/iris/tests/unit/coord_systems/test_GeogCS.py @@ -57,5 +57,6 @@ def test_zero_inverse_flattening_on_perfect_sphere(self): ) self._check_crs_defaults(crs) + if __name__ == "__main__": tests.main()