Version:

salvus.opt.models.generic_model

salvus.opt.models.generic_model salvus opt models generic_model
A generic model based on a numpy array.

Classes

GenericModel

Generic inversion model using a numpy array.
SIGNATURE
class GenericModel(salvus.opt.models.base_model.BaseModel):
    def __init__(self, name: str, data: str | pathlib.Path | npt.NDArray): ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the model.
Required
data
Type:str | pathlib.Path | npt.NDArray
Description:
Model data.

Properties

  • data(npt.NDArray)-The model data as an arbitrary numpy array.
  • model(npt.NDArray)-The model as its actual representation.
  • name(str)-Model name.
  • status(ModelStatus)-Model status to keep track of whether the model has been modified.
  • vector(npt.NDArray)-The model data as a vector. Returns: vector: The model data flattened to a 1D array.

Class Methods

GenericModel.from_disk()
Load a model from disk. This will use the dictionary and path provided.
SIGNATURE
def from_disk(parent_folder: pathlib.Path, d: dict) -> GenericModel: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path
Description:
Path to store the model.
Required
d
Type:dict
Description:
Dictionary containing meta information of the model.
GenericModel.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

GenericModel.compute_inf_norm()
Infinity norm of the model.
SIGNATURE
def compute_inf_norm(self) -> float: ...
GenericModel.compute_norm()
Return the model norm.
SIGNATURE
def compute_norm(self) -> float: ...
GenericModel.copy()
Copy the model.
SIGNATURE
def copy(self, name: str) -> GenericModel: ...
ARGUMENTS
Required
name
Type:str
Description:
Name of the new (copied) model.
GenericModel.dot()
Dot product of the model with another model.
SIGNATURE
def dot(self, other: GenericModel) -> float: ...
ARGUMENTS
Required
other
Type:GenericModel
Description:
The other model.
GenericModel.max()
In-place point-wise maximum.
SIGNATURE
def max(self, other: GenericModel) -> GenericModel: ...
ARGUMENTS
Required
other
Type:GenericModel
Description:
Model to compare with.
GenericModel.min()
In-place point-wise minimum.
SIGNATURE
def min(self, other: GenericModel) -> GenericModel: ...
ARGUMENTS
Required
other
Type:GenericModel
Description:
Model to compare with.
GenericModel.to_disk()
Serialize the model to JSON (and an associated npy file).
SIGNATURE
def to_disk(self, parent_folder: pathlib.Path | str) -> dict: ...
ARGUMENTS
Required
parent_folder
Type:pathlib.Path | str
Description:
Parent folder where the JSON + npy files should be stored.
GenericModel.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