- bugfixes of buggy magnitude scaling (fix with new rescale_slip method) - bugfixes plotting - changed handling of Lamee parameters for better future implementation possibilities of heterogeneous linear coefficient calculators - Update gmtpy importfeature/orthodrom-crossdist
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 624 KiB |
After Width: | Height: | Size: 609 KiB |
Before Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 160 KiB |
@ -1,125 +0,0 @@
|
||||
import numpy as num |
||||
import os.path as op |
||||
|
||||
import matplotlib.pyplot as plt |
||||
|
||||
from pyrocko import gf |
||||
|
||||
|
||||
km = 1e3 |
||||
d2r = 180./num.pi |
||||
|
||||
# Download a Greens Functions store, programmatically. |
||||
store_id = 'gf_abruzzo_nearfield_vmod_Ameri' |
||||
store_id_dynamic = 'iceland_reg_v2' |
||||
|
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
if not op.exists(store_id_dynamic): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id_dynamic) |
||||
|
||||
|
||||
engine = gf.LocalEngine(store_superdirs=['.']) |
||||
store = engine.get_store(store_id) |
||||
|
||||
strike = 0. |
||||
dip = 90. |
||||
dep = 3*km |
||||
leng = 2*km |
||||
wid = 2*km |
||||
|
||||
source_params = dict( |
||||
north_shift=2*km, |
||||
east_shift=2*km, |
||||
depth=dep, |
||||
width=wid, |
||||
length=leng, |
||||
dip=dip, |
||||
strike=strike, |
||||
magnitude=6., |
||||
anchor='top', |
||||
decimation_factor=4) |
||||
|
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
nx=5, ny=5, |
||||
tractions=gf.tractions.HomogeneousTractions( |
||||
strike=1.e4, |
||||
dip=0.e4, |
||||
normal=0.), |
||||
**source_params) |
||||
|
||||
dyn_rupture.discretize_patches(store) |
||||
slip = dyn_rupture.get_slip() |
||||
rake = num.arctan2(slip[:, 1].mean(), slip[:, 0].mean()) |
||||
print('rake', float(rake*d2r)) |
||||
|
||||
|
||||
depths = dyn_rupture.get_patch_attribute('depth') |
||||
rect_rupture = gf.RectangularSource( |
||||
rake=float(rake*d2r), |
||||
**source_params) |
||||
|
||||
# Define a grid of targets |
||||
# number in east and north directions |
||||
# ngrid = 40 |
||||
ngrid = 90 # for better resolution |
||||
|
||||
# extension from origin in all directions |
||||
obs_size = 10.*km |
||||
ntargets = ngrid**2 |
||||
|
||||
norths = num.linspace(-obs_size, obs_size, ngrid) |
||||
easts = num.linspace(-obs_size, obs_size, ngrid) |
||||
|
||||
norths2d = num.repeat(norths, len(easts)) |
||||
easts2d = num.tile(easts, len(norths)) |
||||
|
||||
|
||||
waveform_target = gf.Target( |
||||
lat=0., lon=0., |
||||
east_shift=10*km, north_shift=0.*km, |
||||
store_id=store_id_dynamic) |
||||
|
||||
|
||||
static_target = gf.StaticTarget( |
||||
lats=num.zeros(norths2d.size), lons=num.zeros(norths2d.size), |
||||
north_shifts=norths2d.ravel(), |
||||
east_shifts=easts2d.ravel(), |
||||
interpolation='nearest_neighbor', |
||||
store_id=store_id) |
||||
|
||||
result = engine.process(rect_rupture, static_target) |
||||
|
||||
targets_static = result.request.targets_static |
||||
N = targets_static[0].coords5[:, 2] |
||||
E = targets_static[0].coords5[:, 3] |
||||
synth_disp_rect = result.results_list[0][0].result |
||||
|
||||
result = engine.process(dyn_rupture, static_target) |
||||
|
||||
targets_static = result.request.targets_static |
||||
N = targets_static[0].coords5[:, 2] |
||||
E = targets_static[0].coords5[:, 3] |
||||
synth_disp_dyn = result.results_list[0][0].result |
||||
|
||||
|
||||
down_rect = synth_disp_rect['displacement.d'] |
||||
down_dyn = synth_disp_dyn['displacement.d'] |
||||
down_diff = down_rect - down_dyn |
||||
|
||||
print('rect', down_rect.max()) |
||||
print('dyn', down_dyn.max()) |
||||
|
||||
fig, axes = plt.subplots(3, 1) |
||||
|
||||
for ax, down in zip(axes, (down_rect, down_dyn, down_diff)): |
||||
cmap = ax.scatter( |
||||
E, N, c=down, |
||||
s=10., marker='s', |
||||
edgecolor='face', |
||||
cmap=plt.get_cmap('seismic')) |
||||
|
||||
fig.colorbar(cmap, ax=ax, orientation='vertical', aspect=5, shrink=0.5) |
||||
|
||||
plt.show() |
@ -1,155 +0,0 @@
|
||||
import logging |
||||
import os |
||||
|
||||
import numpy as num |
||||
import matplotlib.pyplot as plt |
||||
|
||||
from pyrocko import trace, util |
||||
from pyrocko.gf import PseudoDynamicRupture, LocalEngine, Target, tractions, ws |
||||
from pyrocko.plot import dynamic_rupture |
||||
from pyrocko.plot import mpl_graph_color |
||||
|
||||
|
||||
logger = logging.getLogger('pyrocko.examples.gf_forward_pseudo_rupture2') |
||||
util.setup_logging(levelname='info') |
||||
|
||||
d2r = num.pi / 180. |
||||
km2m = 1000. |
||||
|
||||
# Example of a self-similar traction field with increasing complexity used for |
||||
# the Pseudo Dynamic Rupture source model. |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'iceland_reg_v2' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
|
||||
if not os.path.exists(store_id): |
||||
ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = LocalEngine(store_superdirs=['.'], default_store_id=store_id) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Length and Width are defined based from Wells and Coppersmith (1994). |
||||
mag = 7.5 |
||||
length = 10**(-2.44 + 0.59 * mag) * km2m |
||||
width = 10**(-1.01 + 0.32 * mag) * km2m |
||||
nx, ny = int(num.ceil(length / 2000.)), int(num.ceil(width / 2000.)) |
||||
nyq = int(num.floor(num.min((nx, ny))/2.)) |
||||
|
||||
logger.info('nx: %i, ny: %i' % (nx, ny)) |
||||
logger.info('ranks <= %i for no aliasing' % nyq) |
||||
|
||||
# Define the ranks (maximum wavenumber) and phases for the cosine functions |
||||
# in the SelfSimiliarTractions |
||||
ranks = num.array([1, 2, 5, 10]) |
||||
phases = num.array([ |
||||
-0.9120799, 1.40519485, -0.80165805, 1.65676832, 1.04067916, -2.58736667, |
||||
1.27630965, -2.55843096, 2.13857185, 1.01601178]) |
||||
|
||||
# Let's create the PseudoDynamicRupture using self similar tractions |
||||
source = PseudoDynamicRupture( |
||||
lat=0., |
||||
lon=0., |
||||
length=length, |
||||
width=width, |
||||
depth=10. * km2m, |
||||
strike=0., |
||||
dip=0., |
||||
anchor='top', |
||||
gamma=0.6, |
||||
nucleation_x=0.25, |
||||
nucleation_y=-0.5, |
||||
nx=nx, |
||||
ny=ny, |
||||
pure_shear=True, |
||||
smooth_rupture=True, |
||||
magnitude=mag, |
||||
tractions=tractions.SelfSimilarTractions( |
||||
rank=ranks[0], rake=0, phases=phases[:1])) |
||||
|
||||
# The source needs to be discretized into finite faults (patches) with |
||||
# associated elastic parameters taken from the store. |
||||
source.discretize_patches(store) |
||||
|
||||
# A key element of the PseudoDynamicRupture is the linkage of the tractions on |
||||
# the patches with their dislocations. The linear coefficients describing the |
||||
# link are obtained based on Okada (1992) and a boundary element method |
||||
source.calc_coef_mat() |
||||
|
||||
synthetic_traces = [] |
||||
channel_codes = 'ENZ' |
||||
|
||||
for rank in ranks: |
||||
logger.info('Modelling for rank %i' % rank) |
||||
|
||||
# Update source traction rank and phases for increasing number of summed |
||||
# cosines |
||||
source.tractions.rank = rank |
||||
source.tractions.phases = phases[:rank] |
||||
|
||||
# Display absolut tractions and final absolut dislocations |
||||
viewer = dynamic_rupture.RuptureView(source=source) |
||||
viewer.draw_patch_parameter('traction') |
||||
viewer.draw_time_contour(store) |
||||
viewer.show_plot() |
||||
|
||||
viewer = dynamic_rupture.RuptureView(source=source) |
||||
viewer.draw_dislocation() |
||||
viewer.draw_time_contour(store) |
||||
viewer.show_plot() |
||||
|
||||
# Define a list of pyrocko.gf.Target objects, representing the recording |
||||
# devices. In this case one station with a three component sensor will |
||||
# serve fine for demonstation.logger.info('Modelling synthetic waveforms') |
||||
targets = [ |
||||
Target( |
||||
lat=3., |
||||
lon=2., |
||||
store_id=store_id, |
||||
codes=('', 'STA', '%02d' % rank, channel_code)) |
||||
for channel_code in channel_codes] |
||||
|
||||
# Processing that data will return a pyrocko.gf.Reponse object. |
||||
response = engine.process(source, targets) |
||||
|
||||
# This will return a list of the requested traces: |
||||
synthetic_traces += response.pyrocko_traces() |
||||
|
||||
# Finally, let's scrutinize these traces. |
||||
trace.snuffle(synthetic_traces) |
||||
|
||||
# Plot the component-wise amplitude spectra |
||||
fig, axes = plt.subplots(3, 1) |
||||
linestyles = ['solid', 'dashed', 'dotted', 'dashdot', (0, (3, 1, 1, 1, 1, 1))] |
||||
|
||||
for c, ax in zip(channel_codes, axes): |
||||
selected_traces = [tr for tr in synthetic_traces if tr.channel == c] |
||||
|
||||
for i, (tr, linestyle) in enumerate(zip(selected_traces, linestyles)): |
||||
tr.ydata -= tr.ydata.mean() |
||||
freqs, amps = tr.spectrum(tfade=None) |
||||
amps = num.abs(amps) |
||||
|
||||
ax.loglog( |
||||
freqs, |
||||
amps, |
||||
linestyle=linestyle, |
||||
c=mpl_graph_color(i), |
||||
label='ratio = %g' % int(tr.location)) |
||||
|
||||
ax.set_ylim((1e-5, 1.)) |
||||
ax.set_title(c) |
||||
ax.set_ylabel('amplitude [counts]') |
||||
ax.legend(loc='best') |
||||
|
||||
axes[-1].set_xlabel('frequency [Hz]') |
||||
plt.show() |
@ -1,152 +0,0 @@
|
||||
import logging |
||||
import os |
||||
|
||||
import numpy as num |
||||
import matplotlib.pyplot as plt |
||||
|
||||
from pyrocko import trace, util |
||||
from pyrocko.gf import PseudoDynamicRupture, LocalEngine, Target, tractions, ws |
||||
from pyrocko.plot import dynamic_rupture |
||||
from pyrocko.plot import mpl_graph_color |
||||
|
||||
|
||||
logger = logging.getLogger('pyrocko.examples.gf_forward_pseudo_rupture3') |
||||
util.setup_logging(levelname='info') |
||||
|
||||
d2r = num.pi / 180. |
||||
km2m = 1000. |
||||
|
||||
|
||||
# Example of a fractal perturbed traction field used for the Pseudo Dynamic |
||||
# Rupture source model. |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'iceland_reg_v2' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
|
||||
if not os.path.exists(store_id): |
||||
ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = LocalEngine(store_superdirs=['.'], default_store_id=store_id) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Length and Width are defined based from Wells and Coppersmith (1994). |
||||
mag = 7.5 |
||||
length = 10**(-2.44 + 0.59 * mag) * km2m |
||||
width = 10**(-1.01 + 0.32 * mag) * km2m |
||||
nx = int(num.ceil(length / (2. * km2m))) |
||||
ny = int(num.ceil(width / (2. * km2m))) |
||||
|
||||
logger.info('nx: %i, ny: %i' % (nx, ny)) |
||||
|
||||
# Define fractal traction to directed traction ratios for display of the effect |
||||
traction_ratio = num.power(num.ones(5) * 10, num.arange(-2, 3)) |
||||
|
||||
# Let's create the PseudoDynamicRupture using combined fractal and directed |
||||
# tractions |
||||
source = PseudoDynamicRupture( |
||||
lat=0., |
||||
lon=0., |
||||
length=length, |
||||
width=width, |
||||
depth=10. * km2m, |
||||
strike=0., |
||||
dip=0., |
||||
anchor='top', |
||||
gamma=0.6, |
||||
nucleation_x=0.25, |
||||
nucleation_y=-0.5, |
||||
nx=nx, |
||||
ny=ny, |
||||
pure_shear=True, |
||||
smooth_rupture=True, |
||||
magnitude=mag, |
||||
tractions=tractions.TractionComposition(components=[ |
||||
tractions.FractalTractions( |
||||
rake=0, rseed=None, traction_max=traction_ratio[0]), |
||||
tractions.DirectedTractions( |
||||
rake=0, traction=1.)])) |
||||
|
||||
# The source needs to be discretized into finite faults (patches) with |
||||
# associated elastic parameters taken from the store. |
||||
source.discretize_patches(store) |
||||
|
||||
# A key element of the PseudoDynamicRupture is the linkage of the tractions on |
||||
# the patches with their dislocations. The linear coefficients describing the |
||||
# link are obtained based on Okada (1992) and a boundary element method |
||||
source.calc_coef_mat() |
||||
|
||||
synthetic_traces = [] |
||||
channel_codes = 'ENZ' |
||||
|
||||
for it, t in enumerate(traction_ratio): |
||||
# Display absolut tractions and final absolut dislocations |
||||
logger.info('Modelling for fractal traction for traction ratio %g', t) |
||||
|
||||
source.tractions.components[0].traction_max = t |
||||
|
||||
viewer = dynamic_rupture.RuptureView(source=source) |
||||
viewer.draw_patch_parameter('traction') |
||||
viewer.draw_time_contour(store) |
||||
viewer.show_plot() |
||||
|
||||
viewer = dynamic_rupture.RuptureView(source=source) |
||||
viewer.draw_dislocation() |
||||
viewer.draw_time_contour(store) |
||||
viewer.show_plot() |
||||
|
||||
# Define a list of pyrocko.gf.Target objects, representing the recording |
||||
# devices. In this case one station with a three component sensor will |
||||
# serve fine for demonstation.logger.info('Modelling synthetic waveforms') |
||||
targets = [ |
||||
Target( |
||||
lat=3., |
||||
lon=2., |
||||
store_id=store_id, |
||||
codes=('', 'STA', '%g' % it, channel_code)) |
||||
for channel_code in channel_codes] |
||||
|
||||
# Processing that data will return a pyrocko.gf.Reponse object. |
||||
response = engine.process(source, targets) |
||||
|
||||
# This will return a list of the requested traces: |
||||
synthetic_traces += response.pyrocko_traces() |
||||
|
||||
# Finally, let's scrutinize these traces. |
||||
trace.snuffle(synthetic_traces) |
||||
|
||||
# Plot the component-wise amplitude spectra |
||||
fig, axes = plt.subplots(3, 1) |
||||
linestyles = ['solid', 'dashed', 'dotted', 'dashdot', (0, (3, 1, 1, 1, 1, 1))] |
||||
|
||||
for c, ax in zip(channel_codes, axes): |
||||
selected_traces = [tr for tr in synthetic_traces if tr.channel == c] |
||||
|
||||
for i, (tr, linestyle) in enumerate(zip(selected_traces, linestyles)): |
||||
tr.ydata -= tr.ydata.mean() |
||||
freqs, amps = tr.spectrum(tfade=None) |
||||
amps = num.abs(amps) |
||||
|
||||
ax.loglog( |
||||
freqs, |
||||
amps, |
||||
linestyle=linestyle, |
||||
c=mpl_graph_color(i), |
||||
label='ratio = %g' % traction_ratio[int(tr.location)]) |
||||
|
||||
ax.set_ylim((1e-5, 1.)) |
||||
ax.set_title(c) |
||||
ax.set_ylabel('amplitude [counts]') |
||||
ax.legend(loc='best') |
||||
|
||||
axes[-1].set_xlabel('frequency [Hz]') |
||||
plt.show() |
@ -0,0 +1,66 @@
|
||||
import os.path as op |
||||
from pyrocko import gf |
||||
|
||||
km = 1e3 |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'iceland_reg_v2' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = gf.LocalEngine(store_superdirs=['.']) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Let's define the source now with its extension, orientation etc. |
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
lat=0., |
||||
lon=0., |
||||
north_shift=2.*km, |
||||
east_shift=2.*km, |
||||
depth=3.*km, |
||||
strike=43., |
||||
dip=89., |
||||
rake=88., |
||||
|
||||
length=15*km, |
||||
width=5*km, |
||||
|
||||
nx=10, |
||||
ny=5, |
||||
|
||||
# Relative nucleation between -1. and 1. |
||||
nucleation_x=-.6, |
||||
nucleation_y=.3, |
||||
slip=1., |
||||
anchor='top', |
||||
|
||||
# Threads used for modelling |
||||
nthreads=1, |
||||
|
||||
# Force pure shear rupture |
||||
pure_shear=True) |
||||
|
||||
# Recalculate slip, that rupture magnitude fits given magnitude |
||||
dyn_rupture.rescale_slip(magnitude=7.0, store=store) |
||||
|
||||
# Create waveform target, where synthetic waveforms are calculated for |
||||
waveform_target = gf.Target( |
||||
lat=0., |
||||
lon=0., |
||||
east_shift=10*km, |
||||
north_shift=10.*km, |
||||
store_id=store_id) |
||||
|
||||
# Get synthetic waveforms and display them in snuffler |
||||
result = engine.process(dyn_rupture, waveform_target) |
||||
result.snuffle() |
@ -0,0 +1,62 @@
|
||||
import os.path as op |
||||
from pyrocko import gf |
||||
from pyrocko.plot.dynamic_rupture import RuptureView |
||||
|
||||
km = 1e3 |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'iceland_reg_v2' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = gf.LocalEngine(store_superdirs=['.']) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Let's define the source now with its extension, orientation etc. |
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
# At lat 0. and lon 0. (default) |
||||
north_shift=2.*km, |
||||
east_shift=2.*km, |
||||
depth=3.*km, |
||||
strike=43., |
||||
dip=89., |
||||
rake=88., |
||||
|
||||
length=15*km, |
||||
width=5*km, |
||||
|
||||
nx=10, |
||||
ny=5, |
||||
|
||||
# Relative nucleation between -1. and 1. |
||||
nucleation_x=-.6, |
||||
nucleation_y=.3, |
||||
slip=1., |
||||
anchor='top', |
||||
|
||||
# Threads used for modelling |
||||
nthreads=1, |
||||
|
||||
# Force pure shear rupture |
||||
pure_shear=True) |
||||
|
||||
# Recalculate slip, that rupture magnitude fits given magnitude |
||||
dyn_rupture.rescale_slip(magnitude=7.0, store=store) |
||||
|
||||
plot = RuptureView(dyn_rupture, figsize=(8, 4)) |
||||
plot.draw_patch_parameter('traction') |
||||
plot.draw_time_contour(store) |
||||
plot.draw_nucleation_point() |
||||
plot.save('dynamic_basic_tractions.png') |
||||
# Alternatively plot on screen |
||||
# plot.show_plot() |
@ -1,50 +0,0 @@
|
||||
import os.path as op |
||||
|
||||
from pyrocko import gf |
||||
from pyrocko.plot.dynamic_rupture import RuptureView, rupture_movie |
||||
|
||||
km = 1e3 |
||||
|
||||
# Download a Greens Functions store |
||||
store_id = 'crust2_ib' |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
|
||||
engine = gf.LocalEngine(store_superdirs=['.'], use_config=True) |
||||
store = engine.get_store(store_id) |
||||
|
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
nx=30, ny=40, |
||||
north_shift=2*km, east_shift=2*km, depth=5*km, |
||||
strike=43., dip=90., rake=88., |
||||
width=12*km, length=26*km, |
||||
nucleation_x=-.6, nucleation_y=.3, |
||||
gamma=0.7, slip=2., anchor='top', smooth_rupture=True, |
||||
nthreads=0) |
||||
|
||||
dyn_rupture.discretize_patches(store) |
||||
|
||||
plot = RuptureView(dyn_rupture, figsize=(8, 4)) |
||||
plot.draw_patch_parameter('traction') |
||||
plot.draw_time_contour(store) |
||||
plot.draw_nucleation_point() |
||||
plot.save('dynamic_simple_tractions.png') |
||||
# Alternatively plot on screen |
||||
# plot.show_plot() |
||||
|
||||
plot = RuptureView(dyn_rupture, figsize=(8, 4)) |
||||
plot.draw_dislocation() |
||||
plot.draw_time_contour(store) |
||||
plot.draw_nucleation_point() |
||||
plot.save('dynamic_simple_dislocations.png') |
||||
|
||||
plot = RuptureView(dyn_rupture, figsize=(8, 4)) |
||||
plot.draw_patch_parameter('vr') |
||||
plot.draw_time_contour(store) |
||||
plot.draw_nucleation_point() |
||||
plot.save('dynamic_simple_vr.png') |
||||
|
||||
rupture_movie( |
||||
dyn_rupture, store, 'dislocation', |
||||
plot_type='view', figsize=(8, 4)) |
@ -1,48 +0,0 @@
|
||||
import os.path as op |
||||
from pyrocko import gf |
||||
|
||||
km = 1e3 |
||||
|
||||
# Download a Greens Functions store |
||||
store_id = 'crust2_ib' |
||||
|
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
|
||||
engine = gf.LocalEngine(store_superdirs=['.'], use_config=True) |
||||
store = engine.get_store(store_id) |
||||
|
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
lat=0., |
||||
lon=0., |
||||
north_shift=0*km, |
||||
east_shift=0*km, |
||||
depth=3*km, |
||||
|
||||
width=12*km, |
||||
length=29*km, |
||||
|
||||
strike=43., |
||||
dip=89., |
||||
rake=88., |
||||
|
||||
# Number of discrete patches |
||||
nx=15, |
||||
ny=15, |
||||
# Relation between subsurface model s-wave velocity vs |
||||
# and rupture velocity vr |
||||
gamma=0.7, |
||||
|
||||
magnitude=7., |
||||
anchor='top') |
||||
|
||||
waveform_target = gf.Target( |
||||
lat=0., |
||||
lon=0., |
||||
east_shift=10*km, |
||||
north_shift=10.*km, |
||||
store_id=store_id) |
||||
|
||||
result = engine.process(dyn_rupture, waveform_target) |
||||
result.snuffle() |
@ -1,48 +0,0 @@
|
||||
import os.path as op |
||||
from pyrocko import gf |
||||
from pyrocko.plot.dynamic_rupture import RuptureView |
||||
|
||||
km = 1e3 |
||||
|
||||
# Download a Greens Functions store |
||||
store_id = 'crust2_ib' |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
|
||||
engine = gf.LocalEngine(store_superdirs=['.'], use_config=True) |
||||
store = engine.get_store(store_id) |
||||
|
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
# At lat 0. and lon 0. (default) |
||||
north_shift=2*km, |
||||
east_shift=2*km, |
||||
depth=3*km, |
||||
strike=43., |
||||
dip=89., |
||||
rake=88., |
||||
|
||||
length=26*km, |
||||
width=12*km, |
||||
|
||||
nx=30, |
||||
ny=20, |
||||
|
||||
# Relative nucleation between -1. and 1. |
||||
nucleation_x=-.6, |
||||
nucleation_y=.3, |
||||
magnitude=7., |
||||
anchor='top', |
||||
|
||||
# Threads used for modelling |
||||
nthreads=0) |
||||
|
||||
dyn_rupture.discretize_patches(store) |
||||
|
||||
plot = RuptureView(dyn_rupture, figsize=(8, 4)) |
||||
plot.draw_patch_parameter('traction') |
||||
plot.draw_time_contour(store) |
||||
plot.draw_nucleation_point() |
||||
plot.save('dynamic_simple_tractions.png') |
||||
# Alternatively plot on screen |
||||
# plot.show_plot() |
@ -0,0 +1,129 @@
|
||||
import numpy as num |
||||
import os.path as op |
||||
|
||||
import matplotlib.pyplot as plt |
||||
|
||||
from pyrocko import gf |
||||
|
||||
km = 1e3 |
||||
d2r = num.pi / 180. |
||||
r2d = 180. / num.pi |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'gf_abruzzo_nearfield_vmod_Ameri' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = gf.LocalEngine(store_superdirs=['.']) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Let's define the source now with its extension, orientation etc. |
||||
source_params = dict( |
||||
north_shift=2. * km, |
||||
east_shift=2. * km, |
||||
depth=3.5 * km, |
||||
length=6. * km, |
||||
width=3. * km, |
||||
strike=0., |
||||
dip=0., |
||||
rake=45., |
||||
anchor='top', |
||||
decimation_factor=1) |
||||
|
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
nx=1, |
||||
ny=1, |
||||
pure_shear=True, |
||||
**source_params) |
||||
|
||||
# Recalculate slip, that rupture magnitude fits given magnitude |
||||
magnitude = 6.0 |
||||
dyn_rupture.rescale_slip(magnitude=magnitude, store=store) |
||||
|
||||
# Get rake out of slip (can differ from traction rake!) |
||||
slip = dyn_rupture.get_slip() |
||||
source_params['rake'] = num.arctan2(slip[0, 1], slip[0, 0]) * r2d |
||||
|
||||
# Create similar rectangular source model with rake derivded from slip |
||||
rect_rupture = gf.RectangularSource( |
||||
magnitude=magnitude, |
||||
**source_params) |
||||
|
||||
# Define static target grid to extract the surface displacement |
||||
ngrid = 40 |
||||
|
||||
obs_size = 10. * km |
||||
ntargets = ngrid**2 |
||||
|
||||
norths = num.linspace(-obs_size, obs_size, ngrid) + \ |
||||
source_params['north_shift'] |
||||
easts = num.linspace(-obs_size, obs_size, ngrid) + \ |
||||
source_params['east_shift'] |
||||
|
||||
norths2d = num.repeat(norths, len(easts)) |
||||
easts2d = num.tile(easts, len(norths)) |
||||
|
||||
static_target = gf.StaticTarget( |
||||
lats=num.ones(norths2d.size) * dyn_rupture.effective_lat, |
||||
lons=num.ones(norths2d.size) * dyn_rupture.effective_lon, |
||||
north_shifts=norths2d.ravel(), |
||||
east_shifts=easts2d.ravel(), |
||||
interpolation='nearest_neighbor', |
||||
store_id=store_id) |
||||
|
||||
# Get static surface displacements for rectangular and pseudo dynamic source |
||||
result = engine.process(rect_rupture, static_target) |
||||
|
||||
targets_static = result.request.targets_static |
||||
synth_disp_rect = result.results_list[0][0].result |
||||
|
||||
result = engine.process(dyn_rupture, static_target) |
||||
|
||||
targets_static = result.request.targets_static |
||||
N = targets_static[0].coords5[:, 2] |
||||
E = targets_static[0].coords5[:, 3] |
||||
synth_disp_dyn = result.results_list[0][0].result |
||||
|
||||
# Extract static vertical displacement and plot |
||||
down_rect = synth_disp_rect['displacement.d'] |
||||
down_dyn = synth_disp_dyn['displacement.d'] |
||||
down_diff = down_rect - down_dyn |
||||
|
||||
vmin = num.min([down_rect, down_dyn, down_diff]) |
||||
vmax = num.max([down_rect, down_dyn, down_diff]) |
||||
|
||||
fig, axes = plt.subplots(3, 1, sharex=True) |
||||
|
||||
for ax, (down, label) in zip( |
||||
axes, |
||||
zip((down_rect, down_dyn, down_diff), |
||||
(r'$u_{Z, rect}$', r'$u_{Z, dyn}$', r'$\Delta u_{Z}$'))): |
||||
cntr = ax.tricontourf( |
||||
E, N, down, levels=14, cmap='RdBu_r', |
||||
vmin=vmin, |
||||
vmax=vmax) |
||||
|
||||
cbar = fig.colorbar( |
||||
cntr, |
||||
ax=ax, |
||||
orientation='vertical', |
||||
aspect=10, |
||||
shrink=1.) |
||||
|
||||
cbar.ax.set_ylabel(label + ' [m]') |
||||
|
||||
ax.set_ylabel('Easting [m]') |
||||
|
||||
axes[-1].set_xlabel('Northing [m]') |
||||
|
||||
plt.show() |
@ -0,0 +1,65 @@
|
||||
import os.path as op |
||||
|
||||
from pyrocko import gf |
||||
|
||||
km = 1e3 |
||||
|
||||
# The store we are going extract data from: |
||||
store_id = 'crust2_mf' |
||||
|
||||
# First, download a Greens Functions store. If you already have one that you |
||||
# would like to use, you can skip this step and point the *store_superdirs* in |
||||
# the next step to that directory. |
||||
if not op.exists(store_id): |
||||
gf.ws.download_gf_store(site='kinherd', store_id=store_id) |
||||
|
||||
# We need a pyrocko.gf.Engine object which provides us with the traces |
||||
# extracted from the store. In this case we are going to use a local |
||||
# engine since we are going to query a local store. |
||||
engine = gf.LocalEngine(store_superdirs=['.'], use_config=True) |
||||
|
||||
# The dynamic parameter used for discretization of the PseudoDynamicRupture are |
||||
# extracted from the stores config file. |
||||
store = engine.get_store(store_id) |
||||
|
||||
# Let's define the source now with its extension, orientation etc. |
||||
dyn_rupture = gf.PseudoDynamicRupture( |
||||
# At lat 0. and lon 0. (default) |
||||
north_shift=2.*km, |
||||
east_shift=2.*km, |
||||
depth=3.*km, |
||||
strike=43., |
||||
dip=89., |
||||
rake=88., |
||||
|
||||
length=26.*km, |
||||
width=12.*km, |
||||
|
||||
nx=10, |
||||
ny=5, |
||||
|
||||