-
Notifications
You must be signed in to change notification settings - Fork 213
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
0c969bb
16819cc
979d057
c1161a3
29e263d
129ae99
adef7ad
97c836b
a414f7e
c7ee1a2
db7aca6
825cd66
acaca7d
919102d
f5897a8
7abe416
45abd59
b9997c1
f92c7d1
4161f9e
968b2cd
a77fd13
d030593
cd38f61
4793155
0f24da2
a43d4c8
f39053a
f386b09
8995715
20693e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,9 @@ | |
to create a projection and output a valid GMT projection string. | ||
|
||
>>> from pygmt import projection | ||
>>> proj = projection.LambertAzimuthalEqualArea(lon0=30, lat0=-20, horizon=60, width="8i") | ||
>>> proj = projection.LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width="8i") | ||
>>> proj | ||
LambertAzimuthalEqualArea(lon0=30, lat0=-20, horizon=60, width='8i') | ||
LambertAzimuthalEqualArea(central_longitude=30, central_latitude=-20, horizon=60, width='8i') | ||
>>> print(proj) | ||
A30/-20/60/8i | ||
""" | ||
|
@@ -81,24 +81,24 @@ class _Azimuthal(_Projection): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 90. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib() | ||
lat0: float = attr.ib() | ||
central_longitude: float = attr.ib() | ||
central_latitude: float = attr.ib() | ||
horizon: float = attr.ib(default=90) | ||
width: str = attr.ib() | ||
|
||
# private; we don't want the user to care or know about | ||
_fmt: str = attr.ib( | ||
init=False, repr=False, default="{_code}{lon0}/{lat0}/{horizon}/{width}" | ||
init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{horizon}/{width}" | ||
) | ||
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is probably no need to define There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, scratch that, I can't modify the formatter string, as it used by most of the subclasses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Woops again. I see what you mean. I'll remove it, and maybe I should get to bed ;) |
||
|
||
|
@@ -119,20 +119,20 @@ class _Cylindrical(_Projection): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib() | ||
lat0: float = attr.ib() | ||
central_longitude: float = attr.ib() | ||
central_latitude: float = attr.ib() | ||
width: str = attr.ib() | ||
|
||
# private; we don't want the user to care or know about | ||
_fmt: str = attr.ib(init=False, repr=False, default="{_code}{lon0}/{lat0}/{wdith}") | ||
_fmt: str = attr.ib(init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{wdith}") | ||
_code: str = attr.ib(init=False, repr=False, default=Supported.UNDEFINED.value) | ||
|
||
|
||
|
@@ -144,9 +144,9 @@ class _Conic: | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
lat1 : float | ||
The first standard parallel. | ||
|
@@ -156,15 +156,15 @@ class _Conic: | |
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib() | ||
lat0: float = attr.ib() | ||
central_longitude: float = attr.ib() | ||
central_latitude: float = attr.ib() | ||
lat1: float = attr.ib() | ||
lat2: float = attr.ib() | ||
width: float = attr.ib() | ||
|
||
# private; we don't want the user to care or know about | ||
_fmt: str = attr.ib( | ||
init=False, repr=False, default="{_code}{lon0}/{lat0}/{lat1}/{lat2}/{width}" | ||
init=False, repr=False, default="{_code}{central_longitude}/{central_latitude}/{lat1}/{lat2}/{width}" | ||
) | ||
|
||
|
||
|
@@ -176,9 +176,9 @@ class LambertAzimuthalEqualArea(_Azimuthal): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 90. | ||
|
@@ -200,9 +200,9 @@ class AzimuthalEquidistant(_Azimuthal): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 180. | ||
|
@@ -226,9 +226,9 @@ class AzimuthalGnomic(_Azimuthal): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 60. | ||
|
@@ -260,9 +260,9 @@ class AzimuthalOrthographic(_Azimuthal): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 90. | ||
|
@@ -294,9 +294,9 @@ class GeneralPerspective(_Projection): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre (in degrees). | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre (in degrees). | ||
altitude : float | ||
The height in km of the viewpoint above local sea level. | ||
|
@@ -314,8 +314,8 @@ class GeneralPerspective(_Projection): | |
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib() | ||
lat0: float = attr.ib() | ||
central_longitude: float = attr.ib() | ||
central_latitude: float = attr.ib() | ||
altitude: float = attr.ib() | ||
azimuth: float = attr.ib() | ||
tilt: float = attr.ib() | ||
|
@@ -328,7 +328,7 @@ class GeneralPerspective(_Projection): | |
_fmt: str = attr.ib( | ||
init=False, | ||
repr=False, | ||
default="{_code}{lon0}/{lat0}/{altitude}/{azimuth}/{tilt}/{twist}/{viewport_width}/{viewport_height}/{width}", | ||
default="{_code}{central_longitude}/{central_latitude}/{altitude}/{azimuth}/{tilt}/{twist}/{viewport_width}/{viewport_height}/{width}", | ||
) | ||
_code: str = attr.ib( | ||
init=False, repr=False, default=Supported.GENERAL_PERSPECTIVE.value | ||
|
@@ -343,9 +343,9 @@ class GeneralSterographic(_Azimuthal): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
horizon : float | ||
The max distance to the projection centre in degrees. Default is 90. | ||
|
@@ -377,9 +377,9 @@ class AlbersConicEqualArea(_Conic): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
lat1 : float | ||
The first standard parallel. | ||
|
@@ -403,9 +403,9 @@ class EquidistantConic(_Conic): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
lat1 : float | ||
The first standard parallel. | ||
|
@@ -427,9 +427,9 @@ class CassiniCylindrical(_Cylindrical): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
|
@@ -449,16 +449,16 @@ class MercatorCylindrical(_Cylindrical): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. Default is 180. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. Default is 0. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib(default=180, kw_only=True) | ||
lat0: float = attr.ib(default=0, kw_only=True) | ||
central_longitude: float = attr.ib(default=180, kw_only=True) | ||
central_latitude: float = attr.ib(default=0, kw_only=True) | ||
|
||
# private; we don't want the user to care or know about | ||
_code: str = attr.ib( | ||
|
@@ -474,16 +474,16 @@ class CylindricalStereographic(_Cylindrical): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. Default is 180. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. Default is 0. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
""" | ||
|
||
lon0: float = attr.ib(default=180, kw_only=True) | ||
lat0: float = attr.ib(default=0, kw_only=True) | ||
central_longitude: float = attr.ib(default=180, kw_only=True) | ||
central_latitude: float = attr.ib(default=0, kw_only=True) | ||
|
||
# private; we don't want the user to care or know about | ||
_code: str = attr.ib( | ||
|
@@ -499,9 +499,9 @@ class CylindricalEqualArea(_Cylindrical): | |
|
||
Parameters | ||
---------- | ||
lon0 : float | ||
central_longitude : float | ||
The longitude of the projection centre. | ||
lat0 : float | ||
central_latitude : float | ||
The latitude of the projection centre. | ||
width : str | ||
The figure width. For example ``8i`` is 8 inches. | ||
|
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.
Examples are better placed in the tutorials, gallery, or class docstrings. This one will never be rendered in the documentation.
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.
Will remove the module level example. I'll put some examples together in the tutorials section soon.