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

salvus.opt.models.unstructured_model

An unstructured mesh model

Classes

UnstructuredModel

class UnstructuredModel(salvus.opt.models.base_model.BaseModel):
    def __init__(
        self,
        name: str,
        model: Union[
            str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh
        ],
        fields: List[str],
    ):
        ...

Unstructured mesh inversion model.

Parameters
  • name str — Name of the model.
  • model Union[str, pathlib.Path, salvus.mesh.unstructured_mesh.UnstructuredMesh] — The unstructured mesh.
  • fields List[str] — Names of the elemental fields to use.
Attributes
model salvus.mesh.unstructured_mesh.UnstructuredMesh

The actual dataset representing the model.

name str

Model name.

status str

Model status to keep track of whether the model has been modified.

Methods
from_disk()
def from_disk(parent_folder: pathlib.Path, d: Dict) -> UnstructuredModel:
    ...

Load a model from disk. This will use the dictionary and path provided.

Parameters
  • parent_folder pathlib.Path — Path to store the model.
  • d Dict — Dictionary containing meta information of the model.
Returns UnstructuredModel
from_json()
def from_json(d: Dict) -> typing_extensions.Self:
    ...

Create a model from a dictionary.

Parameters
  • d Dict — Dictionary containing meta information of the model.
Returns typing_extensions.Self
copy()
def copy(self, name: str) -> UnstructuredModel:
    ...

Copy the model.

Parameters
  • name str — Name of the new model.
Returns UnstructuredModel
dot()
def dot(self, other: UnstructuredModel) -> float:
    ...

Compute dot product.

Parameters
  • other UnstructuredModel — Other model to compute the dot product with.
Returns float
max()
def max(self, other: UnstructuredModel) -> UnstructuredModel:
    ...

In-place point-wise maximum.

Parameters
  • other UnstructuredModel — Model to compare with.
Returns UnstructuredModel — A reference to the modified input model.
min()
def min(self, other: UnstructuredModel) -> UnstructuredModel:
    ...

In-place point-wise minimum.

Parameters
  • other UnstructuredModel — Model to compare with.
Returns UnstructuredModel — A reference to the modified input model.
norm()
def norm(self) -> float:
    ...

Return the model norm.

Returns float
norm_inf()
def norm_inf(self) -> float:
    ...

Infinity norm.

Returns float
to_disk()
def to_disk(self, parent_folder: Union[str, pathlib.Path]) -> Dict:
    ...

Serialize the model to JSON (and an associated npy file).

Parameters
  • parent_folder Union[str, pathlib.Path] — Parent folder where the JSON + h5 files should be stored.
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