Skip to content

Commit 2b409c3

Browse files
Use crs.globe in _crs_distance_differentials() (#4605)
* Use crs.globe in _crs_distance_differentials(), add a relevant test, update whatsnew * add a ref to the issue and PR
1 parent 68ce060 commit 2b409c3

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/src/whatsnew/3.2.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ v3.2.1 |build_date| [unreleased]
3838

3939
🐛 **Bugs Fixed**
4040

41-
#. N/A
41+
#. `@dennissergeev`_ changed _crs_distance_differentials() so that it uses the `Globe`
42+
attribute from a given CRS instead of creating a new `ccrs.Globe()` object.
43+
Iris can now handle non-Earth semi-major axes, as discussed in :issue:`4582` (:pull:`4605`).
4244

4345
💼 **Internal**
4446

@@ -388,6 +390,7 @@ v3.2.1 |build_date| [unreleased]
388390
.. _@aaronspring: https://github.com/aaronspring
389391
.. _@akuhnregnier: https://github.com/akuhnregnier
390392
.. _@bsherratt: https://github.com/bsherratt
393+
.. _@dennissergeev: https://github.com/dennissergeev
391394
.. _@larsbarring: https://github.com/larsbarring
392395
.. _@pdearnshaw: https://github.com/pdearnshaw
393396
.. _@SimonPeatman: https://github.com/SimonPeatman

lib/iris/analysis/cartography.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ def _crs_distance_differentials(crs, x, y):
927927
928928
"""
929929
# Make a true-latlon coordinate system for distance calculations.
930-
crs_latlon = ccrs.Geodetic(globe=ccrs.Globe(ellipse="sphere"))
930+
crs_latlon = ccrs.Geodetic(globe=crs.globe)
931931
# Transform points to true-latlon (just to get the true latitudes).
932932
_, true_lat = _transform_xy(crs, x, y, crs_latlon)
933933
# Get coordinate differentials w.r.t. true-latlon.

lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,5 +493,18 @@ def test_rotated_to_unrotated(self):
493493
self.assertArrayAlmostEqual(res_y, y2d)
494494

495495

496+
class TestNonEarthPlanet(tests.IrisTest):
497+
def test_non_earth_semimajor_axis(self):
498+
u, v = uv_cubes()
499+
u.coord("grid_latitude").coord_system = iris.coord_systems.GeogCS(123)
500+
u.coord("grid_longitude").coord_system = iris.coord_systems.GeogCS(123)
501+
v.coord("grid_latitude").coord_system = iris.coord_systems.GeogCS(123)
502+
v.coord("grid_longitude").coord_system = iris.coord_systems.GeogCS(123)
503+
other_cs = iris.coord_systems.RotatedGeogCS(
504+
0, 0, ellipsoid=iris.coord_systems.GeogCS(123)
505+
)
506+
rotate_winds(u, v, other_cs)
507+
508+
496509
if __name__ == "__main__":
497510
tests.main()

0 commit comments

Comments
 (0)