Version:

Full-Waveform Inversion

Part 5 - Extensions

Copy
%matplotlib inline
# This notebook will use this variable to determine which
# remote site to run on.
import os
import numpy as np
import salvus.namespace as sn

SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
p = sn.Project(path="project")

Only update within a region of interest

In a typical USCT setup, there is always enough space between the ultrasound transducers and the phantom. What if we include that information as prior knowledge into our problem formulation?
An easy way of doing this, is to define a region of interest and restrict the reconstruction to this area.
To keep it simple, we just define a sphere with a radius of 6.5 cm as the target region.
mesh = p.simulations.get_mesh(simulation_configuration="initial_model")
# define the region of interest
roi = np.zeros_like(mesh.connectivity)
mask = np.linalg.norm(mesh.points[mesh.connectivity], axis=2) < 0.065
roi[mask] = 1.0
mesh.attach_field("region_of_interest", roi)
Let's see if this helps with the iterations. To be able to compare the results, we just create a new inverse problem within the same project, initialize the region of interest, and start iterating.
p += sn.InverseProblemConfiguration(
    name="my_second_inversion",
    prior_model="initial_model",
    events=p.events.list(),
    mapping=sn.Mapping(
        scaling="absolute",
        inversion_parameters=["VP", "RHO"],
        region_of_interest=mesh,
    ),
    preconditioner=sn.ConstantSmoothing({"VP": 0.01, "RHO": 0.01}),
    method=sn.TrustRegion(initial_trust_region_linf=10.0),
    misfit_configuration="L2",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    job_submission=sn.SiteConfig(
        site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=4
    ),
)
p.inversions.iterate(
    inverse_problem_configuration="my_second_inversion",
    timeout_in_seconds=360,
    ping_interval_in_seconds=10,
    delete_disposable_files="all",
)
[2024-11-15 13:41:34,995] INFO: Adding new iteration #0.
[2024-11-15 13:41:35,016] INFO: Resuming iteration #0.

[2024-11-15 13:41:35,016] INFO: 1 new tasks have been issued.
[2024-11-15 13:41:35,017] INFO: Processing task `misfit_and_gradient`
[2024-11-15 13:41:35,321] INFO: 
Iteration 0: Number of events: 5	 chi = 0.018681064754203797	 ||g|| = 0.016366358801050206
pred = ---	ared = ---	norm_update = ---	tr_radius = ---
[2024-11-15 13:41:35,321] INFO: 1 new tasks have been issued.
[2024-11-15 13:41:35,322] INFO: Processing task `preconditioner`

[2024-11-15 13:41:35,543] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:41:45,561] INFO: Processing task `preconditioner`
[2024-11-15 13:41:45,723] INFO: 1 new tasks have been issued.
[2024-11-15 13:41:45,724] INFO: Processing task `misfit`
[2024-11-15 13:41:45,787] INFO: Submitting job array with 5 jobs ...

[2024-11-15 13:41:45,932] INFO: Launched simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:41:45,933] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:41:55,968] INFO: Processing task `misfit`
[2024-11-15 13:41:58,758] INFO: 
old misfit control group: 0.018681064754203797
new misfit control group: 0.007802509365775308
predicted reduction control group: -0.005675405778715309
actual reduction control group: -0.010878555388428489
5 out of 5 event(s) improved the misfit.
[2024-11-15 13:41:58,758] INFO: 
Model update accepted.
[2024-11-15 13:41:58,759] INFO: 1 new tasks have been issued.
[2024-11-15 13:41:58,759] INFO: Processing task `finalize_iteration`
[2024-11-15 13:41:58,832] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00000
[2024-11-15 13:41:58,851] INFO: Freed up 1.2 MB of space.
[2024-11-15 13:41:58,854] INFO: Succesfully completed iteration #0.
[2024-11-15 13:41:58,856] INFO: Adding new iteration #1.
Let's see if the region of interest was considered when the model was updated.
p.viz.nb.inversion(inverse_problem_configuration="my_second_inversion")
Indeed, outside of the pre-defined sphere, the model is still constant and has the same values as the initial model.
Let's do a few more iterations and see what the reconstruction will be.
for i in range(2):
    p.inversions.iterate(
        inverse_problem_configuration="my_second_inversion",
        timeout_in_seconds=360,
        ping_interval_in_seconds=10,
        delete_disposable_files="all",
    )
p.viz.nb.inversion(inverse_problem_configuration="my_second_inversion")
[2024-11-15 13:42:00,322] INFO: Resuming iteration #1.

[2024-11-15 13:42:00,322] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:00,322] INFO: Processing task `gradient`
[2024-11-15 13:42:00,629] INFO: Submitting job array with 5 jobs ...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...

[2024-11-15 13:42:00,707] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:42:00,709] INFO: Some tasks of iteration #1 are still running. Please check again later.
[2024-11-15 13:42:10,711] INFO: Processing task `gradient`
[2024-11-15 13:42:11,040] INFO: 5 events have already been submitted. They will not be submitted again.
[2024-11-15 13:42:11,449] INFO: 
Iteration 1: Number of events: 5	 chi = 0.0078025093657753085	 ||g|| = 0.008438424180558228
pred = -0.005675405778715309	ared = -0.010878555388428489	norm_update = 0.7166324367619695	tr_radius = 0.7166322852767166
[2024-11-15 13:42:11,458] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:11,458] INFO: Processing task `preconditioner`

[2024-11-15 13:42:11,538] INFO: Some tasks of iteration #1 are still running. Please check again later.
[2024-11-15 13:42:21,559] INFO: Processing task `preconditioner`
[2024-11-15 13:42:21,676] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:21,677] INFO: Processing task `misfit`
[2024-11-15 13:42:21,716] INFO: Submitting job array with 5 jobs ...

[2024-11-15 13:42:21,805] INFO: Launched simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:42:21,806] INFO: Some tasks of iteration #1 are still running. Please check again later.
[2024-11-15 13:42:31,841] INFO: Processing task `misfit`
[2024-11-15 13:42:34,131] INFO: 
old misfit control group: 0.007802509365775308
new misfit control group: 0.0038977169133135496
predicted reduction control group: -0.0029460718526640095
actual reduction control group: -0.003904792452461758
5 out of 5 event(s) improved the misfit.
[2024-11-15 13:42:34,131] INFO: 
Model update accepted.
[2024-11-15 13:42:34,132] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:34,132] INFO: Processing task `finalize_iteration`
[2024-11-15 13:42:34,250] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00001
[2024-11-15 13:42:34,464] INFO: Freed up 4.8 MB of space.
[2024-11-15 13:42:34,465] INFO: Succesfully completed iteration #1.
[2024-11-15 13:42:34,468] INFO: Adding new iteration #2.
[2024-11-15 13:42:34,478] INFO: Resuming iteration #2.

[2024-11-15 13:42:34,478] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:34,479] INFO: Processing task `gradient`
[2024-11-15 13:42:34,813] INFO: Submitting job array with 5 jobs ...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...
Uploading 1 files...

[2024-11-15 13:42:34,912] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:42:34,914] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-11-15 13:42:44,920] INFO: Processing task `gradient`
[2024-11-15 13:42:45,149] INFO: 5 events have already been submitted. They will not be submitted again.
[2024-11-15 13:42:45,815] INFO: 
Iteration 2: Number of events: 5	 chi = 0.0038977169133135496	 ||g|| = 0.0038998099223934266
pred = -0.0029460718526640095	ared = -0.003904792452461758	norm_update = 0.7368817080094618	tr_radius = 1.4332645705534333
[2024-11-15 13:42:45,837] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:45,840] INFO: Processing task `preconditioner`

[2024-11-15 13:42:45,993] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-11-15 13:42:56,097] INFO: Processing task `preconditioner`
[2024-11-15 13:42:56,308] INFO: 1 new tasks have been issued.
[2024-11-15 13:42:56,309] INFO: Processing task `misfit`
[2024-11-15 13:42:56,379] INFO: Submitting job array with 5 jobs ...

[2024-11-15 13:42:56,544] INFO: Launched simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:42:56,548] INFO: Some tasks of iteration #2 are still running. Please check again later.
[2024-11-15 13:43:06,635] INFO: Processing task `misfit`
[2024-11-15 13:43:09,344] INFO: 
old misfit control group: 0.0038977169133135496
new misfit control group: 0.003293527922292616
predicted reduction control group: -0.00027362868818550537
actual reduction control group: -0.0006041889910209336
5 out of 5 event(s) improved the misfit.
[2024-11-15 13:43:09,345] INFO: 
Model update accepted.
[2024-11-15 13:43:09,345] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:09,346] INFO: Processing task `finalize_iteration`
[2024-11-15 13:43:09,484] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00002
[2024-11-15 13:43:09,677] INFO: Freed up 6.0 MB of space.
[2024-11-15 13:43:09,678] INFO: Succesfully completed iteration #2.
[2024-11-15 13:43:09,681] INFO: Adding new iteration #3.
This looks better, so the prior knowledge was indeed helpful.
Alternatively, we could specify point-wise lower and upper bounds on the model parameters In the example below, we allow deviations of +/- 20% in both VP and RHO, except for the previously selected region of interest, where we restrict VP updates to +/- 1 m/s.
Note that the mapping function does not contain a region of interest in this case.
p += sn.InverseProblemConfiguration(
    name="my_third_inversion",
    prior_model="initial_model",
    events=p.events.list(),
    mapping=sn.Mapping(
        scaling="absolute",
        inversion_parameters=["VP", "RHO"],
    ),
    preconditioner=sn.ConstantSmoothing({"VP": 0.01, "RHO": 0.01}),
    method=sn.TrustRegion(initial_trust_region_linf=10.0),
    misfit_configuration="L2",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    job_submission=sn.SiteConfig(
        site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=4
    ),
)
mesh = p.simulations.get_mesh("initial_model")
lb = mesh.copy()
ones = np.ones_like(lb.elemental_fields["VP"])
lb.elemental_fields["VP"] *= 0.8
lb.elemental_fields["RHO"] *= 0.8
lb.elemental_fields["VP"][roi < 0.5] = 1501.0

ub = mesh.copy()
ub.elemental_fields["VP"] *= 1.2
ub.elemental_fields["RHO"] *= 1.2
ub.elemental_fields["VP"][roi < 0.5] = 1502.0

p.inversions.set_constraints(
    inverse_problem_configuration="my_third_inversion",
    constraints={
        "lower_bounds": lb,
        "upper_bounds": ub,
    },
)
p.inversions.iterate(
    "my_third_inversion", timeout_in_seconds=360, delete_disposable_files="all"
)
p.viz.nb.inversion(inverse_problem_configuration="my_third_inversion")
[2024-11-15 13:43:10,836] INFO: Adding new iteration #0.
[2024-11-15 13:43:10,852] INFO: Resuming iteration #0.

[2024-11-15 13:43:10,852] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:10,853] INFO: Processing task `misfit_and_gradient`
[2024-11-15 13:43:11,347] INFO: 
Iteration 0: Number of events: 5	 chi = 0.018681064754203797	 ||g|| = 0.022700663670338374
pred = ---	ared = ---	norm_update = ---	tr_radius = ---
[2024-11-15 13:43:11,348] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:11,348] INFO: Processing task `preconditioner`

[2024-11-15 13:43:11,478] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:11,523] INFO: Processing task `preconditioner`
[2024-11-15 13:43:11,626] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:11,662] INFO: Processing task `preconditioner`
[2024-11-15 13:43:11,726] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:11,750] INFO: Processing task `preconditioner`
[2024-11-15 13:43:11,815] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:11,835] INFO: Processing task `preconditioner`
[2024-11-15 13:43:11,912] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:11,933] INFO: Processing task `preconditioner`
[2024-11-15 13:43:11,984] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,004] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,060] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,090] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,163] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,192] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,265] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,294] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,363] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,383] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,442] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,462] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,528] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,549] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,619] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,648] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,718] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,739] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,795] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,816] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,882] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,903] INFO: Processing task `preconditioner`
[2024-11-15 13:43:12,975] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:12,993] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,060] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,085] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,133] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,152] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,202] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,222] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,281] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,301] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,363] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,386] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,469] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,505] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,601] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,620] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,696] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,732] INFO: Processing task `preconditioner`
[2024-11-15 13:43:13,844] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:13,885] INFO: Processing task `preconditioner`
[2024-11-15 13:43:14,064] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:14,068] INFO: Processing task `misfit`
[2024-11-15 13:43:14,139] INFO: Submitting job array with 5 jobs ...

[2024-11-15 13:43:14,275] INFO: Launched simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:43:14,277] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:14,315] INFO: Processing task `misfit`
[2024-11-15 13:43:14,395] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:14,490] INFO: Processing task `misfit`
[2024-11-15 13:43:14,577] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:14,623] INFO: Processing task `misfit`
[2024-11-15 13:43:14,991] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,032] INFO: Processing task `misfit`
[2024-11-15 13:43:15,115] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,152] INFO: Processing task `misfit`
[2024-11-15 13:43:15,243] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,282] INFO: Processing task `misfit`
[2024-11-15 13:43:15,367] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,412] INFO: Processing task `misfit`
[2024-11-15 13:43:15,539] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,592] INFO: Processing task `misfit`
[2024-11-15 13:43:15,699] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:15,763] INFO: Processing task `misfit`
[2024-11-15 13:43:15,943] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:16,000] INFO: Processing task `misfit`
[2024-11-15 13:43:16,129] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:16,198] INFO: Processing task `misfit`
[2024-11-15 13:43:16,293] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:16,371] INFO: Processing task `misfit`
[2024-11-15 13:43:16,512] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:16,575] INFO: Processing task `misfit`
[2024-11-15 13:43:16,643] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:16,694] INFO: Processing task `misfit`
[2024-11-15 13:43:17,068] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,131] INFO: Processing task `misfit`
[2024-11-15 13:43:17,217] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,295] INFO: Processing task `misfit`
[2024-11-15 13:43:17,417] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,466] INFO: Processing task `misfit`
[2024-11-15 13:43:17,584] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,647] INFO: Processing task `misfit`
[2024-11-15 13:43:17,759] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,815] INFO: Processing task `misfit`
[2024-11-15 13:43:17,908] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:17,982] INFO: Processing task `misfit`
[2024-11-15 13:43:18,094] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,147] INFO: Processing task `misfit`
[2024-11-15 13:43:18,227] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,308] INFO: Processing task `misfit`
[2024-11-15 13:43:18,432] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,479] INFO: Processing task `misfit`
[2024-11-15 13:43:18,574] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,649] INFO: Processing task `misfit`
[2024-11-15 13:43:18,745] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,813] INFO: Processing task `misfit`
[2024-11-15 13:43:18,931] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:18,987] INFO: Processing task `misfit`
[2024-11-15 13:43:19,347] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,395] INFO: Processing task `misfit`
[2024-11-15 13:43:19,480] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,537] INFO: Processing task `misfit`
[2024-11-15 13:43:19,620] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,659] INFO: Processing task `misfit`
[2024-11-15 13:43:19,734] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,771] INFO: Processing task `misfit`
[2024-11-15 13:43:19,850] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,886] INFO: Processing task `misfit`
[2024-11-15 13:43:19,956] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:19,993] INFO: Processing task `misfit`
[2024-11-15 13:43:20,081] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:20,127] INFO: Processing task `misfit`
[2024-11-15 13:43:20,264] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:20,310] INFO: Processing task `misfit`
[2024-11-15 13:43:20,419] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:20,489] INFO: Processing task `misfit`
[2024-11-15 13:43:20,610] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:20,673] INFO: Processing task `misfit`
[2024-11-15 13:43:20,834] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:20,898] INFO: Processing task `misfit`
[2024-11-15 13:43:21,034] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:21,097] INFO: Processing task `misfit`
[2024-11-15 13:43:21,473] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:21,511] INFO: Processing task `misfit`
[2024-11-15 13:43:21,589] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:21,638] INFO: Processing task `misfit`
[2024-11-15 13:43:21,713] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:21,751] INFO: Processing task `misfit`
[2024-11-15 13:43:21,906] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:21,973] INFO: Processing task `misfit`
[2024-11-15 13:43:22,077] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:22,127] INFO: Processing task `misfit`
[2024-11-15 13:43:24,667] INFO: 
old misfit control group: 0.018681064754203797
new misfit control group: 0.009266712628118857
predicted reduction control group: -0.005269264615522084
actual reduction control group: -0.00941435212608494
5 out of 5 event(s) improved the misfit.
[2024-11-15 13:43:24,668] INFO: 
Model update accepted.
[2024-11-15 13:43:24,668] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:24,669] INFO: Processing task `finalize_iteration`
[2024-11-15 13:43:24,745] INFO: ... searching for obsolete files in project/INVERSIONS/my_third_inversion/00000
[2024-11-15 13:43:24,766] INFO: Freed up 1.2 MB of space.
[2024-11-15 13:43:24,767] INFO: Succesfully completed iteration #0.
[2024-11-15 13:43:24,769] INFO: Adding new iteration #1.
The example above is just meant to demonstrate the use of box constraints. For cases where lower and upper bounds are (almost) equal, we recommend using a region of interest instead.

Postprocessing model updates

It is sometimes helpful to let prior knowledge influence the model updates. There are inherent differences in the sensitivity with respect to the magnitude of some parameters, but we might use physical knowledge such as scaling relations between the parameters to tweak the proposed models. This can be achieved by a callback within the mapping function. In the following example, we only invert for VP, but use the following scaling relation for soft tissues to update RHO:
def scaling_relation_density(
    prior_model: sn.UnstructuredMesh,
    proposed_model: sn.UnstructuredMesh,
) -> sn.UnstructuredMesh:

    # Here we directly apply a scaling relation to the density model.
    # We don't need the prior model in this case.

    new_model = proposed_model.copy()
    new_model.elemental_fields["RHO"] = (
        0.893 * new_model.elemental_fields["VP"] - 349.0
    )

    return new_model
This callback will modify proposed model updates before recomputing the misfits. Strictly speaking, this results in inconsistent gradients, because we neglect density as an inversion parameter but because of the low sensitivity to density amplitudes, this does not impact the trust region algorithm much.
p += sn.InverseProblemConfiguration(
    name="my_fourth_inversion",
    prior_model="initial_model",
    events=p.events.list(),
    mapping=sn.Mapping(
        scaling="absolute",
        inversion_parameters=[
            "VP",
        ],
        postprocess_model_update=scaling_relation_density,
    ),
    preconditioner=sn.ConstantSmoothing({"VP": 0.01}),
    method=sn.TrustRegion(initial_trust_region_linf=10.0),
    misfit_configuration="L2",
    wavefield_compression=sn.WavefieldCompression(
        forward_wavefield_sampling_interval=10
    ),
    job_submission=sn.SiteConfig(
        site_name=SALVUS_FLOW_SITE_NAME, ranks_per_job=4
    ),
)
# Will be removed for the website.
p.inversions.set_stopping_criteria(
    inverse_problem_configuration="my_fourth_inversion",
    criteria={"max_iterations_global": 2},
)
p.inversions.iterate(
    "my_fourth_inversion",
    timeout_in_seconds=360,
    delete_disposable_files="all",
)
p.viz.nb.inversion(inverse_problem_configuration="my_fourth_inversion")
[2024-11-15 13:43:26,006] INFO: Adding new iteration #0.
[2024-11-15 13:43:26,016] INFO: Resuming iteration #0.

[2024-11-15 13:43:26,021] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:26,022] INFO: Processing task `misfit_and_gradient`
[2024-11-15 13:43:26,512] INFO: 
Iteration 0: Number of events: 5	 chi = 0.018681064754203797	 ||g|| = 0.02159122070536007
pred = ---	ared = ---	norm_update = ---	tr_radius = ---
[2024-11-15 13:43:26,513] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:26,513] INFO: Processing task `preconditioner`

[2024-11-15 13:43:26,611] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:26,631] INFO: Processing task `preconditioner`
[2024-11-15 13:43:26,679] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:26,699] INFO: Processing task `preconditioner`
[2024-11-15 13:43:26,761] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:26,790] INFO: Processing task `preconditioner`
[2024-11-15 13:43:26,855] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:26,883] INFO: Processing task `preconditioner`
[2024-11-15 13:43:26,955] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:26,983] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,040] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,059] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,140] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,165] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,231] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,263] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,330] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,363] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,452] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,467] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,524] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,549] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,603] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,623] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,670] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,692] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,783] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,811] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,884] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,915] INFO: Processing task `preconditioner`
[2024-11-15 13:43:27,966] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:27,983] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,053] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,088] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,160] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,197] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,264] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,292] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,348] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,364] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,416] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,439] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,525] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,555] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,623] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,664] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,745] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,776] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,859] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,887] INFO: Processing task `preconditioner`
[2024-11-15 13:43:28,954] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:28,987] INFO: Processing task `preconditioner`
[2024-11-15 13:43:29,051] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:29,078] INFO: Processing task `preconditioner`
[2024-11-15 13:43:29,129] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:29,149] INFO: Processing task `preconditioner`
[2024-11-15 13:43:29,211] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:29,232] INFO: Processing task `preconditioner`
[2024-11-15 13:43:29,364] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:29,364] INFO: Processing task `misfit`
[2024-11-15 13:43:29,436] INFO: Submitting job array with 5 jobs ...

[2024-11-15 13:43:29,906] INFO: Launched simulations for 5 events. Please check again to see if they are finished.
[2024-11-15 13:43:29,907] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:29,943] INFO: Processing task `misfit`
[2024-11-15 13:43:30,019] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,068] INFO: Processing task `misfit`
[2024-11-15 13:43:30,149] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,187] INFO: Processing task `misfit`
[2024-11-15 13:43:30,287] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,325] INFO: Processing task `misfit`
[2024-11-15 13:43:30,443] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,498] INFO: Processing task `misfit`
[2024-11-15 13:43:30,571] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,612] INFO: Processing task `misfit`
[2024-11-15 13:43:30,690] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,733] INFO: Processing task `misfit`
[2024-11-15 13:43:30,806] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,838] INFO: Processing task `misfit`
[2024-11-15 13:43:30,925] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:30,956] INFO: Processing task `misfit`
[2024-11-15 13:43:31,037] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,075] INFO: Processing task `misfit`
[2024-11-15 13:43:31,147] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,189] INFO: Processing task `misfit`
[2024-11-15 13:43:31,269] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,302] INFO: Processing task `misfit`
[2024-11-15 13:43:31,374] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,428] INFO: Processing task `misfit`
[2024-11-15 13:43:31,500] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,551] INFO: Processing task `misfit`
[2024-11-15 13:43:31,877] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:31,920] INFO: Processing task `misfit`
[2024-11-15 13:43:31,984] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,018] INFO: Processing task `misfit`
[2024-11-15 13:43:32,097] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,147] INFO: Processing task `misfit`
[2024-11-15 13:43:32,211] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,244] INFO: Processing task `misfit`
[2024-11-15 13:43:32,312] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,356] INFO: Processing task `misfit`
[2024-11-15 13:43:32,430] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,486] INFO: Processing task `misfit`
[2024-11-15 13:43:32,554] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,581] INFO: Processing task `misfit`
[2024-11-15 13:43:32,642] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,669] INFO: Processing task `misfit`
[2024-11-15 13:43:32,722] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,748] INFO: Processing task `misfit`
[2024-11-15 13:43:32,812] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,838] INFO: Processing task `misfit`
[2024-11-15 13:43:32,895] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:32,921] INFO: Processing task `misfit`
[2024-11-15 13:43:32,976] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,003] INFO: Processing task `misfit`
[2024-11-15 13:43:33,066] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,099] INFO: Processing task `misfit`
[2024-11-15 13:43:33,152] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,194] INFO: Processing task `misfit`
[2024-11-15 13:43:33,449] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,472] INFO: Processing task `misfit`
[2024-11-15 13:43:33,530] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,554] INFO: Processing task `misfit`
[2024-11-15 13:43:33,624] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,649] INFO: Processing task `misfit`
[2024-11-15 13:43:33,712] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,748] INFO: Processing task `misfit`
[2024-11-15 13:43:33,824] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,859] INFO: Processing task `misfit`
[2024-11-15 13:43:33,931] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:33,966] INFO: Processing task `misfit`
[2024-11-15 13:43:34,037] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,071] INFO: Processing task `misfit`
[2024-11-15 13:43:34,138] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,168] INFO: Processing task `misfit`
[2024-11-15 13:43:34,239] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,271] INFO: Processing task `misfit`
[2024-11-15 13:43:34,343] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,376] INFO: Processing task `misfit`
[2024-11-15 13:43:34,446] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,478] INFO: Processing task `misfit`
[2024-11-15 13:43:34,548] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,581] INFO: Processing task `misfit`
[2024-11-15 13:43:34,653] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,686] INFO: Processing task `misfit`
[2024-11-15 13:43:34,754] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:34,787] INFO: Processing task `misfit`
[2024-11-15 13:43:35,106] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,139] INFO: Processing task `misfit`
[2024-11-15 13:43:35,210] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,244] INFO: Processing task `misfit`
[2024-11-15 13:43:35,315] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,350] INFO: Processing task `misfit`
[2024-11-15 13:43:35,419] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,453] INFO: Processing task `misfit`
[2024-11-15 13:43:35,521] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,553] INFO: Processing task `misfit`
[2024-11-15 13:43:35,620] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,648] INFO: Processing task `misfit`
[2024-11-15 13:43:35,717] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,747] INFO: Processing task `misfit`
[2024-11-15 13:43:35,814] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,844] INFO: Processing task `misfit`
[2024-11-15 13:43:35,915] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:35,945] INFO: Processing task `misfit`
[2024-11-15 13:43:36,013] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,043] INFO: Processing task `misfit`
[2024-11-15 13:43:36,112] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,142] INFO: Processing task `misfit`
[2024-11-15 13:43:36,210] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,243] INFO: Processing task `misfit`
[2024-11-15 13:43:36,307] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,340] INFO: Processing task `misfit`
[2024-11-15 13:43:36,406] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,439] INFO: Processing task `misfit`
[2024-11-15 13:43:36,739] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,772] INFO: Processing task `misfit`
[2024-11-15 13:43:36,838] INFO: Some tasks of iteration #0 are still running. Please check again later.
[2024-11-15 13:43:36,869] INFO: Processing task `misfit`
[2024-11-15 13:43:38,489] INFO: 
old misfit control group: 0.018681064754203797
new misfit control group: 0.007324120186341101
predicted reduction control group: -0.009520467601654339
actual reduction control group: -0.011356944567862695
5 out of 5 event(s) improved the misfit.
[2024-11-15 13:43:38,489] INFO: 
Model update accepted.
[2024-11-15 13:43:38,489] INFO: 1 new tasks have been issued.
[2024-11-15 13:43:38,490] INFO: Processing task `finalize_iteration`
[2024-11-15 13:43:38,536] INFO: ... searching for obsolete files in project/INVERSIONS/my_fourth_inversion/00000
[2024-11-15 13:43:38,548] INFO: Freed up 1.1 MB of space.
[2024-11-15 13:43:38,551] INFO: Succesfully completed iteration #0.
[2024-11-15 13:43:38,553] INFO: Adding new iteration #1.
Remember that we only invert for VP, so the gradients with respect to RHO don't enter the optimization. Nevertheless, we can see the updated density values when inspecting the absolute parameters in the mesh.
p.simulations.get_mesh(
    p.inversions.get_simulation_name(
        inverse_problem_configuration="my_fourth_inversion", iteration_id=1
    )
)
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x7b0c69396890>
PAGE CONTENTS