ids app: implementation of report (WIP)
parent
7ed5cc1363
commit
68c9d8a2dc
@ -0,0 +1,76 @@
|
||||
# GPLv3
|
||||
#
|
||||
# The Developers, 21st Century
|
||||
import logging
|
||||
|
||||
import numpy as num
|
||||
|
||||
logger = logging.getLogger('ewrica.scaling')
|
||||
|
||||
km = 1e3
|
||||
|
||||
|
||||
def length_blaser(magnitude, rake):
|
||||
'''Scaling relation for rupture length following Blaser et al., 2010
|
||||
|
||||
The standard deviation is taken into account leading to slightly different
|
||||
results.
|
||||
|
||||
:param magnitude: Moment magnitude Mw
|
||||
:type magnitude: float
|
||||
:param rake: rake angle in degrees on rupture plane
|
||||
:type rake: float
|
||||
|
||||
:returns: rupture length in m
|
||||
:rtypev float
|
||||
'''
|
||||
rake = (rake % 360.) - 180.
|
||||
|
||||
if rake < 135 and rake > 45:
|
||||
ls = 0.18
|
||||
lcov = num.matrix([[26.14, -3.67], [-3.67, 0.52]]) * 1e-5
|
||||
la, lb = num.random.multivariate_normal([-2.37, 0.57], lcov)
|
||||
|
||||
elif rake > -135 and rake < -45:
|
||||
ls = 0.18
|
||||
lcov = num.matrix([[222.24, -32.34], [-32.34, 4.75]]) * 1e-5
|
||||
la, lb = num.random.multivariate_normal([-1.91, 0.52], lcov)
|
||||
|
||||
else:
|
||||
ls = 0.18
|
||||
lcov = num.matrix([[12.37, -1.94], [-1.94, 0.31]]) * 1e-5
|
||||
la, lb = num.random.multivariate_normal([-2.69, 0.64], lcov)
|
||||
|
||||
return 10**(num.random.normal(magnitude * lb + la, ls**2)) * km
|
||||
|
||||
|
||||
def width_blaser(magnitude, rake):
|
||||
'''Scaling relation for rupture width following Blaser et al., 2010
|
||||
|
||||
The standard deviation is taken into account leading to slightly different
|
||||
results.
|
||||
|
||||
:param magnitude: Moment magnitude Mw
|
||||
:type magnitude: float
|
||||
:param rake: rake angle in degrees on rupture plane
|
||||
:type rake: float
|
||||
|
||||
:returns: rupture width in m
|
||||
:rtypev float
|
||||
'''
|
||||
if rake < 135 and rake > 45:
|
||||
ws = 0.17
|
||||
wcov = num.matrix([[27.47, -3.77], [-3.77, 0.52]]) * 1e-5
|
||||
wa, wb = num.random.multivariate_normal([-1.86, 0.46], wcov)
|
||||
|
||||
elif rake > -135 and rake < -45:
|
||||
ws = 0.16
|
||||
wcov = num.matrix([[264.18, -42.02], [-42.02, 6.73]]) * 1e-5
|
||||
wa, wb = num.random.multivariate_normal([-1.20, 0.36], wcov)
|
||||
|
||||
else:
|
||||
ws = 0.15
|
||||
wcov = num.matrix([[13.48, -2.18], [-2.18, 0.36]]) * 1e-5
|
||||
wa, wb = num.random.multivariate_normal([-1.12, 0.33], wcov)
|
||||
|
||||
return 10**(num.random.normal(magnitude * wb + wa, ws**2)) * km
|
@ -0,0 +1,4 @@
|
||||
# GPLv3
|
||||
#
|
||||
# The Developers, 21st Century
|
||||
from .base import * # noqa
|
@ -0,0 +1,108 @@
|
||||
# GPLv3
|
||||
#
|
||||
# The Developers, 21st Century
|
||||
import os
|
||||
import os.path as op
|
||||
|
||||
import numpy as num
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from pyrocko import model
|
||||
from pyrocko.guts import Bool, Object
|
||||
from pyrocko.plot.dynamic_rupture import make_colormap
|
||||
from pyrocko.plot import mpl_init, mpl_papersize
|
||||
|
||||
from ewrica.sources import load_sources, EwricaIDSSource
|
||||
from ewrica.io import ids as idsio
|
||||
from ewrica.plot import ids as idsplot
|
||||
|
||||
mpl_init(fontsize=15)
|
||||
|
||||
km = 1e3
|
||||
|
||||
|
||||
runs = [d for d in os.listdir('.') if op.isdir(d) and 'curved' not in d]
|
||||
for run in runs:
|
||||
source = load_sources(filename=op.join(run, 'results', 'idssource.yaml'))[0]
|
||||
print(run, source.misfit)
|
||||
|
||||
|
||||
class Plotter(Object):
|
||||
source = EwricaIDSSource.T()
|
||||
|
||||
|
||||
class MapPlotter(Plotter):
|
||||
show_grid = Bool.T(default=True)
|
||||
show_topo = Bool.T(default=False)
|
||||
|
||||
@property
|
||||
def basemap(self):
|
||||
source = self.source
|
||||
|
||||
return idsplot.RuptureMap(
|
||||
source=source,
|
||||
lat=source.lat, lon=source.lon,
|
||||
radius=source.length/2.,
|
||||
show_topo=self.show_topo,
|
||||
show_grid=self.show_grid)
|
||||
|
||||
|
||||
class FinalSlipMap(MapPlotter):
|
||||
def plot(self):
|
||||
m = self.basemap
|
||||
m.draw_dislocation()
|
||||
m.draw_nucleation_point()
|
||||
m.draw_top_edge()
|
||||
m.save(op.join(run, 'results', 'final_slip_map.png'))
|
||||
|
||||
|
||||
class FinalStaticGNSSMap(MapPlotter):
|
||||
def plot(self):
|
||||
gnss_obs, gnss_mod = idsio.load_obssyn_gnss(
|
||||
config_fn=op.join(run, 'input', 'ids_input.inp'))
|
||||
|
||||
m = self.basemap
|
||||
m.draw_dislocation()
|
||||
m.draw_nucleation_point()
|
||||
m.draw_top_edge()
|
||||
m.draw_gnss_data_fit(
|
||||
campaign_obs=gnss_obs, campaign_syn=gnss_mod, vertical=False)
|
||||
m.save(op.join(run, 'results', 'gnss_fit_horizontal_map.png'))
|
||||
|
||||
|
||||
class FinalSlipView(Plotter):
|
||||
def plot(self):
|
||||
v = idsplot.RuptureView(source=source)
|
||||
v.draw_dislocation()
|
||||
v.draw_nucleation_point()
|
||||
v.draw_dislocation_contour()
|
||||
v.save(op.join(run, 'results', 'final_slip_view.png'))
|
||||
|
||||
|
||||
class SourceTimeFunction(Plotter):
|
||||
def plot(self):
|
||||
v = idsplot.RuptureView(source=source)
|
||||
v.draw_source_dynamics('stf')
|
||||
v.save(op.join(run, 'results', 'stf.png'))
|
||||
|
||||
|
||||
class TracePlot(Plotter):
|
||||
def plot(self):
|
||||
idsplot.trace_view(
|
||||
source=source,
|
||||
waveform_paths=[op.join(run, 'results', 'traces.mseed')],
|
||||
filename=op.join(run, 'results', 'traces.png'),
|
||||
scale_mode='individual')
|
||||
|
||||
|
||||
plot_classes = [
|
||||
FinalSlipMap,
|
||||
FinalStaticGNSSMap,
|
||||
FinalSlipView,
|
||||
SourceTimeFunction,
|
||||
TracePlot]
|
||||
|
||||
|
||||
def create_report_plots():
|
||||
pass
|
||||
|
Loading…
Reference in New Issue