Mondaic

salvus.project.components.misfit_component

salvus.project.components.misfit_component salvus project components misfit_component

The misfit component.

Classes

MisfitComponent

class MisfitComponent(builtins.object):
    def __init__(self, project: salvus.project.project.Project): ...

Project subclass handling all things related to misfits and gradients.

Parameters
  • project salvus.project.project.Project — The project to attach the waveform component to.
Methods
compute_adjoint_source()
def compute_adjoint_source(
    self,
    simulation_configuration: str | _SimulationConfigurationBase,
    misfit_configuration: str | MisfitConfiguration,
    events: (
        str
        | typing.Sequence[str]
        | Event
        | typing.Sequence[Event]
        | EventCollection
    ),
) -> None: ...

Compute adjoint sources and store them in the project cache for a given simulation configuration, misfit configuration and a list of events.

As a by-product, the misfit value will be added to the internal MisfitStore.

Parameters
  • simulation_configuration str | _SimulationConfigurationBase — Name of the simulation configuration for the forward run.
  • misfit_configuration str | MisfitConfiguration — The name of the misfit configuration.
  • events str | typing.Sequence[str] | Event | typing.Sequence[Event] | EventCollection — One or more events.
Returns None
get()
def get(
    self,
    simulation_configuration: str | SimulationConfiguration,
    misfit_configuration: str | MisfitConfiguration,
    events: (
        str
        | typing.Sequence[str]
        | Event
        | typing.Sequence[Event]
        | EventCollection
    ),
    skip_writing_adjoint_source: bool | None = False,
) -> dict[str, float]: ...

Get a misfit dictionary for a given simulation configuration, misfit configuration and a list of events.

Parameters
  • simulation_configuration str | SimulationConfiguration — Name of the simulation configuration for the forward run.
  • misfit_configuration str | MisfitConfiguration — The name of the misfit configuration.
  • events str | typing.Sequence[str] | Event | typing.Sequence[Event] | EventCollection — One or more events.
  • skip_writing_adjoint_source bool | None — Optionally skip writing the adjoint source file.
Returns dict[str, float]
get_event_misfit_object()
def get_event_misfit_object(
    self,
    simulation_configuration: str,
    misfit_configuration: str | MisfitConfiguration,
    event: Event | str,
) -> EventMisfit: ...

Return the internally used EventMisfit object. Once you have this you are free to whatever you want but you are breaking out of the project and SalvusProject does no longer know what you are doing.

Parameters
  • simulation_configuration str — Name of the simulation configuration for the forward run.
  • misfit_configuration str | MisfitConfiguration — Name of the misfit configuration.
  • event Event | str — The event to use.
Returns EventMisfit
get_gradient_filenames()
def get_gradient_filenames(
    self,
    simulation_configuration: str | SimulationConfiguration,
    misfit_configuration: str | MisfitConfiguration,
    event: str | Event,
    wavefield_compression: WavefieldCompression,
    gradient_parameters: set[str] | None = None,
) -> dict[str, pathlib.Path]: ...

Get the paths to the gradient HDF5 and XDMF files.

Note that get_gradient_filenames_for_events() should be used when querying more than a single event.

Parameters
  • simulation_configuration str | SimulationConfiguration — Simulation configuration for the forward run.
  • misfit_configuration str | MisfitConfiguration — The name of the misfit configuration.
  • event str | Event — The event for which to get the gradient filenames.
  • wavefield_compression WavefieldCompression — Wavefield compression settings.
  • gradient_parameters set[str] | None — Model parameters to compute the gradients for. Must be a subset of the model parameters. If not given, gradients will be computed for all model fields.
Returns dict[str, pathlib.Path] — A dictionary with two keys: "xdmf_filename" and "hdf5_filename". The values are the respective file paths.
get_gradient_filenames_for_events()
def get_gradient_filenames_for_events(
    self,
    simulation_configuration: str | SimulationConfiguration,
    misfit_configuration: str | MisfitConfiguration,
    events: str | Event | typing.Sequence[str | Event] | EventCollection,
    wavefield_compression: WavefieldCompression,
    gradient_parameters: set[str] | None = None,
) -> dict[str, dict[str, pathlib.Path]]: ...

Get the paths to the gradient HDF5 and XDMF files for many events.

Prefer this over calling get_gradient_filenames() in a loop - the expensive hashing is performed once for the whole batch here.

Parameters
  • simulation_configuration str | SimulationConfiguration — Simulation configuration for the forward run.
  • misfit_configuration str | MisfitConfiguration — The name of the misfit configuration.
  • events str | Event | typing.Sequence[str | Event] | EventCollection — The events for which to get the gradient filenames.
  • wavefield_compression WavefieldCompression — Wavefield compression settings.
  • gradient_parameters set[str] | None — Model parameters to compute the gradients for. Must be a subset of the model parameters. If not given, gradients will be computed for all model fields.
Returns dict[str, dict[str, pathlib.Path]] — A dictionary mapping event name to a dictionary with two keys: "xdmf_filename" and "hdf5_filename".
get_misfit_comparison_table()
def get_misfit_comparison_table(
    self,
    reference_data: str,
    other_data: builtins.list[str] | None = None,
    misfit_configuration: str,
    event: str | Event,
    shorten_names: bool = False,
) -> pd.DataFrame: ...

Return a pandas DataFrame comparing the misfits for different simulation configurations per receiver. The final will contains the misfit values per receiver for each passed simulation configuration as well as the absolute reduction for each with respect to the reference.

Parameters
  • reference_data str — The simulation configuration name for the baseline misfit.
  • other_data builtins.list[str] | None — One or more other simulation configurations whose misfits will be compared against the reference.
  • misfit_configuration str — The misfit configuration.
  • event str | Event — The event to do it for.
  • shorten_names bool — If True, the names of all columns will be shortened so they are as short as possible while still being unique.
Returns pd.DataFrame
list()
def list(self) -> list[str]: ...

Get a list of all misfit configurations.

Returns list[str]