Version:

salvus.opt.models.structured_model

salvus.opt.models.structured_model salvus opt models structured_model
A structured model class based on xarray Datasets.

Classes

StructuredModel

Structured inversion model based on xarray DataSets.
SIGNATURE
class StructuredModel(salvus.opt.models.base_model.BaseModel):
    def __init__(
        self,
        name: str,
        model: str | pathlib.Path | xr.Dataset,
        fields: list[str],
    ): ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the model.
Required
model
Type:str | pathlib.Path | xr.Dataset
Description:
xarray DataSet.
Required
fields
Type:list[str]
Description:
Names of the elemental fields to use.

Properties

  • model(xr.Dataset)-The model as its actual representation.
  • name(str)-Model name.
  • status(ModelStatus)-Model status to keep track of whether the model has been modified.

Class Methods

StructuredModel.from_disk()
Load a model from disk.
SIGNATURE
def from_disk(parent_folder: pathlib.Path, d: dict) -> StructuredModel: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path
Description:
Path where the model is stored.
Required
d
Type:dict
Description:
Dictionary containing meta information of the model.
StructuredModel.from_json()
Create a model from a dictionary.
SIGNATURE
def from_json(d: dict) -> Self: ...
ARGUMENTS
Required
d
Type:dict
Description:
Dictionary containing meta information of the model.

Methods

StructuredModel.compute_inf_norm()
Infinity norm of the model.
SIGNATURE
def compute_inf_norm(self) -> float: ...
StructuredModel.compute_norm()
Return the model norm.
SIGNATURE
def compute_norm(self) -> float: ...
StructuredModel.copy()
Copy the model.
SIGNATURE
def copy(self, name: str) -> StructuredModel: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the new (copied) model.
StructuredModel.dot()
Dot product of the model with another model.
SIGNATURE
def dot(self, other: StructuredModel) -> float: ...
ARGUMENTS
Required
other
Type:StructuredModel
Description:
The other model.
StructuredModel.max()
In-place point-wise maximum.
SIGNATURE
def max(self, other: StructuredModel) -> StructuredModel: ...
ARGUMENTS
Required
other
Type:StructuredModel
Description:
Model to compare with.
StructuredModel.min()
In-place point-wise minimum.
SIGNATURE
def min(self, other: StructuredModel) -> StructuredModel: ...
ARGUMENTS
Required
other
Type:StructuredModel
Description:
Model to compare with.
StructuredModel.to_disk()
Serialize the model to disk. This will use the model name and the path provided. Heavy data are written directly to disk, light data are returned as dictionary.
SIGNATURE
def to_disk(self, parent_folder: pathlib.Path | str) -> dict: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path | str
Description:
Path to store the model.
StructuredModel.to_json()
Serialize the object to a dictionary that can be written to JSON.
SIGNATURE
def to_json(
    self,
    external_file_hash: types = None,
    timer: types = None,
    log_to_logger: bool = False,
    comm: types = None,
) -> builtins.dict: ...
ARGUMENTS
Optional
external_file_hash
Type:types
Default value:None
Description:
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.
Optional
timer
Type:types
Default value:None
Description:
Execution timer.
Optional
log_to_logger
Type:bool
Default value:False
Description:
Log timings to the logger.
Optional
comm
Type:types
Default value:None
Description:
MPI communicator, if any.
PAGE CONTENTS