Mondaic
This API reference is not for the latest stable Salvus version.

salvus.project.configuration.inverse_problem_configuration

Classes

InverseProblemConfiguration

class InverseProblemConfiguration(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        name: str,
        prior_model: str,
        events: Union[str, Sequence[str]],
        method: TrustRegion,
        mapping: Mapping,
        preconditioner: Optional[
            salvus.opt.preconditioner.ConstantSmoothing,
            salvus.opt.preconditioner.ModelDependentSmoothing,
            salvus.opt.preconditioner.SpaceDependentSmoothing,
        ] = None,
        misfit_configuration: Optional[
            salvus.project.configuration.misfit_configuration.MisfitConfiguration
        ] = None,
        wavefield_compression: Optional[
            salvus.flow.collections.wavefield_compression.WavefieldCompression
        ] = None,
        event_batch_selection: Optional[str, Callable] = None,
        job_submission: Optional[
            salvus.flow.sites.site_utils.SiteConfig,
            Dict[
                str,
                Union[
                    salvus.flow.sites.site_utils.SiteConfig,
                    bool,
                    Dict[
                        str,
                        salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
                    ],
                ],
            ],
        ] = None,
    ):
        ...

Configuration for an inverse problem.

Parameters
  • name str — Name of the inverse problem.
  • prior_model str — Prior model.
  • events Union[str, Sequence[str]] — List of events to consider.
  • method TrustRegion — Descent method to solve the inverse problem.
  • mapping Mapping — Mapping between inversion and simulation domain.
  • preconditioner Optional[salvus.opt.preconditioner.ConstantSmoothing, salvus.opt.preconditioner.ModelDependentSmoothing, salvus.opt.preconditioner.SpaceDependentSmoothing] — Preconditioner used by the descent method.
  • misfit_configuration Optional[salvus.project.configuration.misfit_configuration.MisfitConfiguration] — The misfit configuration.
  • wavefield_compression Optional[salvus.flow.collections.wavefield_compression.WavefieldCompression] — The compression settings for checkpoints and recomputing the forward wavefield during the adjoint run.
  • event_batch_selection Optional[str, Callable] — Optional callback function for selecting a new subset of events in every new iteration.
  • job_submission Optional[salvus.flow.sites.site_utils.SiteConfig, Dict[str, Union[salvus.flow.sites.site_utils.SiteConfig, bool, Dict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig]]]] — Submission settings for asynchronous jobs.
Attributes
event_batch_selection Optional[Callable]

Get the event batch selection callback if available.

event_batch_selection_str Optional[str]

Get the event batch selection callback as string if available.

Methods
from_json()
def from_json(
    d: Dict, json_path: pathlib.Path, model_inventory_path: pathlib.Path
) -> InverseProblemConfiguration:
    ...

Construct object from a JSON-serializable dictionary.

Parameters
  • d Dict — JSON dictionary of the inverse problem.
  • json_path pathlib.Path — Path to serialized json file.
  • model_inventory_path pathlib.Path — Path to the model inventory at the project level.
Returns InverseProblemConfiguration
add_events()
def add_events(self, events: Sequence[str]) -> None:
    ...

Add events to the inverse problem

Parameters
  • events Sequence[str] — List of event names.
Returns None
add_iteration()
def add_iteration(self, iteration: salvus.opt.iteration.Iteration) -> None:
    ...

Add an interation to the inverse problem

Parameters
  • iteration salvus.opt.iteration.Iteration — Iteration.
Returns None
check_stopping_criteria()
def check_stopping_criteria(
    self, iteration_id: Optional[int, numpy.int32, numpy.int64] = None
) -> bool:
    ...

Check if the iteration satisfies at least one of the stopping criteria are satisfied.

Parameters
  • iteration_id Optional[int, numpy.int32, numpy.int64] — Iteration id.
Returns bool
delete_iteration()
def delete_iteration(self, id: int) -> None:
    ...

Delete an iteration from the inverse problem.

Parameters
  • id int — ID of the iteration to delete.
Returns None
get_all_branches()
def get_all_branches(self) -> Dict[str, List[int]]:
    ...

Return a dictionary of all branches in the inversion tree. The keys are set to the tips of the branches.

Returns Dict[str, List[int]]
get_branch_ids()
def get_branch_ids(self, latest: int) -> List[int]:
    ...

Obtain the ids of an inversion branch.

Parameters
  • latest int — Id of the latest iteration.
Returns List[int] — List of iteration ids from root to leaf.
get_iteration()
def get_iteration(self, id: int) -> salvus.opt.iteration.Iteration:
    ...

Obtain an iteration object from the inverse problem.

Parameters
  • id int — ID of the iteration.
Returns salvus.opt.iteration.Iteration — The queryied iteration.
get_iteration_directory()
def get_iteration_directory(self, iteration_id: int) -> pathlib.Path:
    ...

Obtain the path where all models and gradients of this iteration are stored.

Parameters
  • iteration_id int — ID of the iteration.
Returns pathlib.Path
get_iteration_ids()
def get_iteration_ids(self, status: str = "all") -> Sequence[int]:
    ...

Get the IDs of all iterations with a certain status

Parameters
  • status str — Status of the iteration.
Returns Sequence[int] — A list of IDs.
get_new_iteration_id()
def get_new_iteration_id(self) -> int:
    ...

Obtain the next available iteration ID.

Returns int — Possible ID for a new iteration.
set_constraints()
def set_constraints(
    self,
    constraints: Dict[
        str, salvus.opt.models.unstructured_model.UnstructuredModel
    ],
) -> None:
    ...

Define box constraints on the inversion parameters.

Parameters
  • constraints Dict[str, salvus.opt.models.unstructured_model.UnstructuredModel] — Optional lower and upper bounds on the model parameters.
Returns None
set_job_submission()
def set_job_submission(
    self,
    job_submission: Union[
        salvus.flow.sites.site_utils.SiteConfig,
        Dict[
            str,
            Union[
                salvus.flow.sites.site_utils.SiteConfig,
                bool,
                Dict[
                    str,
                    salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig,
                ],
            ],
        ],
    ],
) -> None:
    ...

Set job submission configuration for asynchronous tasks.

Parameters
  • job_submission Union[salvus.flow.sites.site_utils.SiteConfig, Dict[str, Union[salvus.flow.sites.site_utils.SiteConfig, bool, Dict[str, salvus.flow.sites.task_chain.task_chain_site_config.TaskChainSiteConfig]]]] — Either a SiteConfig or a dictionary of SiteConfigs or with keys forward, adjoint and preconditioner. Instead of a SiteConfig it is also possible to pass a dictionary of TaskChainSiteConfigs for forward and adjoint.
Returns None
set_stopping_criteria()
def set_stopping_criteria(self, criteria: Dict) -> None:
    ...

Set stopping criteria to limit the maximum cost of an inversion.

Parameters
  • criteria Dict — Dictionary of stopping criteria. If any of them is true, no further iterations will be added. Currently supported are max_iterations for the maximum number of iterations per branch and max_iterations_global for the maximum number of iterations in the entire inversion tree.
Returns None
set_wavefield_compression()
def set_wavefield_compression(
    self,
    wavefield_compression: salvus.flow.collections.wavefield_compression.WavefieldCompression,
) -> None:
    ...

Set wavefield compression settings for gradient computations.

Parameters
  • wavefield_compression salvus.flow.collections.wavefield_compression.WavefieldCompression — Wavefield compression settings.
Returns None
to_json()
def to_json(self) -> Dict:
    ...

Serialize the object to dictionary that can be written to JSON. Auxiliary files will be written to the specified path.

Returns Dict
update_iteration()
def update_iteration(self, iteration: salvus.opt.iteration.Iteration) -> None:
    ...

Update an iteration. The same iteration ID must already exist in the inverse problem.

Parameters
  • iteration salvus.opt.iteration.Iteration — Iteration to update.
Returns None