Mondaic

salvus.project.configuration.inverse_problem_configuration

salvus.project.configuration.inverse_problem_configuration salvus project configuration inverse_problem_configuration

The inverse problem configuration.

Classes

InverseProblemConfiguration

class InverseProblemConfiguration(
    salvus.flow.utils.serialization_helpers.SerializationMixin
):
    def __init__(
        self,
        name: str,
        prior_model: str,
        events: str | typing.Sequence[str],
        method: TrustRegion,
        mapping: Mapping,
        preconditioner: (
            ConstantSmoothing
            | ModelDependentSmoothing
            | SpaceDependentSmoothing
            | typing.Callable
            | str
            | None
        ) = None,
        extra_kwargs_preconditioner: dict | None = None,
        misfit_configuration: MisfitConfiguration | str | None = None,
        wavefield_compression: WavefieldCompression | None = None,
        event_batch_selection: str | typing.Callable | None = None,
        job_submission: (
            SiteConfig
            | TaskChainSiteConfig
            | dict[str, SiteConfig | bool | dict[str, TaskChainSiteConfig]]
            | MPIExecutionConfiguration
            | None
        ) = None,
    ): ...

Configuration for an inverse problem.

Parameters
  • name str — Name of the inverse problem.
  • prior_model str — Prior model.
  • events str | typing.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 ConstantSmoothing | ModelDependentSmoothing | SpaceDependentSmoothing | typing.Callable | str | None — Preconditioner used by the descent method.
  • extra_kwargs_preconditioner dict | None — Additional keyword arguments for custom preconditioners.
  • misfit_configuration MisfitConfiguration | str | None — The misfit configuration.
  • wavefield_compression WavefieldCompression | None — The compression settings for checkpoints and recomputing the forward wavefield during the adjoint run.
  • event_batch_selection str | typing.Callable | None — Optional callback function for selecting a new subset of events in every new iteration.
  • job_submission SiteConfig | TaskChainSiteConfig | dict[str, SiteConfig | bool | dict[str, TaskChainSiteConfig]] | MPIExecutionConfiguration | None — Submission settings for asynchronous jobs.
Attributes
event_batch_selection typing.Callable | None

Get the event batch selection callback if available.

event_batch_selection_str str | None

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: typing.Sequence[str]) -> None: ...

Add events to the inverse problem.

Parameters
  • events typing.Sequence[str] — List of event names.
Returns None
add_iteration()
def add_iteration(
    self, iteration: Iteration[UnstructuredModel], comm: int | None = None
) -> None: ...

Add an interation to the inverse problem.

Parameters
  • iteration Iteration[UnstructuredModel] — Iteration.
  • comm int | None — MPI communicator, if any.
Returns None
check_stopping_criteria()
def check_stopping_criteria(
    self, iteration_id: salvus._core.types.int_ | None = None
) -> bool: ...

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

Parameters
  • iteration_id salvus._core.types.int_ | None — 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) -> Iteration: ...

Obtain an iteration object from the inverse problem.

Parameters
  • id int — ID of the iteration.
Returns 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") -> typing.Sequence[int]: ...

Get the IDs of all iterations with a certain status.

Parameters
  • status str — Status of the iteration.
Returns typing.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, UnstructuredModel]
) -> None: ...

Define box constraints on the inversion parameters.

Parameters
  • constraints dict[str, UnstructuredModel] — Optional lower and upper bounds on the model parameters.
Returns None
set_job_submission()
def set_job_submission(
    self,
    job_submission: (
        SiteConfig
        | TaskChainSiteConfig
        | dict[str, SiteConfig | bool | dict[str, TaskChainSiteConfig]]
    ),
    comm: int | None = None,
) -> None: ...

Set job submission configuration for asynchronous tasks.

Parameters
  • job_submission SiteConfig | TaskChainSiteConfig | dict[str, SiteConfig | bool | dict[str, 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.
  • comm int | None — MPI communicator, if any.
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: WavefieldCompression, comm: int | None = None
) -> None: ...

Set wavefield compression settings for gradient computations.

Parameters
  • wavefield_compression WavefieldCompression — Wavefield compression settings.
  • comm int | None — MPI communicator, if any.
Returns None
to_json()
def to_json(
    self,
    external_file_hash: str | None = None,
    timer: Timer | None = None,
    log_to_logger: bool = False,
    comm: int | None = None,
) -> dict: ...

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

Parameters
  • external_file_hash str | None — Hash of any external files associated with this object. Can be passed here in which case it will be stored in a centralized location in the JSON file.
  • timer Timer | None — Execution timer.
  • log_to_logger bool — Log timings to the logger.
  • comm int | None — MPI communicator, if any.
Returns dict
update_iteration()
def update_iteration(
    self, iteration: Iteration[UnstructuredModel], comm: int | None = None
) -> None: ...

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

Parameters
  • iteration Iteration[UnstructuredModel] — Iteration to update.
  • comm int | None — MPI communicator, if any.
Returns None

Used in tutorials