Skip to content

Commit

Permalink
Removed addition of period from wrap_lons.
Browse files Browse the repository at this point in the history
Updated affected tests using assertArrayAllClose following #3993.
  • Loading branch information
akuhnregnier committed Nov 11, 2021
1 parent 2dda3a9 commit 42330c2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 6 additions & 0 deletions docs/src/whatsnew/latest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,16 @@ This document explains the changes made to Iris for this release
#. `@rcomer`_ modified a NetCDF saver test to prevent it triggering a numpy
deprecation warning. (:issue:`4374`, :pull:`4376`)

#. `@akuhnregnier`_ removed addition of period from
:func:`~iris.analysis.cartography.wrap_lons` and updated affected tests
using assertArrayAllClose following :issue:`3993`.
(:pull:`3994`)

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
.. _@akuhnregnier: https://github.com/akuhnregnier
.. _@bsherratt: https://github.com/bsherratt
.. _@larsbarring: https://github.com/larsbarring
.. _@pdearnshaw: https://github.com/pdearnshaw
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 @@ -70,7 +70,7 @@ def wrap_lons(lons, base, period):
# It is important to use 64bit floating precision when changing a floats
# numbers range.
lons = lons.astype(np.float64)
return ((lons - base + period * 2) % period) + base
return ((lons - base) % period) + base


def unrotate_pole(rotated_lons, rotated_lats, pole_lon, pole_lat):
Expand Down
8 changes: 3 additions & 5 deletions lib/iris/tests/unit/cube/test_Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -1662,11 +1662,9 @@ def test_wrap_radians(self):
cube = create_cube(0, 360)
cube.coord("longitude").convert_units("radians")
result = cube.intersection(longitude=(-1, 0.5))
self.assertEqual(
result.coord("longitude").points[0], -0.99483767363676634
)
self.assertEqual(
result.coord("longitude").points[-1], 0.48869219055841207
self.assertArrayAllClose(
result.coord("longitude").points,
np.arange(-57, 29) * np.pi / 180
)
self.assertEqual(result.data[0, 0, 0], 303)
self.assertEqual(result.data[0, 0, -1], 28)
Expand Down

0 comments on commit 42330c2

Please sign in to comment.