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
Changed the default unit of inches to centimetres.
  • Loading branch information
Josh Sixsmith committed Dec 8, 2019
commit 45abd597e5a6a5ab7740b3b1fe2c69b1e09f6426
86 changes: 43 additions & 43 deletions pygmt/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ class _Azimuthal(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
horizon: float = attr.ib(default=90)
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand Down Expand Up @@ -124,13 +124,13 @@ class _Cylindrical(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand Down Expand Up @@ -159,15 +159,15 @@ class _Conic(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
lat1: float = attr.ib()
lat2: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand All @@ -190,12 +190,12 @@ class _Miscellaneous(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_meridian: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand All @@ -222,7 +222,7 @@ class LambertAzimuthalEqualArea(_Azimuthal):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -246,7 +246,7 @@ class AzimuthalEquidistant(_Azimuthal):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

horizon: float = attr.ib(default=180, kw_only=True)
Expand All @@ -272,7 +272,7 @@ class AzimuthalGnomic(_Azimuthal):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

horizon: float = attr.ib(default=60, kw_only=True)
Expand Down Expand Up @@ -306,7 +306,7 @@ class AzimuthalOrthographic(_Azimuthal):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

horizon: float = attr.ib(default=90)
Expand Down Expand Up @@ -350,7 +350,7 @@ class GeneralPerspective(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
Expand All @@ -362,7 +362,7 @@ class GeneralPerspective(_Projection):
Width: float = attr.ib()
Height: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand Down Expand Up @@ -390,7 +390,7 @@ class GeneralSterographic(_Azimuthal):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

horizon: float = attr.ib(default=90, kw_only=True)
Expand Down Expand Up @@ -426,7 +426,7 @@ class AlbersConicEqualArea(_Conic):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -452,7 +452,7 @@ class EquidistantConic(_Conic):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -474,7 +474,7 @@ class CassiniCylindrical(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -496,7 +496,7 @@ class MercatorCylindrical(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib(default=180, kw_only=True)
Expand All @@ -521,7 +521,7 @@ class CylindricalStereographic(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib(default=180, kw_only=True)
Expand All @@ -546,7 +546,7 @@ class CylindricalEqualArea(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -566,7 +566,7 @@ class HammerEqualArea(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -586,7 +586,7 @@ class SinusoidalEqualArea(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -606,7 +606,7 @@ class EckertIVEqualArea(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -626,7 +626,7 @@ class EckertVIEqualArea(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -646,7 +646,7 @@ class Robinson(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -666,7 +666,7 @@ class WinkelTripel(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -686,7 +686,7 @@ class Mollweide(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -706,7 +706,7 @@ class VanDerGrinten(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -732,7 +732,7 @@ class LambertConicConformal(_Conic):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -754,13 +754,13 @@ class Polyconic(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand All @@ -784,7 +784,7 @@ class Miller(_Miscellaneous):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Expand All @@ -808,13 +808,13 @@ class ObliqueMercator1(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand Down Expand Up @@ -844,15 +844,15 @@ class ObliqueMercator2(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
oblique_longitude: float = attr.ib()
oblique_latitude: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand Down Expand Up @@ -882,15 +882,15 @@ class ObliqueMercator3(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib()
central_latitude: float = attr.ib()
pole_longitude: float = attr.ib()
pole_latitude: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand All @@ -916,7 +916,7 @@ class TransverseMercator(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

# private; we don't want the user to care or know about
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# private; we don't want the user to care or know about

No need to repeat the same comment everywhere. In fact, _ is commonly used in Python to indicate "private" so there is no need for this comment at all. In general, our rule is that it's better to have code that doesn't need comments.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair comment. I'll remove them.

Expand All @@ -938,11 +938,11 @@ class UniversalTransverseMercator(_Projection):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""
zone: str = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default="i")
unit: str = attr.ib(default="c")

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
Expand All @@ -968,7 +968,7 @@ class EquidistantCylindrical(_Cylindrical):
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
Default is ``c``.
"""

central_longitude: float = attr.ib(default=180, kw_only=True)
Expand Down