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

Add gallery example showing different polar projection use cases #955

Merged
merged 53 commits into from
Mar 4, 2021
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
195ce16
Add gallery example showing different polar projection use cases
michaelgrund Feb 22, 2021
9f28102
formatting
michaelgrund Feb 22, 2021
bdc0069
Merge branch 'master' into misc-polar-projs
michaelgrund Feb 22, 2021
e6ec82f
Merge branch 'master' into misc-polar-projs
michaelgrund Feb 23, 2021
e02cc94
Merge branch 'master' into misc-polar-projs
michaelgrund Feb 24, 2021
c39ef2a
adjusted annotations
michaelgrund Feb 24, 2021
1ff394b
updates
michaelgrund Feb 24, 2021
f728cc5
updated annotations
michaelgrund Feb 25, 2021
5e48e9f
Merge branch 'master' into misc-polar-projs
michaelgrund Feb 25, 2021
354f5eb
added parts of docstrings, still in progress
michaelgrund Feb 28, 2021
c39afb8
Merge branch 'misc-polar-projs' of https://github.com/GenericMappingT…
michaelgrund Feb 28, 2021
21d728c
Merge branch 'master' into misc-polar-projs
michaelgrund Feb 28, 2021
a63c2d5
added parts of docstrings, still in progress
michaelgrund Feb 28, 2021
7340153
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 1, 2021
63c2f3e
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 1, 2021
dc57750
completed docstrings
michaelgrund Mar 1, 2021
6fd46ca
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 2, 2021
86ad5f7
updated docstrings
michaelgrund Mar 2, 2021
8867a92
updated docstrings
michaelgrund Mar 2, 2021
2d5f009
formatting
michaelgrund Mar 2, 2021
02fcd0b
formatting
michaelgrund Mar 2, 2021
9f2473b
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
0f1a157
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
7107a0e
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
02ea10e
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
d934cd8
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
01fa9ee
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
a43530a
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
9d3b275
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
3c749e9
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
91e51fc
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
73da9ce
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
639d798
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
02cff7f
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
258a9a8
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
f9412ec
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
026fadc
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 3, 2021
6ff04d3
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 3, 2021
ce5586d
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
992b7b5
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
42ee401
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
8bec63c
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
6fcadca
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
d7913da
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
0c6b967
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
62af98d
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
8da7d4e
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 3, 2021
f18a6fb
updated based on code review
michaelgrund Mar 3, 2021
6ca4e9f
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
57cd773
Update examples/projections/nongeo/polar-misc.py
michaelgrund Mar 3, 2021
099b8bf
Merge branch 'master' into misc-polar-projs
michaelgrund Mar 4, 2021
91cb328
removed old polar example by new version
michaelgrund Mar 4, 2021
bd020c9
Merge branch 'master' into misc-polar-projs
seisman Mar 4, 2021
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
160 changes: 148 additions & 12 deletions examples/projections/nongeo/polar.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,158 @@
"""
r"""
Polar
=====

**P**\ *width*: Give the *width* of the figure.
Polar projections allow plotting polar coordinate data (e.g. angle
:math:`\theta` and radius *r*).

The full syntax for polar projections is:

**P**\ *width*\ [**+a**]\ [**+f**\ [**e**\|\ **p**\|\ *radius*]]\
[**+r**\ *offset*][**+t**\ *origin*][**+z**\ [**p**\|\ *radius*]]

Limits are set via the ``region`` parameter
([*theta_min*, *theta_max*, *radius_min*, *radius_max*]). When using
**P**\ *width* you have to give the *width* of the figure. The lower-case
version **p** is similar to **P** but expects a *scale* instead of
a width (**p**\ *scale*).

The following customizing modifiers are available:

- **+a**: by default, :math:`\theta` refers to the angle that is equivalent to
a counterclockwise rotation with respect to the east direction (standard
definition); **+a** indicates that the input data is rotated clockwise
relative to the north direction (geographical azimuth angle).

- **+r**\ *offset*: represents the offset of the r axis. This modifier allows
you to offset the center of the circle from r=0.

- **+t**\ *origin*: sets the angle corresponding to the east direction which is
equivalent to rotating the entire coordinate axis clockwise; if the **+a**
modifier is used, setting the angle corresponding to the north direction is
equivalent to rotating the entire coordinate axis counterclockwise.

- **+f**: reverses the radial direction.

- Append **e** to indicate that the r-axis is an elevation angle, and the
range of the r-axis should be between 0 and 90.
- Appending **p** sets the current earth radius (determined by
:gmt-term:`PROJ_ELLIPSOID`)
to the maximum value of the r axis when the r axis is reversed.
- Append *radius* to set the maximum value of the r axis.

- **+z**: indicates that the r axis is marked as depth instead of radius (e.g.
*r = radius - z*).

- Append **p** to set radius to the current earth radius.
- Append *radius* to set the value of the radius.

"""

import pygmt

fig = pygmt.Figure()
fig.plot(
# x inputs are the theta values for a polar plot.
x=[180, 120, 270, 60, 0],
# y inputs are the radius values for a polar plot.
y=[15, 35, 15, 35, 15],
pen="2p,blue",
# The region values are theta-min/theta-max/radius-min/radius-max.
region=[0, 360, 0, 40],
projection="P15c",
frame=["afg"],

pygmt.config(FONT_TITLE="14p,Helvetica,black", FORMAT_GEO_MAP="+D")

# ============

fig.basemap(
# set map limits to theta_min = 0, theta_max = 360, radius_min = 0, radius_max = 1
region=[0, 360, 0, 1],
# set map width to 5 cm
projection="P5c",
# set the frame and color
frame=["xa45f", "+gbisque"],
)

fig.text(position="TC", text="projection='P5c'", offset="0/2.0c", no_clip=True)
fig.text(position="TC", text="region=[0, 360, 0, 1]", offset="0/1.5c", no_clip=True)

fig.shift_origin(xshift="8c")

# ============
fig.basemap(
# set map limits to theta_min = 0, theta_max = 360, radius_min = 0, radius_max = 1
region=[0, 360, 0, 1],
# set map width to 5 cm and interpret input data as geographic azimuth instead
# of standard angle
projection="P5c+a",
# set the frame and color
frame=["xa45f", "+gbisque"],
)

fig.text(position="TC", text="projection='P5c+a'", offset="0/2.0c", no_clip=True)
fig.text(position="TC", text="region=[0, 360, 0, 1]", offset="0/1.5c", no_clip=True)

fig.shift_origin(xshift="8c")

# ============
fig.basemap(
# set map limits to theta_min = 0, theta_max = 90, radius_min = 0, radius_max = 1
region=[0, 90, 0, 1],
# set map width to 5 cm and interpret input data as geographic azimuth instead
# of standard angle
projection="P5c+a",
# set the frame and color
frame=["xa45f", "ya0.2", "WNe+gbisque"],
)

fig.text(position="TC", text="projection='P5c+a'", offset="0/2.0c", no_clip=True)
fig.text(position="TC", text="region=[0, 90, 0, 1]", offset="0/1.5c", no_clip=True)

fig.shift_origin(xshift="-16c", yshift="-7c")

# ============
fig.basemap(
# set map limits to theta_min = 0, theta_max = 90, radius_min = 0, radius_max = 1
region=[0, 90, 0, 1],
# set map width to 5 cm and interpret input data as geographic azimuth instead
# of standard angle, rotate coordinate system counterclockwise by 45 degrees
projection="P5c+a+t45",
# set the frame and color
frame=["xa30f", "ya0.2", "WNe+gbisque"],
)

fig.text(position="TC", text="projection='P5c+a\+t45'", offset="0/2.0c", no_clip=True)
fig.text(position="TC", text="region=[0, 90, 0, 1]", offset="0/1.5c", no_clip=True)

fig.shift_origin(xshift="8c", yshift="1.3c")

# ============
fig.basemap(
# set map limits to theta_min = 0, theta_max = 90, radius_min = 3480,
# radius_max = 6371 (Earth's radius)
region=[0, 90, 3480, 6371],
# set map width to 5 cm and interpret input data as geographic azimuth instead
# of standard angle, rotate coordinate system counterclockwise by 45 degrees
projection="P5c+a+t45",
# set the frame and color
frame=["xa30f", "ya", "WNse+gbisque"],
)

fig.text(position="TC", text="projection='P5c+a\+t45'", offset="0/2.0c", no_clip=True)
fig.text(
position="TC", text="region=[0, 90, 3480, 6371]", offset="0/1.5c", no_clip=True
)

fig.shift_origin(xshift="8c")

# ============
fig.basemap(
# set map limits to theta_min = 0, theta_max = 90, radius_min = 3480,
# radius_max = 6371 (Earth's radius)
region=[0, 90, 3480, 6371],
# set map width to 5 cm and interpret input data as geographic azimuth instead
# of standard angle, rotate coordinate system counterclockwise by 45 degrees,
# r axis is marked as depth
projection="P5c+a+t45+z",
# set the frame and color
frame=["xa30f", "ya", "WNse+gbisque"],
)

fig.text(position="TC", text="projection='P5c+a\+t45+z'", offset="0/2.0c", no_clip=True)
fig.text(
position="TC", text="region=[0, 90, 3480, 6371]", offset="0/1.5c", no_clip=True
)

fig.show()