salvus.project.components.action.inversion.inversion_action_component
Classes
InversionActionComponent
InversionActionComponentclass InversionActionComponent(builtins.object):
def __init__(self, project: salvus.project.project.Project):
...Inversion specific actions, mainly to process tasks that require simulations
Parameters
projectsalvus.project.project.Project — The project for the component.
Methods
compute_gradients()
compute_gradients()def compute_gradients(
self,
simulation_configuration: str,
misfit_configuration: str,
events: Union[
str,
Sequence[str],
salvus.flow.collections.event.Event,
Sequence[salvus.flow.collections.event.Event],
salvus.flow.collections.event_collection.EventCollection,
],
site_name: str,
ranks_per_job: int,
wall_time_in_seconds_per_job: Optional[int] = None,
memory_per_rank_in_MB: Optional[float] = None,
max_events_per_job_submission: int = 0,
wavefield_compression: Optional[
salvus.flow.collections.wavefield_compression.WavefieldCompression
] = None,
delete_dependent_jobs: bool = True,
verbosity: int = 0,
) -> Optional[Dict[str, pathlib.Path]]:
...Compute event gradients for a given simulation configuration, misfit configuration.
Parameters
simulation_configurationstr — Name of the simulation configuration for the forward run.misfit_configurationstr — Name of the misfit configuration.eventsUnion[str, Sequence[str], salvus.flow.collections.event.Event, Sequence[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — One or more events.site_namestr — Site to use.ranks_per_jobint — Ranks per job.wall_time_in_seconds_per_jobOptional[int] — Wall time per job.memory_per_rank_in_MBOptional[float] — Optional memory settings for the site.max_events_per_job_submissionint — Optional chunkwise job submission. If set to a positive number, simulations will be launched in chunks.wavefield_compressionOptional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — Wavefield compression settings.delete_dependent_jobsbool — Delete job and all its dependencies at remote site after the outputs have been downloaded.verbosityint — Verbosity.
Returns Optional[Dict[str, pathlib.Path]] — A dictionary with the path to the gradient file for each event.
compute_misfits()
compute_misfits()def compute_misfits(
self,
simulation_configuration: str,
misfit_configuration: str,
events: Union[
str,
Sequence[str],
salvus.flow.collections.event.Event,
Sequence[salvus.flow.collections.event.Event],
salvus.flow.collections.event_collection.EventCollection,
],
site_name: str,
ranks_per_job: int,
wall_time_in_seconds_per_job: Optional[int] = None,
memory_per_rank_in_MB: Optional[float] = None,
max_events_per_job_submission: int = 0,
derived_job_config: Optional[
salvus.flow.collections.wavefield_compression.WavefieldCompression
] = None,
delete_dependent_jobs: bool = True,
verbosity: int = 0,
store_checkpoints: Optional[bool] = None,
) -> Optional[Dict[str, float]]:
...Compute event misfits for a given simulation configuration, misfit configuration.
Parameters
simulation_configurationstr — Name of the simulation configuration for the forward run.misfit_configurationstr — Name of the misfit configuration.eventsUnion[str, Sequence[str], salvus.flow.collections.event.Event, Sequence[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — One or more events.site_namestr — Site to use.ranks_per_jobint — Ranks per job.wall_time_in_seconds_per_jobOptional[int] — Wall time per job.memory_per_rank_in_MBOptional[float] — Optional memory settings for the site.max_events_per_job_submissionint — Optional chunkwise job submission. If set to a positive number, simulations will be launched in chunks.derived_job_configOptional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — Options that have an effect on the output of subsequent simulations but must already be known now. Currently allows the specification of some techniques to compress wavefields for the purpose of gradient computations.delete_dependent_jobsbool — Delete job and all its dependencies at remote site after the outputs have been downloaded.verbosityint — Verbosity.store_checkpointsOptional[bool] — Deprecated. Please use thederived_job_configparameter.
Returns Optional[Dict[str, float]] — A dictionary with the aggregated misfit from all receivers for each event.
smooth_model()
smooth_model()def smooth_model(
self,
model: Union[
salvus.mesh.unstructured_mesh.UnstructuredMesh,
salvus.opt.models.unstructured_model.UnstructuredModel,
],
smoothing_configuration: Union[
salvus.opt.preconditioner.ConstantSmoothing,
salvus.opt.preconditioner.ModelDependentSmoothing,
salvus.opt.preconditioner.SpaceDependentSmoothing,
],
site_name: str,
ranks_per_job: int,
wall_time_in_seconds_per_job: Optional[int] = None,
verbosity: int = 0,
run_async: bool = False,
) -> Union[
salvus.mesh.unstructured_mesh.UnstructuredMesh,
salvus.flow.sites.salvus_job_array.SalvusJobArray,
]:
...Smooth a model or gradient.
Parameters
modelUnion[salvus.mesh.unstructured_mesh.UnstructuredMesh, salvus.opt.models.unstructured_model.UnstructuredModel] — Input model (gradient) that should be smoothed.smoothing_configurationUnion[salvus.opt.preconditioner.ConstantSmoothing, salvus.opt.preconditioner.ModelDependentSmoothing, salvus.opt.preconditioner.SpaceDependentSmoothing] — Smoothing configuration.site_namestr — Site to use.ranks_per_jobint — Ranks per job.wall_time_in_seconds_per_jobOptional[int] — Wall time per job.verbosityint — Verbosity.run_asyncbool — Optional switch to run smoothing asynchronously. This is mainly for internal use.
Returns Union[salvus.mesh.unstructured_mesh.UnstructuredMesh, salvus.flow.sites.salvus_job_array.SalvusJobArray] — The smoothed model (gradient) as UnstructuredMesh object or - in case of running asynchronously - a SalvusJobarray of the smoothing job.
sum_gradients()
sum_gradients()def sum_gradients(
self,
simulation_configuration: str,
misfit_configuration: str,
events: Union[
str,
Sequence[str],
salvus.flow.collections.event.Event,
Sequence[salvus.flow.collections.event.Event],
salvus.flow.collections.event_collection.EventCollection,
],
wavefield_compression: Optional[
salvus.flow.collections.wavefield_compression.WavefieldCompression
] = None,
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Compute the sum of all gradients for a list of events.
The function will raise if the gradients have not been computed yet for
the given combination of simulation_configuration,
misfit_configuration and events.
Parameters
simulation_configurationstr — Name of the simulation configuration for the forward run.misfit_configurationstr — Name of the misfit configuration.eventsUnion[str, Sequence[str], salvus.flow.collections.event.Event, Sequence[salvus.flow.collections.event.Event], salvus.flow.collections.event_collection.EventCollection] — One or more events.wavefield_compressionOptional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — Wavefield compression for the gradients to choose.
Returns salvus.mesh.unstructured_mesh.UnstructuredMesh — An unstructured mesh object with the summed gradient.