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

salvus.opt.mappings.mappings

Mappings between inversion parameters and simulation meshes.

Classes

BaseMapping

class 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.

Parameters
  • inversion_parameters List[str] — List of inversion parameters.
  • scaling str — Scaling of the inversion model.
  • map_to_physical_parameters Optional[Dict[str, str]] — Dictionary defining the mapping from the model to the simulation space.
  • discontinuous_model_blocks Optional[List[List[int]]] — Optionally specify which blocks in the unstructured mesh form discontinous regions of the model. The integer IDs refer to the field block which must be store in the prior mesh.
Methods
from_json()
def from_json(d: Dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns Any
to_json()
def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash Optional[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.
Returns Dict

Mapping

class Mapping(salvus.opt.mappings.mappings.BaseMapping):
    def __init__(
        self,
        inversion_parameters: List[str],
        scaling: types,
        map_to_physical_parameters: Optional[Dict[str, str]] = None,
        region_of_interest: types = 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,
        postprocess_model_update: Optional[str, Callable] = None,
    ): ...

Class to map between model and simulation domains.

Parameters
  • inversion_parameters List[str] — List of inversion parameters.
  • scaling types — Scaling of the inversion model. Must be one of absolute, absolute_deviation_from_prior or relative_deviation_from_prior or custom point-wise scaling values provided as a numpy array or dictionary of numpy arrays for each of the physical parameters.
  • map_to_physical_parameters Optional[Dict[str, str]] — Dictionary defining the mapping from the model to the simulation space.
  • region_of_interest types — 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_meters Optional[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_meters Optional[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_blocks Optional[List[List[int]]] — Optionally specify which blocks in the unstructured mesh form discontinous regions of the model. The integer IDs refer to the field block which must be store in the prior mesh.
  • postprocess_model_update Optional[str, Callable] — Optionally pass a function to post-process the model update, e.g., by enforcing thresholds or inter-parameter relations which are not handled explicitly by constraints.
Methods
from_disk()
def from_disk(d: Dict, path: types = None) -> Mapping: ...

Construct object from a JSON-serializable dictionary.

Parameters
  • d Dict — JSON dictionary of the iteration.
  • path types — Path to the folder containing auxiliary files.
Returns Mapping
from_json()
def from_json(d: Dict) -> Any: ...

Recreate the object from a dictionary serialization of its initialization parameters.

Parameters
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns Any
adjoint()
def adjoint(
    self,
    mesh: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
    prior: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
    model: types = None,
    event: types = None,
    name: str = "tmp",
) -> salvus.opt.models.unstructured_model.UnstructuredModel: ...

Adjoint mapping to transform gradients from physical to modle space.

Parameters
  • mesh salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Model in physical space to apply the adjoint mapping to.
  • prior salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.
  • model types — Model at which the adjoint mapping is evaluated. Can be None for linear mappings.
  • event types — Event required for event-dependent mappings.
  • name str — Optional name of the resulting inversion model.
Returns salvus.opt.models.unstructured_model.UnstructuredModel
forward()
def forward(
    self,
    model: salvus.opt.models.unstructured_model.UnstructuredModel,
    prior: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
    event: types = None,
) -> (
    salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh
): ...

Map inversion model parameters to physical parameters on a mesh.

Parameters
  • model salvus.opt.models.unstructured_model.UnstructuredModel — Inversion model.
  • prior salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.
  • event types — Event required for event-dependent mappings.
Returns salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh
inverse()
def inverse(
    self,
    mesh: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
    prior: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
    event: types = None,
    name: str = "tmp",
) -> salvus.opt.models.unstructured_model.UnstructuredModel: ...

Inverse mapping to transform a model in physical / simulation space to the inversion space.

Parameters
  • mesh salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Model in physical space to apply the inverse mapping to.
  • prior salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Prior in physical / simulation space.
  • event types — Event required for event-dependent mappings.
  • name str — Optional name of the resulting inversion model.
Returns salvus.opt.models.unstructured_model.UnstructuredModel
to_disk()
def to_disk(
    self, path: types = None, external_file_hash: types = None
) -> Dict: ...

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

Parameters
  • path types — Path to store auxiliary files.
  • external_file_hash types — 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.
Returns Dict
to_json()
def to_json(self, external_file_hash: Optional[str] = None) -> Dict: ...

Serialize the object to dictionary that can be written to JSON.

Parameters
  • external_file_hash Optional[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.
Returns Dict
validate()
def validate(
    self,
    prior: salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh,
) -> None: ...

Validate mapping for a given prior.

Parameters
  • prior salvus.mesh.data_structures.unstructured_mesh.unstructured_mesh.UnstructuredMesh — Prior model.
Returns None