-
Notifications
You must be signed in to change notification settings - Fork 301
Full-featured Mercator coord system #3041
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
71fde3d
Full-featured Mercator CS
DPeterK 793861c
Update CML test result
DPeterK d3303a4
Drop extraneous kwargs
DPeterK 515fdc5
Reinstate inline docstring comments
DPeterK adbcaa7
Whatsnew updated
DPeterK 6a7c841
Rename kwarg to `standard_parallel`
DPeterK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| <?xml version="1.0" ?> | ||
| <mercator ellipsoid="GeogCS(semi_major_axis=6377563.396, semi_minor_axis=6356256.909)" longitude_of_projection_origin="90.0"/> | ||
| <mercator ellipsoid="GeogCS(semi_major_axis=6377563.396, semi_minor_axis=6356256.909)" longitude_of_projection_origin="90.0" standard_parallel="0.0"/> |
This file contains hidden or 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 hidden or 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 hidden or 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,109 @@ | ||
| # (C) British Crown Copyright 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.Mercator` 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, Mercator | ||
|
|
||
|
|
||
| class Test_Mercator__basics(tests.IrisTest): | ||
| def setUp(self): | ||
| self.tm = Mercator(longitude_of_projection_origin=90.0, | ||
| ellipsoid=GeogCS(6377563.396, 6356256.909)) | ||
|
|
||
| def test_construction(self): | ||
| self.assertXMLElement(self.tm, ("coord_systems", "Mercator.xml")) | ||
|
|
||
| def test_repr(self): | ||
| expected = ("Mercator(longitude_of_projection_origin=90.0, " | ||
| "ellipsoid=GeogCS(semi_major_axis=6377563.396, " | ||
| "semi_minor_axis=6356256.909), " | ||
| "standard_parallel=0.0)") | ||
| self.assertEqual(expected, repr(self.tm)) | ||
|
|
||
|
|
||
| class Test_Mercator__as_cartopy_crs(tests.IrisTest): | ||
| def test_simple(self): | ||
| # Check that a projection set up with all the defaults is correctly | ||
| # converted to a cartopy CRS. | ||
| merc_cs = Mercator() | ||
| res = merc_cs.as_cartopy_crs() | ||
| expected = ccrs.Mercator(globe=ccrs.Globe()) | ||
| self.assertEqual(res, expected) | ||
|
|
||
| def test_extra_kwargs(self): | ||
| # Check that a projection with non-default values is correctly | ||
| # converted to a cartopy CRS. | ||
| longitude_of_projection_origin = 90.0 | ||
| true_scale_lat = 14.0 | ||
| ellipsoid = GeogCS(semi_major_axis=6377563.396, | ||
| semi_minor_axis=6356256.909) | ||
|
|
||
| merc_cs = Mercator( | ||
| longitude_of_projection_origin, | ||
| ellipsoid=ellipsoid, | ||
| standard_parallel=true_scale_lat) | ||
|
|
||
| expected = ccrs.Mercator( | ||
| central_longitude=longitude_of_projection_origin, | ||
| globe=ccrs.Globe(semimajor_axis=6377563.396, | ||
| semiminor_axis=6356256.909, ellipse=None), | ||
| latitude_true_scale=true_scale_lat) | ||
|
|
||
| res = merc_cs.as_cartopy_crs() | ||
| self.assertEqual(res, expected) | ||
|
|
||
|
|
||
| class Test_as_cartopy_projection(tests.IrisTest): | ||
| def test_simple(self): | ||
| # Check that a projection set up with all the defaults is correctly | ||
| # converted to a cartopy projection. | ||
| merc_cs = Mercator() | ||
| res = merc_cs.as_cartopy_projection() | ||
| expected = ccrs.Mercator(globe=ccrs.Globe()) | ||
| self.assertEqual(res, expected) | ||
|
|
||
| def test_extra_kwargs(self): | ||
| longitude_of_projection_origin = 90.0 | ||
| true_scale_lat = 14.0 | ||
| ellipsoid = GeogCS(semi_major_axis=6377563.396, | ||
| semi_minor_axis=6356256.909) | ||
|
|
||
| merc_cs = Mercator( | ||
| longitude_of_projection_origin, | ||
| ellipsoid=ellipsoid, | ||
| standard_parallel=true_scale_lat) | ||
|
|
||
| expected = ccrs.Mercator( | ||
| central_longitude=longitude_of_projection_origin, | ||
| globe=ccrs.Globe(semimajor_axis=6377563.396, | ||
| semiminor_axis=6356256.909, ellipse=None), | ||
| latitude_true_scale=true_scale_lat) | ||
|
|
||
| res = merc_cs.as_cartopy_projection() | ||
| self.assertEqual(res, expected) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| tests.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. These are some really old tests (and really old-school style). 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa 😨