%matplotlib inline
# This notebook will use this variable to determine which
# remote site to run on.
import os
import time
import salvus.namespace as sn
SALVUS_FLOW_SITE_NAME = os.environ.get("SITE_NAME", "local")
p = sn.Project(path="project")
p += sn.MisfitConfiguration(
name="L2",
observed_data="true_model_100kHz",
misfit_function="L2",
receiver_field="phi",
)
print(
p.actions.inversion.compute_misfits(
simulation_configuration="initial_model",
misfit_configuration="L2",
events=p.events.list(),
store_checkpoints=False,
site_name=SALVUS_FLOW_SITE_NAME,
ranks_per_job=4,
)
)
{'event_0000': 0.024592185172671033, 'event_0001': 0.020252733072806305, 'event_0002': 0.017606771469430887, 'event_0003': 0.013230878222458041, 'event_0004': 0.01772275583365272}
while not p.actions.inversion.compute_gradients(
simulation_configuration="initial_model",
misfit_configuration="L2",
wavefield_compression=sn.WavefieldCompression(
forward_wavefield_sampling_interval=10
),
events=p.events.list(),
site_name=SALVUS_FLOW_SITE_NAME,
ranks_per_job=4,
):
time.sleep(10.0)
[2024-11-15 13:39:03,960] INFO: The following events have been simulated before, but checkpoints are not available for this combination of `site_name` and `ranks_per_job` and wavefield compression settings. They will be run again: ['event_0000', 'event_0001', 'event_0002', 'event_0003', 'event_0004'] [2024-11-15 13:39:04,015] INFO: Submitting job array with 5 jobs ... [2024-11-15 13:39:04,407] INFO: Launched simulations for 5 events. Please check again to see if they are finished. [2024-11-15 13:39:15,228] 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:39:15,314] INFO: Launched adjoint simulations for 5 events. Please check again to see if they are finished. [2024-11-15 13:39:25,475] INFO: 5 events have already been submitted. They will not be submitted again.
p.viz.nb.gradients(
simulation_configuration="initial_model",
misfit_configuration="L2",
wavefield_compression=sn.WavefieldCompression(
forward_wavefield_sampling_interval=10
),
events=p.events.list(),
)
gradient = p.actions.inversion.sum_gradients(
simulation_configuration="initial_model",
misfit_configuration="L2",
wavefield_compression=sn.WavefieldCompression(
forward_wavefield_sampling_interval=10
),
events=p.events.list(),
)
gradient
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x7b281f462650>
p.actions.inversion.smooth_model(
model=gradient,
smoothing_configuration=sn.ConstantSmoothing(
smoothing_lengths_in_meters={
"VP": 0.01,
"RHO": 0.01,
},
),
ranks_per_job=4,
site_name=SALVUS_FLOW_SITE_NAME,
)
<salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh object at 0x7b281f6667d0>