Version:
This tutorial is presented as Python code running inside a Jupyter Notebook, the recommended way to use Salvus. To run it yourself you can copy/type each individual cell or directly download the full notebook, including all required files.

Continental Scale FWI Tutorial - Part 4: Iterative inversion

It is finally time to start the inversion and compute model updates.
A quick recap of what we have done so far:
  • Part 1 collected data for several earthquakes and stations all across Europe.
  • Part 2 set up the domain and physics we need for creating simulated data.
  • Part 3 prepared a dataset for the inversion and configured how to compare simulated seismograms to the observed data
Full-waveform inversion is a non-linear problem that can only be solved iteratively. This entails several tasks of orchestrating the recurring simulations to create synthetic seismograms, compute misfits and sensitivities with respect to changes of the model, preconditioning and updating the model.
The scientific question is how we can formulate this as an optimization problem such that we converge toward the "true Earth" with as little computational cost as possible.
Let's get started!
Copy
import os

MIN_PERIOD = 70.0
MAX_PERIOD = 120.0
SIMULATION_TIME_IN_SECONDS = 1200.0
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
RANKS_PER_JOB = 4
PROJECT_DIR = "project_dir_central_europe"

period_band_name = f"{int(MIN_PERIOD)}_{int(MAX_PERIOD)}_seconds"
To safe some time, we will only iterate on a subset of events.
Make sure to use the same events for which we have selected windows in the previous notebook.
SELECTED_EVENTS = [
    "event_CRETE_GREECE_Mag_6.15_2015-04-16-18-07",
    "event_ICELAND_REGION_Mag_5.75_2020-06-20-19-26",
    "event_STRAIT_OF_GIBRALTAR_Mag_6.38_2016-01-25-04-22",
]
# Load the project with the data from the previous parts.
from salvus import namespace as sn
p = sn.Project(path=PROJECT_DIR)

Setting up an Inverse Problem

Inverse problems are "ill-posed", which makes them hard to solve. Specifically, inverse modelling requires to carefully set up the interplay of several components in order to retrieve a reasonable model as the result of the inversion. This entails several design choices:

Data

  • Which events to consider? (events)
  • How to compare synthetic to observed data? (misfit_configuration)

Model

  • What is the prior model? (prior_model)
  • Which parameters to invert for? (mapping)

Optimization

  • How to find a better model? (method)
  • Which additional information can be used to constrain the model? (preconditioner)

Workflow

  • Where to run the jobs? (job_submission)
The InverseProblemConfiguration collects these parameters to setup the inverse problem. Often enough, it is hard to choose the best setting a-prior, which is why the inverse problem is constructed as a tree that allows to branch off an ongoing inversion with changed parameters, or to run several scenarios concurrently.
Let's consider only two events at first. We will demonstrate how to add the third event to an ongoing inversion later on.
p += sn.InverseProblemConfiguration(
    name=f"inv_{period_band_name}",
    events=SELECTED_EVENTS[:2],
    misfit_configuration=f"tf_phase_misfit_{period_band_name}",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    prior_model=f"initial_model_{period_band_name}",
    mapping=sn.Mapping(
        scaling="relative_deviation_from_prior",
        inversion_parameters=["VSH", "VSV", "VP"],
        map_to_physical_parameters={
            "VPV": "VP",
            "VPH": "VP",
        },
        source_cutout_radius_in_meters=300000,
        receiver_cutout_radius_in_meters=50000,
    ),
    method=sn.TrustRegion(initial_trust_region_linf=0.02),
    preconditioner=sn.ModelDependentSmoothing(
        smoothing_lengths_in_wavelengths={
            "VSH": [0.2, 0.5, 0.5],
            "VSV": [0.2, 0.5, 0.5],
            "VP": [0.2, 0.5, 0.5],
        },
        reference_frequency_in_hertz=1.0 / MIN_PERIOD,
        reference_model="prior",
        reference_velocities={"VSH": "VSH", "VSV": "VSH", "VP": "VSH"},
    ),
    job_submission={
        "forward": sn.SiteConfig(
            site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=RANKS_PER_JOB
        ),
        "adjoint": sn.SiteConfig(
            site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=RANKS_PER_JOB
        ),
        "preconditioner": sn.SiteConfig(
            site_name="local", ranks_per_job=RANKS_PER_JOB
        ),
    },
)
Let's start by adding the first iteration.
p.inversions.add_iteration(
    inverse_problem_configuration=f"inv_{period_band_name}"
)
[2024-03-15 09:41:25,543] INFO: Adding new iteration #0.
True
The progress of the inversion can be visualized in a widget. At the moment, there is not a lot to show, obviously...
p.viz.nb.inversion(inverse_problem_configuration=f"inv_{period_band_name}")
Many steps within a single iteration involve expensive simulations, e.g., for computing misfits or adjoint simulations to compute gradients. This is why Salvus operates a task-based workflow.
In order to be able to closely monitor the progress, SalvusOpt steps through an iteration, and automatically dispatches simulations whenever necessary. The function resume will return whenever SalvusOpt is waiting for other tasks to finish first. Calling it several time, will step through the iteration in sequence. The log messages inform about the current status and tasks.
p.inversions.resume(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
[2024-03-15 09:41:26,309] INFO: Resuming iteration #0.
Current stage: initialize
[2024-03-15 09:41:26,309] INFO: 1 new tasks have been issued.
[2024-03-15 09:41:26,309] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:41:27,319] INFO: Submitting job array with 2 jobs ...
Uploading 1 files...
Uploading 1 files...

[2024-03-15 09:41:27,371] INFO: Launched adjoint simulations for 2 events. Please check again to see if they are finished.
[2024-03-15 09:41:27,371] INFO: Some tasks of iteration #0 are still running. Please check again later.
p.inversions.resume(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
[2024-03-15 09:41:27,378] INFO: Resuming iteration #0.
Current stage: check_convergence
[2024-03-15 09:41:27,378] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:41:27,503] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:41:27,549] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:41:27,550] INFO: Some tasks of iteration #0 are still running. Please check again later.
While the simulations are running, we can take a closer look at tasks within an iteration, and how they can efficiently be dealt with.
p.inversions.resume(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
[2024-03-15 09:41:27,556] INFO: Resuming iteration #0.
Current stage: check_convergence
[2024-03-15 09:41:27,557] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:41:27,685] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:41:27,723] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:41:27,724] INFO: Some tasks of iteration #0 are still running. Please check again later.
You can always visualize the current state of an iteration in a widget, where you find a lot of information about the model, misfits and gradients. The contents will be updated as you step through the iteration. The widget will be updated once gradients are available.
p.viz.nb.inversion(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
If you feel confident and don't want to be bothered with every single task, you can also tell Salvus to run an entire iteration at once. Note the parameter timeout_in_seconds, which will force the cell to return even if the iteration has not been completed yet, and there might still be a few simulations running in the back. Again, you can execute the cell several times or mix it with calls to the previous one until the iteration is complete.
p.inversions.iterate(
    inverse_problem_configuration=f"inv_{period_band_name}",
    timeout_in_seconds=1800,
    ping_interval_in_seconds=100,
)
[2024-03-15 09:41:28,187] INFO: Resuming iteration #0.

[2024-03-15 09:41:28,188] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:41:28,318] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:41:28,354] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:41:28,355] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-03-15 09:43:08,357] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:43:08,507] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:43:08,562] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:43:08,564] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-03-15 09:44:48,567] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:44:48,710] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:44:48,770] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:44:48,771] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-03-15 09:46:28,773] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:46:28,902] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:46:29,394] INFO: 
Iteration 0: Number of events: 2	 chi = 308.4717891328537	 ||g|| = 1.222967280451441e-05
pred = ---	ared = ---	norm_update = ---	tr_radius = ---
[2024-03-15 09:46:29,395] INFO: 1 new tasks have been issued.
[2024-03-15 09:46:29,396] INFO: Processing task `preconditioner`

[2024-03-15 09:46:29,667] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-03-15 09:48:09,698] INFO: Processing task `preconditioner`
[2024-03-15 09:48:09,983] INFO: 1 new tasks have been issued.
[2024-03-15 09:48:09,984] INFO: Processing task `misfit`
[2024-03-15 09:48:10,166] INFO: Submitting job array with 2 jobs ...

[2024-03-15 09:48:10,241] INFO: Launched simulations for 2 events. Please check again to see if they are finished.
[2024-03-15 09:48:10,241] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-03-15 09:49:50,342] INFO: Processing task `misfit`
[2024-03-15 09:49:51,087] INFO: 
old misfit control group: 308.4717891328537
new misfit control group: 220.000211222491
predicted reduction control group: -44.11213423327639
actual reduction control group: -88.4715779103627
2 out of 2 event(s) improved the misfit.
[2024-03-15 09:49:51,088] INFO: 
Model update accepted.
[2024-03-15 09:49:51,088] INFO: 1 new tasks have been issued.
[2024-03-15 09:49:51,088] INFO: Processing task `finalize_iteration`
[2024-03-15 09:49:51,258] INFO: Succesfully completed iteration #0.
[2024-03-15 09:49:51,259] INFO: Adding new iteration #1.
Here are some more details on the preconditioner, and how the trust region method determines model updates.
At the end of an iteration, a new iteration with the previous model update is automatically added.
We can now visualize the entire inversion in a widget to get an overview of the evolution of models and misfits during the iterations.
p.viz.nb.inversion(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
Before continuing with more iterations, let's have a more detailed look at intermediate data of the iteration.
p.viz.nb.gradients(
    simulation_configuration=f"initial_model_{period_band_name}",
    misfit_configuration=f"tf_phase_misfit_{period_band_name}",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    events=SELECTED_EVENTS[:2],
)
p.actions.inversion.sum_gradients(
    simulation_configuration=f"initial_model_{period_band_name}",
    misfit_configuration=f"tf_phase_misfit_{period_band_name}",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    events=SELECTED_EVENTS[:2],
)
<salvus.mesh.unstructured_mesh.UnstructuredMesh at 0x7fec8825ad90>
The widget above provides only a preview of the model, and there are a lot more details to discover when visualizing models and gradients in Paraview. The cell below prints the model directory of the first iteration. Copy the path and use scp to transfer the data to your local machine.
print(
    p.inversions.get_iteration_directory(
        inverse_problem_configuration=f"inv_{period_band_name}", iteration_id=0
    ).absolute()
)
/tmp/tmpzmy1cfxt/project_dir_central_europe/INVERSIONS/inv_70_120_seconds/00000
Before we explore the model in Paraview, let's continue to run the inversion in the background.
Instead of continuing with the previous set of events, we can now add the third event. We can simply do so by taking all from the previous iteration and adding the desired events.
Here we first add the event to the inversion at large, and subsequently, we create a new iteration that explicitly also includes new events. By default, the created new iteration will inherit the events selected by its parent.
p.inversions.add_events(
    f"inv_{period_band_name}",
    SELECTED_EVENTS[-1],
)

previous_events = p.inversions.get_iteration(
    f"inv_{period_band_name}", 0
).events

new_events = [
    SELECTED_EVENTS[-1],
]

p.inversions.add_iteration(
    inverse_problem_configuration=f"inv_{period_band_name}",
    parent_id=0,
    events=previous_events + new_events,
)
[2024-03-15 09:49:53,071] INFO: Adding new iteration #2.
True
Let's have a look at the inversion tree. You will notice that we now have two iterations that inherit from the first iteration. While iteration #1 was automatically created previously, we have now added iteration #2 which operates on the same model, but contains the three events. You can hover over the green nodes in the graph to see this info. By default, p.inversion.iterate will always continue on the last added iteration marked by the green edge in the inversion tree.
The misfit for the third event has not yet been computed, but SalvusOpt will automatically trigger the simulation once we continue with the inversion.
p.viz.nb.inversion(
    inverse_problem_configuration=f"inv_{period_band_name}",
)
The first iteration was only one step in model space to reduce the misfit, but the nonlinear problem will take many iterations to converge, of course. We can loop around the iterate function and create a few more model updates.
for i in range(2):
    p.inversions.iterate(
        inverse_problem_configuration=f"inv_{period_band_name}",
        timeout_in_seconds=3600,
        ping_interval_in_seconds=120,
    )
[2024-03-15 09:49:53,806] INFO: Resuming iteration #2.

[2024-03-15 09:49:53,806] INFO: 2 new tasks have been issued.
[2024-03-15 09:49:53,807] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:49:53,903] INFO: Submitting job ...
[2024-03-15 09:49:53,960] INFO: Launched simulations for 1 events. Please check again to see if they are finished.
[2024-03-15 09:49:53,960] INFO: Processing task `gradient`
[2024-03-15 09:49:54,121] INFO: Submitting job array with 2 jobs ...
Uploading 1 files...
Uploading 1 files...

[2024-03-15 09:49:54,165] INFO: Launched adjoint simulations for 2 events. Please check again to see if they are finished.
[2024-03-15 09:49:54,165] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 09:51:54,168] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:51:54,809] INFO: Submitting job ...
Uploading 1 files...

🚀  Submitted job_2403150951812639_17c0863822@local
[2024-03-15 09:51:54,870] INFO: Launched adjoint simulations for 1 events. Please check again to see if they are finished.
[2024-03-15 09:51:54,872] INFO: Processing task `gradient`
[2024-03-15 09:51:54,976] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:51:55,035] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:51:55,036] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 09:53:55,039] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:53:55,214] INFO: 1 events have already been submitted. They will not be submitted again.
[2024-03-15 09:53:55,273] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:53:55,275] INFO: Processing task `gradient`
[2024-03-15 09:53:55,449] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:53:55,528] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 09:53:55,530] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 09:55:55,536] INFO: Processing task `misfit_and_gradient`
[2024-03-15 09:55:55,611] INFO: 1 events have already been submitted. They will not be submitted again.
[2024-03-15 09:55:55,851] INFO: Processing task `gradient`
[2024-03-15 09:55:55,915] INFO: 2 events have already been submitted. They will not be submitted again.
[2024-03-15 09:55:56,418] INFO: 
Iteration 2: Number of events: 3	 chi = 256.81835553496404	 ||g|| = 1.1361320832462406e-05
pred = -44.11213423327639	ared = -88.4715779103627	norm_update = 9517195.57521609	tr_radius = 9517195.57521609
[2024-03-15 09:55:56,549] INFO: 1 new tasks have been issued.
[2024-03-15 09:55:56,550] INFO: Processing task `preconditioner`

[2024-03-15 09:55:56,857] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 09:57:56,940] INFO: Processing task `preconditioner`
[2024-03-15 09:57:57,244] INFO: 1 new tasks have been issued.
[2024-03-15 09:57:57,244] INFO: Processing task `misfit`
[2024-03-15 09:57:57,434] INFO: Submitting job array with 3 jobs ...

[2024-03-15 09:57:57,514] INFO: Launched simulations for 3 events. Please check again to see if they are finished.
[2024-03-15 09:57:57,515] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 09:59:57,651] INFO: Processing task `misfit`
[2024-03-15 09:59:57,728] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-03-15 10:01:57,942] INFO: Processing task `misfit`
[2024-03-15 10:01:59,149] INFO: 
old misfit control group: 256.81835553496404
new misfit control group: 163.90660343068012
predicted reduction control group: -67.50845076105418
actual reduction control group: -92.91175210428392
3 out of 3 event(s) improved the misfit.
[2024-03-15 10:01:59,149] INFO: 
Model update accepted.
[2024-03-15 10:01:59,149] INFO: 1 new tasks have been issued.
[2024-03-15 10:01:59,150] INFO: Processing task `finalize_iteration`
[2024-03-15 10:01:59,447] INFO: Succesfully completed iteration #2.
[2024-03-15 10:01:59,450] INFO: Adding new iteration #3.
[2024-03-15 10:01:59,473] INFO: Resuming iteration #3.

[2024-03-15 10:01:59,473] INFO: 1 new tasks have been issued.
[2024-03-15 10:01:59,473] INFO: Processing task `gradient`
[2024-03-15 10:01:59,692] INFO: Submitting job array with 3 jobs ...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...

[2024-03-15 10:01:59,749] INFO: Launched adjoint simulations for 3 events. Please check again to see if they are finished.
[2024-03-15 10:01:59,749] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:03:59,752] INFO: Processing task `gradient`
[2024-03-15 10:03:59,876] INFO: 3 events have already been submitted. They will not be submitted again.
[2024-03-15 10:03:59,947] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 10:03:59,947] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:05:59,951] INFO: Processing task `gradient`
[2024-03-15 10:06:00,136] INFO: 3 events have already been submitted. They will not be submitted again.
[2024-03-15 10:06:00,228] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 10:06:00,229] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:08:00,238] INFO: Processing task `gradient`
[2024-03-15 10:08:00,525] INFO: 3 events have already been submitted. They will not be submitted again.
[2024-03-15 10:08:00,673] INFO: Some simulations are still running. Please check again to see if they are finished.
[2024-03-15 10:08:00,692] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:10:00,706] INFO: Processing task `gradient`
[2024-03-15 10:10:00,820] INFO: 3 events have already been submitted. They will not be submitted again.
[2024-03-15 10:10:01,536] INFO: 
Iteration 3: Number of events: 3	 chi = 163.9066034306801	 ||g|| = 1.03417046189998e-05
pred = -67.50845076105418	ared = -92.91175210428392	norm_update = 19034391.514349777	tr_radius = 19034391.15043218
[2024-03-15 10:10:01,778] INFO: 1 new tasks have been issued.
[2024-03-15 10:10:01,779] INFO: Processing task `preconditioner`

[2024-03-15 10:10:02,218] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:12:02,379] INFO: Processing task `preconditioner`
[2024-03-15 10:12:02,858] INFO: 1 new tasks have been issued.
[2024-03-15 10:12:02,858] INFO: Processing task `misfit`
[2024-03-15 10:12:03,143] INFO: Submitting job array with 3 jobs ...

[2024-03-15 10:12:03,240] INFO: Launched simulations for 3 events. Please check again to see if they are finished.
[2024-03-15 10:12:03,241] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:14:03,563] INFO: Processing task `misfit`
[2024-03-15 10:14:03,708] INFO: Some tasks of iteration #3 are still running. Please check again later.
[2024-03-15 10:16:04,246] INFO: Processing task `misfit`
[2024-03-15 10:16:05,560] INFO: 
old misfit control group: 163.90660343068012
new misfit control group: 141.75768151181185
predicted reduction control group: -17.024869272432838
actual reduction control group: -22.148921918868268
3 out of 3 event(s) improved the misfit.
[2024-03-15 10:16:05,561] INFO: 
Model update accepted.
[2024-03-15 10:16:05,561] INFO: 1 new tasks have been issued.
[2024-03-15 10:16:05,561] INFO: Processing task `finalize_iteration`
[2024-03-15 10:16:06,069] INFO: Succesfully completed iteration #3.
[2024-03-15 10:16:06,073] INFO: Adding new iteration #4.
p.viz.nb.inversion(inverse_problem_configuration=f"inv_{period_band_name}")
The trust-region method ensures that the cumulative misfit of all selected events goes down. This is of course only an incomplete picture of what happened. SalvusProject offers a few ways to analyze the data in detail.
One option is to have a look at the misfit reduction from the starting model to the final iteration at each receiver on a map. Keep in mind that the misfit at each receiver is still summed over all components and windows.
p.viz.nb.misfit_comparison(
    reference_data=f"initial_model_{period_band_name}",
    other_data=[
        p.inversions.get_simulation_name(
            inverse_problem_configuration=f"inv_{period_band_name}",
            iteration_id=4,
        )
    ],
    misfit_configuration=f"tf_phase_misfit_{period_band_name}",
    event=SELECTED_EVENTS[-1],
)
Misfit comparison for event 'event_STRAIT_OF_GIBRALTAR_Mag_6.38_2016-01-25-04-22' and misfit configuration 'tf_phase_misfit_70_120_seconds'.
  ini... (reference) inv... Reduction inv...
II.BORG.00 5.7530e+01 5.3255e+01 4.2743e+00
II.ESK.00 6.3279e+01 2.9680e+01 3.3599e+01
II.LVZ.00 3.7027e+01 2.1928e+01 1.5099e+01
II.OBN.00 3.9500e+00 3.1830e+00 7.6700e-01
IU.GRFO. 5.9321e+01 2.0406e+01 3.8915e+01
IU.KEV.00 6.0323e+01 1.6189e+01 4.4134e+01
IU.KONO.00 3.6185e+01 2.4987e+01 1.1199e+01
IU.MACI. 5.2442e+01 3.8249e+01 1.4193e+01
IU.PAB.00 2.5385e+00 1.8415e+00 6.9702e-01
<pandas.io.formats.style.Styler at 0x7fec86adeb10>
Another option is to look at misfit statistics in the form of histograms.
p.viz.misfit_histogram(
    simulation_configuration_a=f"initial_model_{period_band_name}",
    simulation_configuration_b=p.inversions.get_simulation_name(
        inverse_problem_configuration=f"inv_{period_band_name}", iteration_id=4
    ),
    misfit_configuration=f"tf_phase_misfit_{period_band_name}",
    events=SELECTED_EVENTS[-1],
    merge_all_components=False,
)
Last but not least the most important thing is that the waveform got better so let's now also take a look at the waveforms after the three iterations. The misfit has been reduced for all events. And although the changes are small, we do observe a better phase match on average and on some stations the difference is significant. Check out the event STRAIT_OF_GIBRALTAR and station GB.GAL1 for a good example. Note that only the parts of the waveforms within the shaded windows informed the inverse problem about the model space. Interestingly, however, as we approach better models some wiggles that were not selected also match the data better now then they did initially; see station RO.BUR31 for an example. We could make use of this, re-pick windows and then continue with more iterations and a modified MisfitConfiguration.
p.viz.nb.waveforms(
    [
        f"PROCESSED_DATA:{period_band_name}",
        f"initial_model_{period_band_name}",
        p.inversions.get_simulation_name(
            inverse_problem_configuration=f"inv_{period_band_name}",
            iteration_id=4,
        ),
    ],
    receiver_field="displacement",
    data_selection_configuration=f"initial_selection_{period_band_name}",
)
That's the end of the 4-part tutorial on continental waveform inversion.
Although we restricted the dataset to only three events, we have seen all the ingredients to automate the entire toolchain for full-waveform inversion from composing a dataset to computing model updates.
In fact, this is not the end, but rather the starting point to dive into more complicated domains and settings.
Keep in mind that there are tons of options to play around with that will help to find the best setup for the inversion.
PAGE CONTENTS