Skip to content

Commit be75223

Browse files
authored
Wrap meca (#516)
* Wrap meca command * Write tests for various meca input formats * Add example to gallery
1 parent 4cfb7a2 commit be75223

11 files changed

+655
-1
lines changed

doc/api/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Plotting data and laying out the map:
3535
Figure.image
3636
Figure.shift_origin
3737
Figure.text
38+
Figure.meca
3839

3940
Color palette table generation:
4041

examples/gallery/plot/meca.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Focal mechanisms
3+
----------------
4+
5+
The :meth:`pygmt.Figure.meca` method can plot focal mechanisms, or beachballs.
6+
We can specify the focal mechanism nodal planes or moment tensor components as
7+
a dict using the ``spec`` argument (or they can be specified as a 1d or 2d array,
8+
or within a specified file). The size of plotted beachballs can be specified
9+
using the ``scale`` argument.
10+
"""
11+
12+
import pygmt
13+
14+
fig = pygmt.Figure()
15+
16+
# generate a basemap near Washington state showing coastlines, land, and water
17+
fig.coast(
18+
region=[-125, -122, 47, 49],
19+
projection="M6c",
20+
land="grey",
21+
water="lightblue",
22+
shorelines=True,
23+
resolution="f",
24+
frame="a",
25+
)
26+
27+
# store focal mechanisms parameters in a dict
28+
focal_mechanism = dict(strike=330, dip=30, rake=90, magnitude=3)
29+
30+
# pass the focal mechanism data to meca in addition to the scale and event location
31+
fig.meca(focal_mechanism, scale="1c", longitude=-124.3, latitude=48.1, depth=12.0)
32+
33+
fig.show()

pygmt/base_plotting.py

Lines changed: 382 additions & 1 deletion
Large diffs are not rendered by default.
4.79 KB
Loading
3.13 KB
Loading
5.29 KB
Loading
4.45 KB
Loading
3 KB
Loading
19.1 KB
Loading
3.1 KB
Loading

0 commit comments

Comments
 (0)