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=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,
)
[2024-03-15 09:27:14,976] INFO: Adding new iteration #0. [2024-03-15 09:27:14,985] INFO: Resuming iteration #0. [2024-03-15 09:27:14,985] INFO: 1 new tasks have been issued. [2024-03-15 09:27:14,986] INFO: Processing task `misfit_and_gradient` [2024-03-15 09:27:15,487] INFO: Iteration 0: Number of events: 5 chi = 0.017690077140191465 ||g|| = 0.016261600061325036 pred = --- ared = --- norm_update = --- tr_radius = --- [2024-03-15 09:27:15,488] INFO: 1 new tasks have been issued. [2024-03-15 09:27:15,488] INFO: Processing task `preconditioner` [2024-03-15 09:27:15,658] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:27:25,667] INFO: Processing task `preconditioner` [2024-03-15 09:27:25,800] INFO: 1 new tasks have been issued. [2024-03-15 09:27:25,800] INFO: Processing task `misfit` [2024-03-15 09:27:25,862] INFO: Submitting job array with 5 jobs ... [2024-03-15 09:27:25,976] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2024-03-15 09:27:25,976] INFO: Some tasks of iteration #0 are still running. Please check again later. [2024-03-15 09:27:35,994] INFO: Processing task `misfit` [2024-03-15 09:27:36,705] INFO: old misfit control group: 0.01769007714019146 new misfit control group: 0.006645707015224614 predicted reduction control group: -0.005735067527115341 actual reduction control group: -0.011044370124966847 5 out of 5 event(s) improved the misfit. [2024-03-15 09:27:36,706] INFO: Model update accepted. [2024-03-15 09:27:36,706] INFO: 1 new tasks have been issued. [2024-03-15 09:27:36,707] INFO: Processing task `finalize_iteration` [2024-03-15 09:27:36,739] INFO: Succesfully completed iteration #0. [2024-03-15 09:27:36,741] 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")
[2024-03-15 09:27:38,058] INFO: Resuming iteration #1. [2024-03-15 09:27:38,058] INFO: 1 new tasks have been issued. [2024-03-15 09:27:38,058] INFO: Processing task `gradient` [2024-03-15 09:27:38,391] INFO: Submitting job array with 5 jobs ...
Uploading 1 files... Uploading 1 files... Uploading 1 files... Uploading 1 files... Uploading 1 files... [2024-03-15 09:27:38,442] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished. [2024-03-15 09:27:38,443] INFO: Some tasks of iteration #1 are still running. Please check again later. [2024-03-15 09:27:48,445] INFO: Processing task `gradient` [2024-03-15 09:27:48,655] INFO: 5 events have already been submitted. They will not be submitted again. [2024-03-15 09:27:49,154] INFO: Iteration 1: Number of events: 5 chi = 0.006645707015224614 ||g|| = 0.00812201838987874 pred = -0.005735067527115341 ared = -0.011044370124966847 norm_update = 0.7265222129292461 tr_radius = 0.7265223043807953 [2024-03-15 09:27:49,163] INFO: 1 new tasks have been issued. [2024-03-15 09:27:49,164] INFO: Processing task `preconditioner` [2024-03-15 09:27:49,246] INFO: Some tasks of iteration #1 are still running. Please check again later. [2024-03-15 09:27:59,265] INFO: Processing task `preconditioner` [2024-03-15 09:27:59,384] INFO: 1 new tasks have been issued. [2024-03-15 09:27:59,384] INFO: Processing task `misfit` [2024-03-15 09:27:59,458] INFO: Submitting job array with 5 jobs ... [2024-03-15 09:27:59,568] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2024-03-15 09:27:59,569] INFO: Some tasks of iteration #1 are still running. Please check again later. [2024-03-15 09:28:09,598] INFO: Processing task `misfit` [2024-03-15 09:28:10,406] INFO: old misfit control group: 0.006645707015224614 new misfit control group: 0.0028967887381038215 predicted reduction control group: -0.002794686584493957 actual reduction control group: -0.0037489182771207924 5 out of 5 event(s) improved the misfit. [2024-03-15 09:28:10,406] INFO: Model update accepted. [2024-03-15 09:28:10,407] INFO: 1 new tasks have been issued. [2024-03-15 09:28:10,407] INFO: Processing task `finalize_iteration` [2024-03-15 09:28:10,462] INFO: Succesfully completed iteration #1. [2024-03-15 09:28:10,464] INFO: Adding new iteration #2. [2024-03-15 09:28:10,470] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00000 [2024-03-15 09:28:10,472] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00001 [2024-03-15 09:28:10,615] INFO: Freed up 6.0 MB of space. [2024-03-15 09:28:10,618] INFO: Resuming iteration #2. [2024-03-15 09:28:10,619] INFO: 1 new tasks have been issued. [2024-03-15 09:28:10,619] INFO: Processing task `gradient` [2024-03-15 09:28:10,943] INFO: Submitting job array with 5 jobs ...
Uploading 1 files... Uploading 1 files... Uploading 1 files... Uploading 1 files... Uploading 1 files... [2024-03-15 09:28:10,999] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished. [2024-03-15 09:28:11,001] INFO: Some tasks of iteration #2 are still running. Please check again later. [2024-03-15 09:28:21,003] INFO: Processing task `gradient` [2024-03-15 09:28:21,217] INFO: 5 events have already been submitted. They will not be submitted again. [2024-03-15 09:28:21,712] INFO: Iteration 2: Number of events: 5 chi = 0.002896788738103822 ||g|| = 0.003362099830398031 pred = -0.002794686584493957 ared = -0.0037489182771207924 norm_update = 0.7176518757295359 tr_radius = 1.4530446087615907 [2024-03-15 09:28:21,728] INFO: 1 new tasks have been issued. [2024-03-15 09:28:21,728] INFO: Processing task `preconditioner` [2024-03-15 09:28:21,823] INFO: Some tasks of iteration #2 are still running. Please check again later. [2024-03-15 09:28:31,852] INFO: Processing task `preconditioner` [2024-03-15 09:28:31,985] INFO: 1 new tasks have been issued. [2024-03-15 09:28:31,986] INFO: Processing task `misfit` [2024-03-15 09:28:32,047] INFO: Submitting job array with 5 jobs ... [2024-03-15 09:28:32,156] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2024-03-15 09:28:32,157] INFO: Some tasks of iteration #2 are still running. Please check again later. [2024-03-15 09:28:42,197] INFO: Processing task `misfit` [2024-03-15 09:28:42,848] INFO: old misfit control group: 0.0028967887381038215 new misfit control group: 0.0024078610288392685 predicted reduction control group: -0.00022036795434662477 actual reduction control group: -0.000488927709264553 5 out of 5 event(s) improved the misfit. [2024-03-15 09:28:42,849] INFO: Model update accepted. [2024-03-15 09:28:42,849] INFO: 1 new tasks have been issued. [2024-03-15 09:28:42,849] INFO: Processing task `finalize_iteration` [2024-03-15 09:28:42,930] INFO: Succesfully completed iteration #2. [2024-03-15 09:28:42,932] INFO: Adding new iteration #3. [2024-03-15 09:28:42,939] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00000 [2024-03-15 09:28:42,941] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00001 [2024-03-15 09:28:43,028] INFO: ... searching for obsolete files in project/INVERSIONS/my_second_inversion/00002 [2024-03-15 09:28:43,164] INFO: Freed up 6.0 MB of space.