Skip to content

Commit

Permalink
Updated example, and cleaned up docstring for unit description.
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Sixsmith committed Nov 19, 2019
1 parent 5a2cf49 commit a7d885a
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions pygmt/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
to create a projection and output a valid GMT projection string.
>>> from pygmt import projection
>>> proj = projection.LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width="8i")
>>> proj = projection.LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width=8, unit="i")
>>> proj
LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width='8i')
LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width=8, unit='i', center=[30, -20])
>>> print(proj)
A30/-20/60/8i
"""
Expand Down Expand Up @@ -90,20 +90,22 @@ class _Azimuthal(_Projection):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

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="i")
center: list = attr.ib(init=False)

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{horizon}/{width}{unit}"
init=False,
repr=False,
default="{_code}{central_longitude}/{central_latitude}/{horizon}/{width}{unit}",
)
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value)

Expand Down Expand Up @@ -135,18 +137,22 @@ class _Cylindrical(_Projection):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

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="i")
center: list = attr.ib(init=False)

# private; we don't want the user to care or know about
_fmt: str = attr.ib(init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{wdith}{unit}")
_fmt: str = attr.ib(
init=False,
repr=False,
default="{_code}{central_longitude}/{central_latitude}/{wdith}{unit}",
)
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value)

@center.default
Expand All @@ -173,7 +179,7 @@ class _Conic:
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand All @@ -182,12 +188,14 @@ class _Conic:
lat1: float = attr.ib()
lat2: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default='i')
unit: str = attr.ib(default="i")
center: list = attr.ib(init=False)

# private; we don't want the user to care or know about
_fmt: str = attr.ib(
init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{lat1}/{lat2}/{width}{unit}"
init=False,
repr=False,
default="{_code}{central_longitude}/{central_latitude}/{lat1}/{lat2}/{width}{unit}",
)

@center.default
Expand All @@ -212,7 +220,7 @@ class LambertAzimuthalEqualArea(_Azimuthal):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand All @@ -239,7 +247,7 @@ class AzimuthalEquidistant(_Azimuthal):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -268,7 +276,7 @@ class AzimuthalGnomic(_Azimuthal):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -305,7 +313,7 @@ class AzimuthalOrthographic(_Azimuthal):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -352,7 +360,7 @@ class GeneralPerspective(_Projection):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand All @@ -365,7 +373,7 @@ class GeneralPerspective(_Projection):
viewport_width: float = attr.ib()
viewport_height: float = attr.ib()
width: float = attr.ib()
unit: str = attr.ib(default='i')
unit: str = attr.ib(default="i")
center: list = attr.ib(init=False)

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

Expand Down Expand Up @@ -439,7 +447,7 @@ class AlbersConicEqualArea(_Conic):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -468,7 +476,7 @@ class EquidistantConic(_Conic):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand All @@ -491,7 +499,7 @@ class CassiniCylindrical(_Cylindrical):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand All @@ -516,7 +524,7 @@ class MercatorCylindrical(_Cylindrical):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -544,7 +552,7 @@ class CylindricalStereographic(_Cylindrical):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down Expand Up @@ -572,7 +580,7 @@ class CylindricalEqualArea(_Cylindrical):
width : float
The figure width.
unit : str
The unit for the figure width in ``i`` for inch, ``c`` for centimetre and ``p`` for point.
The unit for the figure width in ``i`` for inch, ``c`` for centimetre.
Default is ``i``.
"""

Expand Down

0 comments on commit a7d885a

Please sign in to comment.