Practice: Earthquake Sources, Spectra, and Magnitudes
Colab note: This notebook is designed to run on Google Colab. The first code cell installs dependencies.
Learning Objectives:¶
Interpret basic focal mechanism and beachball patterns
Calculate scalar seismic moment and moment magnitude
Relate a source time function to far-field displacement
Explore how rupture duration controls corner frequency and spectral shape
Calculate directivity effects for a unilateral rupture
Estimate stress drop from moment and rupture size
Distinguish fracture energy from frictional dissipation using a stress-slip curve
Explain magnitude saturation using the omega-square source spectrum
Prerequisites: Basic Python, logarithms, unit conversions, and introductory earthquake source concepts
Reference: Shearer, Chapter 9 (Earthquakes and Source Theory)
Notebook Outline:
# Install dependencies (for Google Colab or missing packages)
import sys
try:
import google.colab
IN_COLAB = True
print("Running in Google Colab")
except:
IN_COLAB = False
print("Running in local environment")
required_packages = {
'numpy': 'numpy',
'matplotlib': 'matplotlib',
'ipywidgets': 'ipywidgets',
'pandas': 'pandas',
'obspy': 'obspy'
}
missing_packages = []
for package, pip_name in required_packages.items():
try:
__import__(package)
print(f"OK: {package} is already installed")
except ImportError:
missing_packages.append(pip_name)
print(f"MISSING: {package} not found")
if missing_packages:
print(f"\nInstalling missing packages: {', '.join(missing_packages)}")
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q"] + missing_packages)
print("Installation complete")
else:
print("\nAll required packages are installed")Running in local environment
OK: numpy is already installed
OK: matplotlib is already installed
OK: ipywidgets is already installed
OK: pandas is already installed
OK: obspy is already installed
All required packages are installed
# Imports
import matplotlib.pyplot as plt
import numpy as npPart (a): Focal Mechanisms and Beachballs¶
Beachball diagrams summarize the P-wave first-motion radiation pattern of an earthquake.
Tasks:
In this exercise you will:
Compute P-wave takeoff angles
Plot first-motion polarity observations on the focal sphere
Compare observations to a focal mechanism
Interpret the resulting beachball
import numpy as np
import pandas as pd
source_depth_km = 8
stations = pd.DataFrame({
"station": [
"STA001","STA002","STA003","STA004","STA005",
"STA006","STA007","STA008","STA009","STA010",
"STA011","STA012","STA013","STA014","STA015",
"STA016","STA017","STA018","STA019","STA020",
"STA021","STA022","STA023","STA024","STA025",
"STA026","STA027","STA028","STA029","STA030",
"STA031","STA032","STA033","STA034","STA035",
"STA036"
],
# azimuth clockwise from north
"azimuth": np.array([
0, 10, 20, 30, 40,
50, 60, 70, 80, 90,
100, 110, 120, 130, 140,
150, 160, 170, 180, 190,
200, 210, 220, 230, 240,
250, 260, 270, 280, 290,
300, 310, 320, 330, 340,
350,
]),
# varied local/regional distances
"distance_km": np.array([
15, 20, 28, 35, 45,
55, 65, 75, 85, 95,
90, 80, 70, 60, 50,
40, 30, 22, 18, 25,
35, 48, 62, 78, 92,
88, 74, 58, 42, 30,
20, 16, 24, 38, 52,
68,
]),
"polarity": np.array([
-1, -1, -1, -1, -1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
-1, -1, -1, -1, -1,
-1, -1, -1, -1, -1,
1, 1, 1, 1, 1,
1, 1, 1, -1, -1,
-1,
])
})
stationsCompute Takeoff Angles¶
For a simple 1D Earth model, the P-wave takeoff angle can be approximated using ray geometry:
where:
= takeoff angle
= horizontal source-receiver distance
= earthquake depth
For this exercise:
distance is already provided in km
earthquake depth is 8 km
This approximation assumes straight-ray propagation in a homogeneous medium.
# compute takeoff angles
takeoff_angles =
stations["takeoff_angle"] = takeoff_angles
stationsPlot First Motions on the Focal Sphere¶
Filled circles = compressional first motions
Open circles = dilatational first motions
import numpy as np
import matplotlib.pyplot as plt
from obspy.imaging.beachball import beach
from ipywidgets import interact, IntSlider
# ---------------------------------------------------
# Force light plotting theme
# ---------------------------------------------------
plt.style.use("default")
plt.rcParams['figure.facecolor'] = 'white'
plt.rcParams['axes.facecolor'] = 'white'
plt.rcParams['savefig.facecolor'] = 'white'
# ---------------------------------------------------
# Equal-area lower hemisphere projection
# ---------------------------------------------------
def focal_projection(takeoff, azimuth):
takeoff_rad = np.radians(takeoff)
azimuth_rad = np.radians(azimuth)
r = np.sqrt(2) * np.sin(takeoff_rad / 2)
x = r * np.sin(azimuth_rad)
y = r * np.cos(azimuth_rad)
return x, y
# ---------------------------------------------------
# Interactive beachball fitting
# ---------------------------------------------------
def plot_focal_mechanism(strike=320, dip=90, rake=180):
fig, ax = plt.subplots(figsize=(8,8))
# draw beachball
b = beach(
[strike, dip, rake],
xy=(0,0),
width=2,
linewidth=1.5,
facecolor='k',
edgecolor='k',
alpha=0.85
)
ax.add_collection(b)
# plot observations
for _, row in stations.iterrows():
x, y = focal_projection(
row["takeoff_angle"],
row["azimuth"]
)
observed = row["polarity"]
if observed == 1:
ax.plot(
x, y,
'ko',
markersize=7,
zorder=0
)
else:
ax.plot(
x, y,
'wo',
markersize=7,
markeredgecolor='k',
zorder=0
)
# cardinal directions
ax.text(0, 1.08, "N", fontsize=14, ha='center')
ax.text(1.08, 0, "E", fontsize=14, va='center')
ax.text(0, -1.08, "S", fontsize=14, ha='center')
ax.text(-1.08, 0, "W", fontsize=14, va='center')
ax.set_xlim(-1.15, 1.15)
ax.set_ylim(-1.15, 1.15)
ax.set_aspect('equal')
ax.set_title(
f"Strike = {strike}° Dip = {dip}° Rake = {rake}°",
fontsize=14
)
ax.axis('off')
plt.show()
# ---------------------------------------------------
# Interactive sliders
# ---------------------------------------------------
interact(
plot_focal_mechanism,
strike=IntSlider(
min=0,
max=360,
step=1,
value=320,
description='Strike'
),
dip=IntSlider(
min=0,
max=90,
step=1,
value=90,
description='Dip'
),
rake=IntSlider(
min=-180,
max=180,
step=1,
value=180,
description='Rake'
)
)<function __main__.plot_focal_mechanism(strike=320, dip=90, rake=180)>Tasks:
Use the sliders to determine the strike, dip, and rake that best fit the polarity observations. Record your preferred focal mechanism solution below:
| Parameter | Estimated Value |
|---|---|
| Strike | |
| Dip | |
| Rake |
Identify the two possible nodal planes.
Explain why first-motion polarity observations alone cannot distinguish the true fault plane from the auxiliary plane.
List one or two additional observations that could help identify the true fault plane.
Part (b): Scalar Seismic Moment and Moment Magnitude¶
The scalar seismic moment is:
where:
is shear modulus
is average slip
is rupture area
Assume an earthquake has:
rupture length: 100 km
rupture width: 12 km
average slip: 6 m
shear modulus: 30 GPa
Tasks:
Convert all quantities to SI units
Calculate rupture area
Calculate scalar seismic moment in N m
Convert moment to dyne-cm
Calculate moment magnitude using:
where is in dyne-cm.
# Given values
length_km = # km
width_km = # km
slip_m = # m
mu_GPa = # GPa
# Convert to SI units
length_m = # m
width_m = # m
mu_Pa = # Pa
# Rupture area
area_m2 = # m^2
# Scalar seismic moment in N m
M0_Nm = # N m
# Convert N m to dyne-cm
# 1 N m = 10^7 dyne-cm
M0_dyne_cm = # dyne-cm
# Moment magnitude using dyne-cm formulation
Mw = # dimensionless
print('Scalar Moment and Magnitude:')
print(f' Area = {area_m2:.3e} m^2')
print(f' M0 = {M0_Nm:.3e} N m')
print(f' M0 = {M0_dyne_cm:.3e} dyne-cm')
print(f' Mw = {Mw:.2f}') Cell In[41], line 2
length_km = # km
^
SyntaxError: invalid syntax
Follow-up: If average slip increases from 6 m to 8 m, how do and change?
# New slip value
slip_new_m = # m
# Recalculate moment and magnitude
M0_new_Nm = # N m
M0_new_dyne_cm = # dyne-cm
Mw_new = # dimensionless
print('Effect of Increasing Slip:')
print(f' Original M0 = {M0_Nm:.3e} N m, Mw = {Mw:.2f}')
print(f' New M0 = {M0_new_Nm:.3e} N m, Mw = {Mw_new:.2f}')
print(f' Moment ratio = {M0_new_Nm/M0_Nm:.2f}')
print(f' Magnitude increase = {Mw_new - Mw:.2f}')Part (c): Source Spectra and Corner Frequency¶
A simple omega-square source spectrum is:
where:
controls the low-frequency plateau
is the corner frequency
amplitudes decay as at high frequency
Tasks:
Define a frequency vector
Calculate spectra for several corner frequencies
Plot the spectra on log-log axes
Explain how changing changes the pulse duration
# Frequency vector
f = np.logspace(-3, 2, 1000) # Hz
# Corner frequencies to compare
fc_values = [ ] # Hz, e.g., [0.1, 1.0, 10.0]
plt.figure(figsize=(8, 5))
for fc in fc_values:
A_f = # omega-square spectrum
A_f_norm = # normalize by maximum amplitude for plotting
plt.loglog(f, A_f_norm, label=f'fc = {fc} Hz')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Normalized amplitude')
plt.title('Omega-square source spectra')
plt.legend()
plt.show()Conceptual question:
Which source has a longer duration: one with high or one with low ?
Your answer here:
Part (d): Rupture Directivity¶
For a unilateral rupture of length propagating at rupture velocity , the apparent source duration depends on station azimuth:
where:
is rupture length
is rupture velocity
is seismic wave speed
is the station angle relative to rupture direction
Forward directivity shortens the pulse and increases its amplitude. Backward directivity lengthens the pulse and decreases its amplitude.
Tasks:
Calculate apparent duration for stations in the forward, side, and backward directions
Plot apparent duration as a function of azimuth
Explain why the pulse amplitude changes if the total moment is fixed
# Rupture and wave speeds
L_km = # rupture length in km
vr_km_s = # rupture velocity in km/s
c_km_s = # seismic wave speed in km/s
# Station angles
theta_deg = np.linspace(0, 180, 181)
theta_rad = np.deg2rad(theta_deg)
# Apparent duration
tau_app = # seconds
# Special cases
tau_forward = # theta = 0 degrees
tau_side = # theta = 90 degrees
tau_backward = # theta = 180 degrees
print('Apparent source durations:')
print(f' Forward direction: {tau_forward:.2f} s')
print(f' Side direction: {tau_side:.2f} s')
print(f' Backward direction: {tau_backward:.2f} s')
plt.figure(figsize=(8, 4))
plt.plot(theta_deg, tau_app)
plt.xlabel('Station angle from rupture direction (degrees)')
plt.ylabel('Apparent duration (s)')
plt.title('Rupture directivity')
plt.show()Interpretation:
Why are forward-directivity pulses shorter but larger in amplitude?
Your answer here:
Part (e): Magnitude Saturation¶
Different magnitude scales sample different frequency bands.
Approximate examples:
and : short periods near 1 s, or about 1 Hz
: surface waves near 20 s, or about 0.05 Hz
: long-period moment, related to the low-frequency spectral plateau
As earthquakes get larger, rupture duration increases and corner frequency decreases. Fixed-frequency measurements eventually sample the high-frequency falloff instead of the flat low-frequency plateau.
This causes magnitude saturation.
Tasks:
Generate omega-square spectra for earthquakes from 4 to 9
Mark the approximate and measurement frequencies
Explain why does not saturate but and do
def M0_from_Mw(Mw):
"""Return scalar moment in N m from moment magnitude."""
return 10**(1.5 * (Mw + 6.07))
# Constants for a simple constant-stress-drop scaling
beta = # shear-wave velocity in m/s
k = # source model constant, e.g., 0.21
stress_drop = # Pa, e.g., 3e6
# Frequencies
f = np.logspace(-3, 2, 1000)
Mw_values = [4, 5, 6, 7, 8, 9]
plt.figure(figsize=(8, 5))
for Mw_i in Mw_values:
M0_i = M0_from_Mw(Mw_i)
r_i = # rupture radius from circular stress-drop equation
fc_i = # corner frequency from r = k beta / fc
A_i = # omega-square spectrum
A_i_norm = A_i / M0_from_Mw(4) # arbitrary plotting normalization
plt.loglog(f, A_i_norm, label=f'Mw {Mw_i}, fc={fc_i:.3f} Hz')
plt.axvline(1.0, linestyle='--', color='black', label='~1 Hz: ML, mb')
plt.axvline(0.05, linestyle=':', color='black', label='~0.05 Hz: Ms')
plt.xlabel('Frequency (Hz)')
plt.ylabel('Amplitude proxy')
plt.title('Magnitude saturation and the omega-square spectrum')
plt.legend(fontsize=8)
plt.show() Cell In[1], line 6
beta = # shear-wave velocity in m/s
^
SyntaxError: invalid syntax
Interpretation:
Why do short-period magnitudes saturate for large earthquakes?
Your answer here:
Why does moment magnitude avoid this problem?
Your answer here:
Summary¶
In this notebook, you practiced connecting earthquake source physics to seismic observations:
Beachballs summarize radiation patterns and faulting style
Seismic moment links slip, rupture area, and rigidity
Source time functions control pulse shape and frequency content
Directivity changes apparent pulse duration and amplitude
Magnitude saturation occurs because fixed-frequency measurements stop tracking total moment for large events
Big idea: Seismograms record both the geometry and time dependence of earthquake rupture.