Chapter 9 Plot focal mechanisms
To plot the focal mechanisms, activate gmtobsrocko conda environment:
conda activate gmtobsrocko
Then, import the required Python libraries:
import pygmt
import os
from obspy.imaging.beachball import beachball
and set the working directory:
#set the current working directory
work_dir=os.getcwd()
After that, set a focal mechanism in Aki & Richards convention and make a beachball plot using obspy beachball function:
# Store focal mechanism parameters in a dictionary based on the Aki & Richards
# convention
mt_2022 = [161.0, 44.13, 65.22]
#make a beachball plot
fig=beachball(mt_2022, size=200, linewidth=2, facecolor="#00A6D6")
#set the name of the figure and save it
beachball_fig="fm_20222.png"
beachball_fig_path= events_path=os.path.join(work_dir,beachball_fig)
fig.savefig(beachball_fig_path)
Figure 9.1: An example of the beach ball plot for the earthquake of the 21st of March 2022.
To make a base map plot with focal mechanisms, we use coast and meca functions, respectively:
fig = pygmt.Figure()
pygmt.config(FONT_ANNOT_PRIMARY="20p,Helvetica,black")
# generate a basemap
fig.coast(
region=[-15, 15, 50, 65],
projection="M15c",
land="grey",
water="white",
shorelines=True,
resolution="f",
frame="afg",
)
# pass the focal mechanism data to meca in addition to the scale and event location
# Store focal mechanism parameters in a dictionary based on the Aki & Richards
# convention
focal_mechanism_21_March_2022 = {"strike": 161, "dip": 44, "rake": 65, "magnitude": 5.15}
focal_mechanism_2019 = {"strike": 136, "dip": 46, "rake": -84, "magnitude": 3.9}
focal_mechanism_2017 = {"strike": 162, "dip": 64, "rake": 111, "magnitude": 4.65}
focal_mechanism_2016 = {"strike": 152, "dip": 46, "rake": 37, "magnitude": 4.42}
focal_mechanism_2014 = {"strike": 42, "dip": 37, "rake": 76, "magnitude": 4.05}
focal_mechanism_2012 = {"strike": 177, "dip": 35, "rake": -64, "magnitude": 3.63}
focal_mechanism_2008 = {"strike": 198, "dip": 57, "rake": 34, "magnitude": 4.53}
# Pass the focal mechanism data through the spec parameter. In addition provide
# scale, event location, and event depth
fig.meca(
spec=focal_mechanism_21_March_2022,
scale="1c", # in centimeters
longitude=2.53,
latitude=61.53,
depth=17.2,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2019,
scale="1c", # in centimeters
longitude=1.83,
latitude=56.97,
depth=2.7,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2017,
scale="1c", # in centimeters
longitude=1.94,
latitude=58.93,
depth=4.8,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2016,
scale="1c", # in centimeters
longitude=2.45,
latitude=62.38,
depth=14.3,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2014,
scale="1c", # in centimeters
longitude=2.31,
latitude=62.12,
depth=17.9,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2012,
scale="1c", # in centimeters
longitude=6.48,
latitude=53.36,
depth=2.3,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.meca(
spec=focal_mechanism_2008,
scale="1c", # in centimeters
longitude=-0.08,
latitude=53.9,
depth=30.8,
# Fill compressive quadrants with color "red"
# [Default is "black"]
compressionfill="#00A6D6",
# Fill extensive quadrants with color "cornsilk"
# [Default is "white"]
extensionfill="cornsilk",
# Draw a 0.5 points thick dark gray ("gray30") solid outline via
# the pen parameter [Default is "0.25p,black,solid"]
pen="0.5p,gray30,solid",
)
fig.show()
fig_name= "FM_new.png"
fig_path= events_path=os.path.join(work_dir,fig_name)
fig.savefig(fig_path,crop=True)
This will create the Figure 1.1 from the introduction section:
Figure 9.2: Map of the recomputed moment tensors in the North Sea region.