salvus.project.components.misfit_component
salvus.project.components.misfit_component salvus project components misfit_component The misfit component.
Classes
MisfitComponent
MisfitComponentclass MisfitComponent(builtins.object):
def __init__(self, project: salvus.project.project.Project): ...Project subclass handling all things related to misfits and gradients.
projectsalvus.project.project.Project — The project to attach the waveform component to.
compute_adjoint_source()
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.
simulation_configurationstr | _SimulationConfigurationBase — Name of the simulation configuration for the forward run.misfit_configurationstr | MisfitConfiguration — The name of the misfit configuration.eventsstr | typing.Sequence[str] | Event | typing.Sequence[Event] | EventCollection — One or more events.
get()
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.
simulation_configurationstr | SimulationConfiguration — Name of the simulation configuration for the forward run.misfit_configurationstr | MisfitConfiguration — The name of the misfit configuration.eventsstr | typing.Sequence[str] | Event | typing.Sequence[Event] | EventCollection — One or more events.skip_writing_adjoint_sourcebool | None — Optionally skip writing the adjoint source file.
get_event_misfit_object()
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.
simulation_configurationstr — Name of the simulation configuration for the forward run.misfit_configurationstr | MisfitConfiguration — Name of the misfit configuration.eventEvent | str — The event to use.
get_gradient_filenames()
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.
simulation_configurationstr | SimulationConfiguration — Simulation configuration for the forward run.misfit_configurationstr | MisfitConfiguration — The name of the misfit configuration.eventstr | Event — The event for which to get the gradient filenames.wavefield_compressionWavefieldCompression — Wavefield compression settings.gradient_parametersset[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.
"xdmf_filename" and "hdf5_filename". The values are the respective file paths.get_gradient_filenames_for_events()
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.
simulation_configurationstr | SimulationConfiguration — Simulation configuration for the forward run.misfit_configurationstr | MisfitConfiguration — The name of the misfit configuration.eventsstr | Event | typing.Sequence[str | Event] | EventCollection — The events for which to get the gradient filenames.wavefield_compressionWavefieldCompression — Wavefield compression settings.gradient_parametersset[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.
"xdmf_filename" and "hdf5_filename".get_misfit_comparison_table()
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.
reference_datastr — The simulation configuration name for the baseline misfit.other_databuiltins.list[str] | None — One or more other simulation configurations whose misfits will be compared against the reference.misfit_configurationstr — The misfit configuration.eventstr | Event — The event to do it for.shorten_namesbool — If True, the names of all columns will be shortened so they are as short as possible while still being unique.
list()
list()def list(self) -> list[str]: ...Get a list of all misfit configurations.