Skip to content

Commit

Permalink
Use crs.globe in _crs_distance_differentials() (#4605)
Browse files Browse the repository at this point in the history
* Use crs.globe in _crs_distance_differentials(), add a relevant test, update whatsnew

* add a ref to the issue and PR
  • Loading branch information
dennissergeev authored Mar 2, 2022
1 parent 68ce060 commit 2b409c3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion docs/src/whatsnew/3.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ v3.2.1 |build_date| [unreleased]

🐛 **Bugs Fixed**

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

💼 **Internal**

Expand Down Expand Up @@ -388,6 +390,7 @@ v3.2.1 |build_date| [unreleased]
.. _@aaronspring: https://github.com/aaronspring
.. _@akuhnregnier: https://github.com/akuhnregnier
.. _@bsherratt: https://github.com/bsherratt
.. _@dennissergeev: https://github.com/dennissergeev
.. _@larsbarring: https://github.com/larsbarring
.. _@pdearnshaw: https://github.com/pdearnshaw
.. _@SimonPeatman: https://github.com/SimonPeatman
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/cartography.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ def _crs_distance_differentials(crs, x, y):
"""
# Make a true-latlon coordinate system for distance calculations.
crs_latlon = ccrs.Geodetic(globe=ccrs.Globe(ellipse="sphere"))
crs_latlon = ccrs.Geodetic(globe=crs.globe)
# Transform points to true-latlon (just to get the true latitudes).
_, true_lat = _transform_xy(crs, x, y, crs_latlon)
# Get coordinate differentials w.r.t. true-latlon.
Expand Down
13 changes: 13 additions & 0 deletions lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,5 +493,18 @@ def test_rotated_to_unrotated(self):
self.assertArrayAlmostEqual(res_y, y2d)


class TestNonEarthPlanet(tests.IrisTest):
def test_non_earth_semimajor_axis(self):
u, v = uv_cubes()
u.coord("grid_latitude").coord_system = iris.coord_systems.GeogCS(123)
u.coord("grid_longitude").coord_system = iris.coord_systems.GeogCS(123)
v.coord("grid_latitude").coord_system = iris.coord_systems.GeogCS(123)
v.coord("grid_longitude").coord_system = iris.coord_systems.GeogCS(123)
other_cs = iris.coord_systems.RotatedGeogCS(
0, 0, ellipsoid=iris.coord_systems.GeogCS(123)
)
rotate_winds(u, v, other_cs)


if __name__ == "__main__":
tests.main()

0 comments on commit 2b409c3

Please sign in to comment.