Skip to content

Commit 94ffbc5

Browse files
author
Will Benfold
committed
Review fixes
1 parent 723fd6c commit 94ffbc5

File tree

6 files changed

+65
-49
lines changed

6 files changed

+65
-49
lines changed

lib/iris/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ def __init__(self, datum_support=False):
151151
.. note::
152152
153153
iris.FUTURE.example_future_flag does not exist. It is provided
154-
as an example because there are currently no flags in
155-
iris.Future.
154+
as an example.
156155
157156
"""
158-
# The flag 'example_future_flag' is provided as a future reference
159-
# for the structure of this class.
157+
# The flag 'example_future_flag' is provided as a reference for the
158+
# structure of this class.
159+
#
160+
# Note that self.__dict__ is used explicitly due to the manner in which
161+
# __setattr__ is overridden.
160162
#
161163
# self.__dict__['example_future_flag'] = example_future_flag
162164
self.__dict__["datum_support"] = datum_support
@@ -211,8 +213,7 @@ def context(self, **kwargs):
211213
.. note::
212214
213215
iris.FUTURE.example_future_flag does not exist and is
214-
provided only as an example since there are currently no
215-
flags in Future.
216+
provided only as an example.
216217
217218
"""
218219
# Save the current context

lib/iris/coord_systems.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def _pretty_attrs(self):
238238
self.longitude_of_prime_meridian,
239239
)
240240
)
241+
# An unknown crs datum will be treated as None
241242
if self.datum is not None and self.datum != "unknown":
242243
attrs.append(
243244
(
@@ -302,6 +303,7 @@ def __getattr__(self, name):
302303
return self._crs.ellipsoid.inverse_flattening
303304
if name == "datum":
304305
datum = self._crs.datum.name
306+
# An unknown crs datum will be treated as None
305307
if datum == "unknown":
306308
return None
307309
return datum

lib/iris/fileformats/_nc_load_rules/helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ def _get_ellipsoid(cf_grid_var):
264264
if proj_crs.datum is not None:
265265
datum = proj_crs.datum.name
266266

267+
# An unknown crs datum will be treated as None
267268
if datum == "unknown":
268269
datum = None
269270

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Copyright Iris contributors
2+
#
3+
# This file is part of Iris and is released under the LGPL license.
4+
# See COPYING and COPYING.LESSER in the root of the repository for full
5+
# licensing details.
6+
"""Integration tests for :class:`iris.coord_systems` datum suppport."""
7+
8+
# Import iris.tests first so that some things can be initialised before
9+
# importing anything else.
10+
import iris.tests as tests # isort:skip
11+
12+
import cartopy.crs as ccrs
13+
import numpy as np
14+
15+
from iris.coord_systems import GeogCS, LambertConformal
16+
17+
18+
class TestDatumTransformation(tests.IrisTest):
19+
def setUp(self):
20+
self.x_points = np.array([-1.5])
21+
self.y_points = np.array([50.5])
22+
23+
self.start_crs = ccrs.OSGB(False)
24+
25+
def test_transform_points_datum(self):
26+
27+
# Iris version
28+
wgs84 = GeogCS.from_datum("WGS84")
29+
iris_cs = LambertConformal(
30+
central_lat=54,
31+
central_lon=-4,
32+
secant_latitudes=[52, 56],
33+
ellipsoid=wgs84,
34+
)
35+
iris_cs_as_cartopy = iris_cs.as_cartopy_crs()
36+
37+
# Cartopy equivalent
38+
cartopy_cs = ccrs.LambertConformal(
39+
central_latitude=54,
40+
central_longitude=-4,
41+
standard_parallels=[52, 56],
42+
globe=ccrs.Globe("WGS84"),
43+
)
44+
45+
expected = cartopy_cs.transform_points(
46+
self.start_crs, self.x_points, self.y_points
47+
)
48+
49+
actual = iris_cs_as_cartopy.transform_points(
50+
self.start_crs, self.x_points, self.y_points
51+
)
52+
53+
self.assertArrayEqual(expected, actual)

lib/iris/tests/test_coordsystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def test_south_cutoff(self):
498498

499499
class Test_Datums(tests.IrisTest):
500500
def test_default_none(self):
501-
cs = GeogCS(6543210, 6500000)
501+
cs = GeogCS(6543210, 6500000) # Arbitrary radii
502502
cartopy_crs = cs.as_cartopy_crs()
503503
self.assertStringEqual(cartopy_crs.datum.name, "unknown")
504504

lib/iris/tests/unit/coord_systems/test_LambertConformal.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
# importing anything else.
1010
import iris.tests as tests # isort:skip
1111

12-
import cartopy.crs as ccrs
13-
import numpy as np
14-
15-
from iris.coord_systems import GeogCS, LambertConformal
12+
from iris.coord_systems import LambertConformal
1613

1714

1815
class Test_init_defaults(tests.IrisTest):
@@ -77,43 +74,5 @@ def test_optional_args_None(self):
7774
self._check_crs_defaults(crs)
7875

7976

80-
class TestDatumTransformation(tests.IrisTest):
81-
def setUp(self):
82-
self.x_points = np.array([-1.5])
83-
self.y_points = np.array([50.5])
84-
85-
self.start_crs = ccrs.OSGB(False)
86-
87-
def test_transform_points_datum(self):
88-
89-
# Iris version
90-
wgs84 = GeogCS.from_datum("WGS84")
91-
iris_cs = LambertConformal(
92-
central_lat=54,
93-
central_lon=-4,
94-
secant_latitudes=[52, 56],
95-
ellipsoid=wgs84,
96-
)
97-
iris_cs_as_cartopy = iris_cs.as_cartopy_crs()
98-
99-
# Cartopy equivalent
100-
cartopy_cs = ccrs.LambertConformal(
101-
central_latitude=54,
102-
central_longitude=-4,
103-
standard_parallels=[52, 56],
104-
globe=ccrs.Globe("WGS84"),
105-
)
106-
107-
expected = cartopy_cs.transform_points(
108-
self.start_crs, self.x_points, self.y_points
109-
)
110-
111-
actual = iris_cs_as_cartopy.transform_points(
112-
self.start_crs, self.x_points, self.y_points
113-
)
114-
115-
self.assertArrayEqual(expected, actual)
116-
117-
11877
if __name__ == "__main__":
11978
tests.main()

0 commit comments

Comments
 (0)