forked from SciTools/iris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Albers Equal Area Projection and some test as per SciTools#2496
- Loading branch information
Showing
5 changed files
with
306 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# (C) British Crown Copyright 2015 - 2018, Met Office | ||
# | ||
# This file is part of Iris. | ||
# | ||
# Iris is free software: you can redistribute it and/or modify it under | ||
# the terms of the GNU Lesser General Public License as published by the | ||
# Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Iris is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with Iris. If not, see <http://www.gnu.org/licenses/>. | ||
""" | ||
Unit tests for the :class:`iris.coord_systems.AlbersEqualArea` class. | ||
""" | ||
|
||
from __future__ import (absolute_import, division, print_function) | ||
from six.moves import (filter, input, map, range, zip) # noqa | ||
|
||
# Import iris.tests first so that some things can be initialised before | ||
# importing anything else. | ||
import iris.tests as tests | ||
|
||
import cartopy.crs as ccrs | ||
from iris.coord_systems import GeogCS, AlbersEqualArea | ||
|
||
|
||
class Test_as_cartopy_crs(tests.IrisTest): | ||
def setUp(self): | ||
self.latitude_of_projection_origin = 0.0 | ||
self.longitude_of_central_meridian = 0.0 | ||
self.semi_major_axis = 6377563.396 | ||
self.semi_minor_axis = 6356256.909 | ||
self.false_easting = 0.0 | ||
self.false_northing = 0.0 | ||
self.standard_parallels = (-18., -36.) | ||
self.ellipsoid = GeogCS(self.semi_major_axis, self.semi_minor_axis) | ||
self.aea_cs = AlbersEqualArea( | ||
self.latitude_of_projection_origin, | ||
self.longitude_of_central_meridian, | ||
self.false_easting, | ||
self.false_northing, | ||
self.standard_parallels, | ||
ellipsoid=self.ellipsoid) | ||
|
||
def test_crs_creation(self): | ||
res = self.aea_cs.as_cartopy_crs() | ||
globe = ccrs.Globe(semimajor_axis=self.semi_major_axis, | ||
semiminor_axis=self.semi_minor_axis, | ||
ellipse=None) | ||
expected = ccrs.AlbersEqualArea( | ||
self.longitude_of_central_meridian, | ||
self.latitude_of_projection_origin, | ||
self.false_easting, | ||
self.false_northing, | ||
self.standard_parallels, | ||
globe=globe) | ||
self.assertEqual(res, expected) | ||
|
||
|
||
class Test_as_cartopy_projection(tests.IrisTest): | ||
def setUp(self): | ||
self.latitude_of_projection_origin = 0.0 | ||
self.longitude_of_central_meridian = 0.0 | ||
self.semi_major_axis = 6377563.396 | ||
self.semi_minor_axis = 6356256.909 | ||
self.false_easting = 0.0 | ||
self.false_northing = 0.0 | ||
self.ellipsoid = GeogCS(self.semi_major_axis, self.semi_minor_axis) | ||
self.aea_cs = AlbersEqualArea( | ||
self.latitude_of_projection_origin, | ||
self.longitude_of_central_meridian, | ||
self.false_easting, | ||
self.false_northing, | ||
self.standard_parallels, | ||
ellipsoid=self.ellipsoid) | ||
|
||
def test_projection_creation(self): | ||
res = self.aea_cs.as_cartopy_projection() | ||
globe = ccrs.Globe(semimajor_axis=self.semi_major_axis, | ||
semiminor_axis=self.semi_minor_axis, | ||
ellipse=None) | ||
expected = ccrs.AlbersEqualArea( | ||
self.latitude_of_projection_origin, | ||
self.longitude_of_central_meridian, | ||
self.false_easting, | ||
self.false_northing, | ||
self.standard_parallels, | ||
globe=globe) | ||
self.assertEqual(res, expected) | ||
|
||
|
||
if __name__ == '__main__': | ||
tests.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters