Skip to content

Commit

Permalink
Tutorials: update, include PT
Browse files Browse the repository at this point in the history
upgrade: conversion from ffo to ffi
FAQ: explain how to update from beta to 1.0
  • Loading branch information
hvasbath committed Mar 25, 2019
1 parent a288009 commit 4b6b1dd
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 107 deletions.
18 changes: 10 additions & 8 deletions beat/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,13 @@ def func(path, obj):
return func


def set_attribute(k, v):
def set_attribute(k, v, cond=None):
def func(path, obj):
obj[k] = v
if cond:
if obj[k] == cond:
obj[k] = v
else:
obj[k] = v

return func

Expand All @@ -67,12 +71,6 @@ def color_diff(diff):

def upgrade_config_file(fn, diff=True, update=[]):
rules = [
('beat.GeodeticConfig',
set_attribute(
'dataset_specific_residual_noise_estimation', False)),
('beat.SeismicConfig',
set_attribute(
'dataset_specific_residual_noise_estimation', False)),
('beat.SeismicConfig',
drop_attribute('blacklist')),
('beat.SeismicConfig',
Expand All @@ -86,6 +84,8 @@ def upgrade_config_file(fn, diff=True, update=[]):
'''))),
('beat.ProblemConfig',
drop_attribute('dataset_specific_residual_noise_estimation')),
('beat.ProblemConfig',
set_attribute('mode', 'ffi', 'ffo')),
('beat.WaveformFitConfig',
set_attribute('blacklist', [])),
('beat.WaveformFitConfig',
Expand All @@ -96,6 +96,8 @@ def upgrade_config_file(fn, diff=True, update=[]):
drop_attribute('stage')),
('beat.ParallelTemperingConfig',
set_attribute('resample', False)),
('beat.FFOConfig',
rename_class('beat.FFIConfig')),
]

def apply_rules(path, obj):
Expand Down
26 changes: 14 additions & 12 deletions data/examples/FullMT/config_geometry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ problem_config: !beat.ProblemConfig
seismic_config: !beat.SeismicConfig
datadir: ./
noise_estimator: !beat.SeismicNoiseAnalyserConfig
structure: non-toeplitz
pre_arrival_time: 5.0
structure: identity
pre_arrival_time: 3.0
pre_stack_cut: true
station_corrections: false
waveforms:
Expand Down Expand Up @@ -193,20 +193,22 @@ seismic_config: !beat.SeismicConfig
sample_rate: 1.0
rm_gfs: true
sampler_config: !beat.SamplerConfig
name: SMC
name: PT
progressbar: true
buffer_size: 5000
parameters: !beat.SMCConfig
buffer_size: 1000
parameters: !beat.ParallelTemperingConfig
tune_interval: 10
proposal_dist: MultivariateNormal
check_bnd: true
rm_flag: false
n_jobs: 4
n_steps: 100
n_chains: 1000
coef_variation: 1.0
stage: 0
proposal_dist: MultivariateNormal
update_covariances: true
n_samples: 50000
n_chains: 8
swap_interval: [10, 30]
beta_tune_interval: 1000
n_chains_posterior: 3
resample: false
thin: 1
burn: 0.6
hyper_sampler_config: !beat.SamplerConfig
name: Metropolis
progressbar: true
Expand Down
Binary file modified docs/_static/example1/FullMT_stage_-1_max.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/examples/FFI_kinematic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The new *config_ffi.yaml* will have an additional *seismic_config* and the *prob
Import results
^^^^^^^^^^^^^^
In this step we want to import the results from the previous two optimizations to the configuration file.
Firstly, we want to import the results from Example I(geometry optimization). But this time also the *seismic_config* is updated::
Firstly, we want to import the results from Example 2(geometry optimization). But this time also the *seismic_config* is updated::

beat import Laquila_kinematic --results=Laquila --mode=geometry --datatypes=geodetic,seismic

Expand Down Expand Up @@ -87,7 +87,7 @@ Calculate Green's Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Elementary GFs
==============
Now the Green's Functions store(s) have to be calculated again for the "geometry" problem with higher resolutions. Please remember `Example I <https://hvasbath.github.io/beat/examples/Rectangular.html#calculate-greens-functions>`__. There the optimization was run using Green's Functions depth and distance sampling of 4km with 0.5Hz sampling. This may be accurate enough for the *geometry* type of optimization, however, for a finite fault optimization the aim is to resolve details of the rupture propagation and the slip distribution. So the setup parameters of the "geometry" Green's Functions would need to be changed to higher resolution. In this case we want to use wavelengths of up to 0.5Hz ergo a depth and distance sampling of 1 km and 2Hz sample rate may be precise enough. Of course, these parameters depend on the problem setup and have to be adjusted individually for each problem! So please open the *Laquila/config_geometry.yaml* and edit the parameters accordingly.
Now the Green's Functions store(s) have to be calculated again for the "geometry" problem with higher resolutions. Please remember `Example 2 <https://hvasbath.github.io/beat/examples/Rectangular.html#calculate-greens-functions>`__. There the optimization was run using Green's Functions depth and distance sampling of 4km with 0.5Hz sampling. This may be accurate enough for the *geometry* type of optimization, however, for a finite fault optimization the aim is to resolve details of the rupture propagation and the slip distribution. So the setup parameters of the "geometry" Green's Functions would need to be changed to higher resolution. In this case we want to use wavelengths of up to 0.5Hz ergo a depth and distance sampling of 1 km and 2Hz sample rate may be precise enough. Of course, these parameters depend on the problem setup and have to be adjusted individually for each problem! So please open the *Laquila/config_geometry.yaml* and edit the parameters accordingly.
Running this calculation will take a long time depending on the number of CPUs at hand. (With 25 CPUs the calculation took approximately 15Hrs)::

beat build_gfs Laquila --datatypes='seismic' --execute
Expand Down Expand Up @@ -185,7 +185,7 @@ Please set the lower and upper bounds of the durations to 0. and 4. seconds, res

Also we need to specify the bounds on the rupture velocities. The shear-wave velocity from the velocity model is a good proxy for that. So please set the lower and upper bounds on the velocities to 2.2 and 4.5 [km/s], respectively. These velocities are sampled for each patch individually and indirectly determine the rupture onset time of each patch depending on the hypocentral location (*nucleation_dip* and *nucleation_strike*). To assure causal rupture propagation starting from the hypocentre the Eikonal equation is solved each forward calculation, which then determines the rupture onset time on each patch [Minson2013]_.

So far we defined everything with respect to the hypocentre, but we have to keep in mind that its location and the hypocentral time are unknowns as well. The time-shift with respect to the *event.time* has been determined in Example I before roughly assuming constant rupture velocity and uniform slip on the RectangularSource. Likely, the refined hypocentral time in this optimization will be converging to a similar time estimate as previously determined. This previously determined timing information has been imported as well in the "import results" - step. However, these bounds should be relaxed again as we are using different frequency content in the data and we allow for a much complexer optimization setup. Please set the lower and upper bounds for the *time* to -13. and 0., respectively.
So far we defined everything with respect to the hypocentre, but we have to keep in mind that its location and the hypocentral time are unknowns as well. The time-shift with respect to the *event.time* has been determined in Example 2 before roughly assuming constant rupture velocity and uniform slip on the RectangularSource. Likely, the refined hypocentral time in this optimization will be converging to a similar time estimate as previously determined. This previously determined timing information has been imported as well in the "import results" - step. However, these bounds should be relaxed again as we are using different frequency content in the data and we allow for a much complexer optimization setup. Please set the lower and upper bounds for the *time* to -13. and 0., respectively.


Finally, we are left with specifying the *duration_sampling* and *starttime_sampling* under the *seismic_config.gf_config*. These determine the steps taken between the upper and lower bounds for the *durations* and the discrete starttime-shifts.
Expand Down Expand Up @@ -219,7 +219,7 @@ Here we see the slip parallel traces for patch 0, at starttime (t0) of -1s (afte

Sample the solution space
^^^^^^^^^^^^^^^^^^^^^^^^^
Please refer to the 'Sample the solution space section' of `Example 1 <https://hvasbath.github.io/beat/examples/FullMT_regional.html#sample-the-solution-space>`__ Example for a more detailed description of the sampling and associated parameters.
Please refer to the 'Sample the solution space section' of `Example 2 <https://hvasbath.github.io/beat/examples/FullMT_regional.html#sample-the-solution-space>`__ Example for a more detailed description of the sampling and associated parameters.

Firstly, we only optimize for the noise scaling or hyperparameters (HPs) including the laplacian smoothing weight::

Expand Down Expand Up @@ -255,7 +255,7 @@ Here we are going to use *random* again, please set it now! We initially narrowe

The 'n_jobs' number should be set to as many CPUs as the user can spare under the *sampler_config*. The number of sampled MarkovChains and the number of steps for each chain of the SMC sampler should be set to high values as we are optimizing now for ca 500 random variables (if the values from the tutorial haven't been altered by the user); for example to 8000 and 400, respectively.

.. warning:: With these sampler parameters a huge amount of samples are going to be stored to disk! Please see `Example 1 <https://hvasbath.github.io/beat/examples/FullMT_regional.html#summarize-the-results>`__ for an instruction on how to keep only the important samples to reduce the disk usage.
.. warning:: With these sampler parameters a huge amount of samples are going to be stored to disk! Please see `Example 2 <https://hvasbath.github.io/beat/examples/Rectangular.html#summarize-and-plotting>`__ for an instruction on how to keep only the important samples to reduce the disk usage.

Finally, we are set to run the full optimization for the static slip-distribution with::

Expand Down
10 changes: 5 additions & 5 deletions docs/examples/FFI_static.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Example 3: static finite-fault optimization
---------------------------------------------

In this example we will determine a variable slip distribution for the L'aquila 2009 earthquake by using static InSAR data.
The data is the exact same from `example 2 <https://hvasbath.github.io/beat/examples/Rectangular.html#>`__, where the overall geometry of the fault plane was estimated.
It is a requirement to have example I completed in order to follow the instructions and commands given in this example.
The data is the exact same from `Example 2 <https://hvasbath.github.io/beat/examples/Rectangular.html#>`__, where the overall geometry of the fault plane was estimated.
It is a requirement to have Example 2 completed in order to follow the instructions and commands given in this example.

Please make sure that you are one level above the Laquila project folder (created earlier).::

Expand Down Expand Up @@ -60,7 +60,7 @@ The fault geometry needs to be defined in the *geodetic.gf_config.reference_sour
extension_lengths: [0.4]
sample_rate: 1.1574074074074073e-05

The values shown above are parts of the MAP solution from the optimization from example I. The results can been imported through the import command specifiying the --results option. We want to import the results from the *Laquila* project_directory from an optimization in *geometry* mode and we want to update the *geodetic* part of the *config_ffi.yaml*::
The values shown above are parts of the MAP solution from the optimization from Example 2. The results can been imported through the import command specifiying the --results option. We want to import the results from the *Laquila* project_directory from an optimization in *geometry* mode and we want to update the *geodetic* part of the *config_ffi.yaml*::

beat import Laquila --results=Laquila --mode='geometry' --datatypes=geodetic

Expand Down Expand Up @@ -175,7 +175,7 @@ Under the *problem_config* we find the parameters that we need to adjust::
Hierarchicals
=============

Please notice the hierarchicals parameters! These are the MAP parameters for the orbital ramps for each radar scene that have been optimized in example I.
Please notice the hierarchicals parameters! These are the MAP parameters for the orbital ramps for each radar scene that have been optimized in Example 2.
These parameters are imported if the *fit_plane* parameter in the *geodetic_config* was set to True. The default is to fix these ramp parameters during the static distributed slip optimization, because leaving them open often results in tradeoffs with patches at greater depth and thus artificial slip is optimized at greater depth.
Nevertheless, the user may want to try out to free the upper and lower bounds again to include the parameters into the optimization.

Expand Down Expand Up @@ -205,7 +205,7 @@ Once happy with the displayed changes the changes will be applied to the file wi

Sample the solution space
^^^^^^^^^^^^^^^^^^^^^^^^^
Please refer to the 'Sample the solution space section' of `example 0 <https://hvasbath.github.io/beat/examples/FullMT_regional.html#sample-the-solution-space>`__ example for a more detailed description of the sampling and associated parameters.
Please refer to the 'Sample the solution space section' of `example 2 <https://hvasbath.github.io/beat/examples/FullMT_regional.html#sample-the-solution-space>`__ example for a more detailed description of the sampling and associated parameters.

Firstly, we only optimize for the noise scaling or hyperparameters (HPs) including the laplacian smoothing weight::

Expand Down
Loading

0 comments on commit 4b6b1dd

Please sign in to comment.