Skip to content
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

Implement Projection classes to encapsulate arguments #379

Draft
wants to merge 31 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c969bb
Initial commit for pygmt/projection.py; Contains a generic design/lay…
Nov 17, 2019
16819cc
Updated docstrings for class projection definitions.
Nov 18, 2019
979d057
Initial run of Black to reformat code.
Nov 18, 2019
c1161a3
Renamed lon0 to central_longitude and lat0 to central_latitude.
Nov 19, 2019
29e263d
Added the attribute to give meaning to the width argument (inches or…
Nov 19, 2019
129ae99
Updated example, and cleaned up docstring for unit description.
Nov 19, 2019
adef7ad
Removed center attribute from printed example.
Dec 7, 2019
97c836b
Specifying the projection code directly in the attrib creation, rathe…
Dec 7, 2019
a414f7e
Added the miscellaneous projections group; Mollweide, Sinusoidal, Eck…
Dec 7, 2019
c7ee1a2
Capitalised projection names where required, eg when named after the …
Dec 7, 2019
db7aca6
Added the Polyconic projection.
Dec 7, 2019
825cd66
Added the Miller and oblique 1, 2, 3 projections.
Dec 7, 2019
acaca7d
Added the Transverse Mercator and Universal Transverse Mercator Proje…
Dec 7, 2019
919102d
Added the equidistant cylindrical projection.
Dec 7, 2019
f5897a8
Fixed as per @leouieda suggestions.
Dec 7, 2019
7abe416
Missed one of the fixes as suggested by @leouieda
Dec 8, 2019
45abd59
Changed the default unit of inches to centimetres.
Dec 8, 2019
b9997c1
Removed superfluous comments regarding the private variables.
Dec 8, 2019
f92c7d1
Run Black formatting.
Dec 8, 2019
4161f9e
Update keyword args for the GeneralPerspective projection.
Jan 14, 2020
968b2cd
Initial unittests for the projection class configurations.
Jan 14, 2020
a77fd13
Added Polar and Linear projections. General cleanup.
Dec 18, 2022
d030593
Apply black formatting
Dec 18, 2022
cd38f61
Various reconfigs; some projs have updated, updated some that specifi…
Dec 19, 2022
4793155
Added a bunch more projections to the test suite.
Dec 19, 2022
0f24da2
Reworked the cylindrical projections to cater for the default and non…
Dec 20, 2022
a43d4c8
Added tests for the 3 oblique mercator projection options.
Dec 20, 2022
f39053a
Added tests for UTM, mercator, equidistant cylindrical. Minor additio…
Dec 21, 2022
f386b09
Applied black formatting.
Dec 21, 2022
8995715
Merge branch 'main' into proj-classes
Dec 23, 2022
20693e7
Caught test fails and updated.
Dec 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added tests for the 3 oblique mercator projection options.
  • Loading branch information
Josh Sixsmith committed Dec 20, 2022
commit a43d4c8940b90955f5da4707039cf9064aee167d
93 changes: 93 additions & 0 deletions pygmt/tests/test_projections.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,99 @@ def test_string_conversion2(self):
assert str(self.prj2) == "J12c"


class TestObliqueMercator1:
"""
Tests for the Oblique Mercator projection (option 1).
"""
prj1 = projection.ObliqueMercator1(
central_longitude=145, central_latitude=-35, azimuth=45, width=12
)
prj2 = projection.ObliqueMercator1(
central_longitude=145, central_latitude=-35, azimuth=45, allow_southern_hemisphere=True, width=12
)
prj3 = projection.ObliqueMercator1(
central_longitude=145, central_latitude=-35, azimuth=45, align_yaxis=True, width=12
)

def test_default_unit(self):
"Test the default value for the figure units"
assert self.prj1.unit == "c"

def test_string_conversion1(self):
"Test the string representation of the projection class"
assert str(self.prj1) == "O145/-35/45/12c"

def test_string_conversion2(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "OA145/-35/45/12c"

def test_string_conversion3(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "O145/-35/45/12c+v"


class TestObliqueMercator2:
"""
Tests for the Oblique Mercator projection (option 2).
"""
prj1 = projection.ObliqueMercator2(
central_longitude=145, central_latitude=-35, oblique_longitude=110, oblique_latitude=-20, width=12
)
prj2 = projection.ObliqueMercator2(
central_longitude=145, central_latitude=-35, oblique_longitude=110, oblique_latitude=-20, allow_southern_hemisphere=True, width=12
)
prj3 = projection.ObliqueMercator2(
central_longitude=145, central_latitude=-35, oblique_longitude=110, oblique_latitude=-20, align_yaxis=True, width=12
)

def test_default_unit(self):
"Test the default value for the figure units"
assert self.prj1.unit == "c"

def test_string_conversion1(self):
"Test the string representation of the projection class"
assert str(self.prj1) == "O145/-35/110/-20/12c"

def test_string_conversion2(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "OB145/-35/110/-20/12c"

def test_string_conversion3(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "O145/-35/110/-20/12c+v"


class TestObliqueMercator3:
"""
Tests for the Oblique Mercator projection (option 3).
"""
prj1 = projection.ObliqueMercator3(
central_longitude=145, central_latitude=-35, pole_longitude=110, pole_latitude=-20, width=12
)
prj2 = projection.ObliqueMercator3(
central_longitude=145, central_latitude=-35, pole_longitude=110, pole_latitude=-20, allow_southern_hemisphere=True, width=12
)
prj3 = projection.ObliqueMercator3(
central_longitude=145, central_latitude=-35, pole_longitude=110, pole_latitude=-20, align_yaxis=True, width=12
)

def test_default_unit(self):
"Test the default value for the figure units"
assert self.prj1.unit == "c"

def test_string_conversion1(self):
"Test the string representation of the projection class"
assert str(self.prj1) == "O145/-35/110/-20/12c"

def test_string_conversion2(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "OC145/-35/110/-20/12c"

def test_string_conversion3(self):
"Test the string representation of the projection class"
assert str(self.prj2) == "O145/-35/110/-20/12c+v"


class TestPolar:
"""
Tests for the Polar projection.
Expand Down