This documentation is not for the latest stable Salvus version.
%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")
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)
p += sn.InverseProblemConfiguration(
name="my_second_inversion",
prior_model="initial_model",
events=[e.event_name for e in p.events.get_all()],
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,
)
[2023-09-10 15:53:52,748] INFO: Adding new iteration #0. [2023-09-10 15:53:52,758] INFO: Resuming iteration #0. [2023-09-10 15:53:52,759] INFO: 1 new tasks have been issued. [2023-09-10 15:53:52,759] INFO: Processing task `misfit_and_gradient` [2023-09-10 15:53:53,247] INFO: Iteration 0: Number of events: 5 chi = 0.017689825271254428 ||g|| = 0.01626147391909629 pred = --- ared = --- norm_update = --- tr_radius = --- [2023-09-10 15:53:53,248] INFO: 1 new tasks have been issued. [2023-09-10 15:53:53,248] INFO: Processing task `preconditioner` [2023-09-10 15:53:53,438] INFO: Some tasks of iteration #0 are still running. Please check again later. [2023-09-10 15:54:03,459] INFO: Processing task `preconditioner` [2023-09-10 15:54:03,671] INFO: 1 new tasks have been issued. [2023-09-10 15:54:03,672] INFO: Processing task `misfit` [2023-09-10 15:54:03,754] INFO: Submitting job array with 5 jobs ... [2023-09-10 15:54:03,908] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2023-09-10 15:54:03,909] INFO: Some tasks of iteration #0 are still running. Please check again later. [2023-09-10 15:54:13,946] INFO: Processing task `misfit` [2023-09-10 15:54:15,022] INFO: old misfit control group: 0.017689825271254428 new misfit control group: 0.006645707057577022 predicted reduction control group: -0.005735007567861612 actual reduction control group: -0.011044118213677406 5 out of 5 event(s) improved the misfit. [2023-09-10 15:54:15,022] INFO: Model update accepted. [2023-09-10 15:54:15,023] INFO: 1 new tasks have been issued. [2023-09-10 15:54:15,023] INFO: Processing task `finalize_iteration` [2023-09-10 15:54:15,068] INFO: Succesfully completed iteration #0. [2023-09-10 15:54:15,071] INFO: Adding new iteration #1.
p.viz.nb.inversion(inverse_problem_configuration="my_second_inversion")
for i in range(2):
p.inversions.iterate(
inverse_problem_configuration="my_second_inversion",
timeout_in_seconds=360,
ping_interval_in_seconds=10,
)
p.inversions.delete_disposable_files(
inverse_problem_configuration="my_second_inversion",
data_to_remove=["auxiliary", "gradients", "waveforms"],
)
p.viz.nb.inversion(inverse_problem_configuration="my_second_inversion")
[2023-09-10 15:54:16,694] INFO: Resuming iteration #1. [2023-09-10 15:54:16,701] INFO: 1 new tasks have been issued. [2023-09-10 15:54:16,702] INFO: Processing task `gradient` [2023-09-10 15:54:17,120] INFO: Submitting job array with 5 jobs ...
[2023-09-10 15:54:17,208] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished. [2023-09-10 15:54:17,210] INFO: Some tasks of iteration #1 are still running. Please check again later. [2023-09-10 15:54:27,223] INFO: Processing task `gradient` [2023-09-10 15:54:27,485] INFO: 5 events have already been submitted. They will not be submitted again. [2023-09-10 15:54:28,137] INFO: Iteration 1: Number of events: 5 chi = 0.006645707057577022 ||g|| = 0.008122034993532758 pred = -0.005735007567861612 ared = -0.011044118213677406 norm_update = 0.7265202727548425 tr_radius = 0.7265203173393829 [2023-09-10 15:54:28,149] INFO: 1 new tasks have been issued. [2023-09-10 15:54:28,150] INFO: Processing task `preconditioner` [2023-09-10 15:54:28,276] INFO: Some tasks of iteration #1 are still running. Please check again later. [2023-09-10 15:54:38,308] INFO: Processing task `preconditioner` [2023-09-10 15:54:38,485] INFO: 1 new tasks have been issued. [2023-09-10 15:54:38,485] INFO: Processing task `misfit` [2023-09-10 15:54:38,568] INFO: Submitting job array with 5 jobs ... [2023-09-10 15:54:38,723] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2023-09-10 15:54:38,724] INFO: Some tasks of iteration #1 are still running. Please check again later. [2023-09-10 15:54:48,773] INFO: Processing task `misfit` [2023-09-10 15:54:49,565] INFO: old misfit control group: 0.006645707057577022 new misfit control group: 0.002896766734466043 predicted reduction control group: -0.0027947391349793975 actual reduction control group: -0.003748940323110979 5 out of 5 event(s) improved the misfit. [2023-09-10 15:54:49,566] INFO: Model update accepted. [2023-09-10 15:54:49,566] INFO: 1 new tasks have been issued. [2023-09-10 15:54:49,567] INFO: Processing task `finalize_iteration` [2023-09-10 15:54:49,640] INFO: Succesfully completed iteration #1. [2023-09-10 15:54:49,644] INFO: Adding new iteration #2. [2023-09-10 15:54:49,652] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00000 [2023-09-10 15:54:49,656] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00001 [2023-09-10 15:54:49,760] INFO: Freed up 4.4 MB of space. [2023-09-10 15:54:49,765] INFO: Resuming iteration #2. [2023-09-10 15:54:49,765] INFO: 1 new tasks have been issued. [2023-09-10 15:54:49,766] INFO: Processing task `gradient` [2023-09-10 15:54:50,167] INFO: Submitting job array with 5 jobs ...
[2023-09-10 15:54:50,268] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished. [2023-09-10 15:54:50,269] INFO: Some tasks of iteration #2 are still running. Please check again later. [2023-09-10 15:55:00,282] INFO: Processing task `gradient` [2023-09-10 15:55:00,652] INFO: 5 events have already been submitted. They will not be submitted again. [2023-09-10 15:55:01,476] INFO: Iteration 2: Number of events: 5 chi = 0.0028967667344660434 ||g|| = 0.003362121843820212 pred = -0.0027947391349793975 ared = -0.003748940323110979 norm_update = 0.7176639107602372 tr_radius = 1.4530406346787659 [2023-09-10 15:55:01,507] INFO: 1 new tasks have been issued. [2023-09-10 15:55:01,508] INFO: Processing task `preconditioner` [2023-09-10 15:55:01,728] INFO: Some tasks of iteration #2 are still running. Please check again later. [2023-09-10 15:55:11,834] INFO: Processing task `preconditioner` [2023-09-10 15:55:12,099] INFO: 1 new tasks have been issued. [2023-09-10 15:55:12,100] INFO: Processing task `misfit` [2023-09-10 15:55:12,419] INFO: Submitting job array with 5 jobs ... [2023-09-10 15:55:12,649] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2023-09-10 15:55:12,651] INFO: Some tasks of iteration #2 are still running. Please check again later. [2023-09-10 15:55:22,726] INFO: Processing task `misfit` [2023-09-10 15:55:23,931] INFO: old misfit control group: 0.002896766734466043 new misfit control group: 0.002407847089641693 predicted reduction control group: -0.00022036388532600842 actual reduction control group: -0.0004889196448243502 5 out of 5 event(s) improved the misfit. [2023-09-10 15:55:23,934] INFO: Model update accepted. [2023-09-10 15:55:23,935] INFO: 1 new tasks have been issued. [2023-09-10 15:55:23,942] INFO: Processing task `finalize_iteration` [2023-09-10 15:55:24,124] INFO: Succesfully completed iteration #2. [2023-09-10 15:55:24,133] INFO: Adding new iteration #3. [2023-09-10 15:55:24,168] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00000 [2023-09-10 15:55:24,182] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00001 [2023-09-10 15:55:24,365] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00002 [2023-09-10 15:55:24,527] INFO: Freed up 4.4 MB of space.