salvus.opt.mappings.mappings
Mappings between inversion parameters and simulation meshes.
Classes
BaseMapping
BaseMappingclass BaseMapping(salvus.flow.utils.serialization_helpers.SerializationMixin):
def __init__(
self,
inversion_parameters: List[str],
scaling: str,
map_to_physical_parameters: Optional[Dict[str, str]] = None,
discontinuous_model_blocks: Optional[List[List[int]]] = None,
):
...Class to map between model and simulation domains.
inversion_parametersList[str] — List of inversion parameters.scalingstr — Scaling of the inversion model.map_to_physical_parametersOptional[Dict[str, str]] — Dictionary defining the mapping from the model to the simulation space.discontinuous_model_blocksOptional[List[List[int]]] — Optionally specify which blocks in the unstructured mesh form discontinous regions of the model. The integer IDs refer to the fieldblockwhich must be store in the prior mesh.
from_json()
from_json()def from_json(d: Dict) -> Any:
...Recreate the object from a dictionary serialization of its initialization parameters.
dDict — Dictionary containing its init parameters and a few other things.
to_json()
to_json()def to_json(self, external_file_hash: Optional[str] = None) -> Dict:
...Serialize the object to dictionary that can be written to JSON.
external_file_hashOptional[str] — 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.
Mapping
Mappingclass Mapping(salvus.opt.mappings.mappings.BaseMapping):
def __init__(
self,
inversion_parameters: List[str],
scaling: Union[str, salvus.mesh.unstructured_mesh.UnstructuredMesh],
map_to_physical_parameters: Optional[Dict[str, str]] = None,
region_of_interest: Optional[
salvus.mesh.unstructured_mesh.UnstructuredMesh, numpy.ndarray
] = None,
source_cutout_radius_in_meters: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
receiver_cutout_radius_in_meters: Optional[
int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64
] = None,
discontinuous_model_blocks: Optional[List[List[int]]] = None,
):
...Class to map between model and simulation domains.
inversion_parametersList[str] — List of inversion parameters.scalingUnion[str, salvus.mesh.unstructured_mesh.UnstructuredMesh] — Scaling of the inversion model. Must be one ofabsolute,absolute_deviation_from_priororrelative_deviation_from_prioror custom point-wise scaling values provided as a numpy array or dictionary of numpy arrays for each of the physical parameters.map_to_physical_parametersOptional[Dict[str, str]] — Dictionary defining the mapping from the model to the simulation space.region_of_interestOptional[salvus.mesh.unstructured_mesh.UnstructuredMesh, numpy.ndarray] — Optional region of interest defined on an UnstructuredMesh or numpy array. Sensitivities outside the region of interest will be masked out during the adjoint mapping.source_cutout_radius_in_metersOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional event-dependent region-of-interest that cuts out a sphere around the source location(s).receiver_cutout_radius_in_metersOptional[int, numpy.int32, numpy.int64, float, numpy.float32, numpy.float64] — Optional event-dependent region-of-interest that cuts out a sphere around the receiver location(s).discontinuous_model_blocksOptional[List[List[int]]] — Optionally specify which blocks in the unstructured mesh form discontinous regions of the model. The integer IDs refer to the fieldblockwhich must be store in the prior mesh.
from_disk()
from_disk()def from_disk(d: Dict, path: Optional[pathlib.Path] = None) -> Mapping:
...Construct object from a JSON-serializable dictionary.
dDict — JSON dictionary of the iteration.pathOptional[pathlib.Path] — Path to the folder containing auxiliary files.
from_json()
from_json()def from_json(d: Dict) -> Any:
...Recreate the object from a dictionary serialization of its initialization parameters.
dDict — Dictionary containing its init parameters and a few other things.
adjoint()
adjoint()def adjoint(
self,
mesh: salvus.mesh.unstructured_mesh.UnstructuredMesh,
prior: salvus.mesh.unstructured_mesh.UnstructuredMesh,
model: Optional[
salvus.opt.models.unstructured_model.UnstructuredModel
] = None,
event: Optional[
salvus.flow.collections.event.Event,
salvus.flow.collections.event_data.EventData,
] = None,
name: str = "tmp",
) -> salvus.opt.models.unstructured_model.UnstructuredModel:
...Adjoint mapping to transform gradients from physical to modle space.
meshsalvus.mesh.unstructured_mesh.UnstructuredMesh — Model in physical space to apply the adjoint mapping to.priorsalvus.mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.modelOptional[salvus.opt.models.unstructured_model.UnstructuredModel] — Model at which the adjoint mapping is evaluated. Can be None for linear mappings.eventOptional[salvus.flow.collections.event.Event, salvus.flow.collections.event_data.EventData] — Event required for event-dependent mappings.namestr — Optional name of the resulting inversion model.
forward()
forward()def forward(
self,
model: salvus.opt.models.unstructured_model.UnstructuredModel,
prior: salvus.mesh.unstructured_mesh.UnstructuredMesh,
event: Optional[salvus.flow.collections.event.Event] = None,
) -> salvus.mesh.unstructured_mesh.UnstructuredMesh:
...Map inversion model parameters to physical parameters on a mesh.
modelsalvus.opt.models.unstructured_model.UnstructuredModel — Inversion model.priorsalvus.mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.eventOptional[salvus.flow.collections.event.Event] — Event required for event-dependent mappings.
inverse()
inverse()def inverse(
self,
mesh: salvus.mesh.unstructured_mesh.UnstructuredMesh,
prior: salvus.mesh.unstructured_mesh.UnstructuredMesh,
event: Optional[salvus.flow.collections.event.Event] = None,
name: str = "tmp",
) -> salvus.opt.models.unstructured_model.UnstructuredModel:
...Inverse mapping to transform a model in physical / simulation space to the inversion space.
meshsalvus.mesh.unstructured_mesh.UnstructuredMesh — Model in physical space to apply the inverse mapping to.priorsalvus.mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.eventOptional[salvus.flow.collections.event.Event] — Event required for event-dependent mappings.namestr — Optional name of the resulting inversion model.
to_disk()
to_disk()def to_disk(
self,
path: Optional[pathlib.Path] = None,
external_file_hash: Optional[str] = None,
) -> Dict:
...Serialize the object to dictionary that can be written to JSON. Auxiliary files will be written to the specified path.
pathOptional[pathlib.Path] — Path to store auxiliary files.external_file_hashOptional[str] — 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.
to_json()
to_json()def to_json(self, external_file_hash: Optional[str] = None) -> Dict:
...Serialize the object to dictionary that can be written to JSON.
external_file_hashOptional[str] — 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.
validate()
validate()def validate(
self, prior: salvus.mesh.unstructured_mesh.UnstructuredMesh
) -> None:
...Validate mapping for a given prior.
priorsalvus.mesh.unstructured_mesh.UnstructuredMesh — Prior model.