Skip to content

Improve gallery example "meca.py" #2199

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

Merged
merged 6 commits into from
Nov 21, 2022
Merged
Changes from all commits
Commits
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
23 changes: 15 additions & 8 deletions examples/gallery/seismology/meca.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
Focal mechanisms
----------------

The :meth:`pygmt.Figure.meca` method can plot focal mechanisms, or beachballs.
The :meth:`pygmt.Figure.meca` method can plot focal mechanisms or beachballs.
We can specify the focal mechanism nodal planes or moment tensor components as
a dict using the ``spec`` parameter (or they can be specified as a 1d or 2d
array, or within a specified file). The size of plotted beachballs can be
a dictionary using the ``spec`` parameter (or they can be specified as a 1d or
2d array, or within a specified file). The size of plotted beachballs can be
specified using the ``scale`` parameter.
"""

import pygmt

fig = pygmt.Figure()

# generate a basemap near Washington state showing coastlines, land, and water
# generate a map near Washington State showing land, water, and shorelines
fig.coast(
region=[-125, -122, 47, 49],
projection="M6c",
Expand All @@ -23,11 +23,18 @@
frame="a",
)

# store focal mechanisms parameters in a dict
# store focal mechanism parameters in a dictionary based on the Aki & Richards
# convention
focal_mechanism = dict(strike=330, dip=30, rake=90, magnitude=3)

# pass the focal mechanism data to meca in addition to the scale and event
# location
fig.meca(focal_mechanism, scale="1c", longitude=-124.3, latitude=48.1, depth=12.0)
# pass the focal mechanism data through the spec parameter. In addition provide
# scale, event location, and event depth
fig.meca(
spec=focal_mechanism,
scale="1c", # in centimeters
longitude=-124.3,
latitude=48.1,
depth=12.0,
)

fig.show()