salvus.project.configuration.model.volume.cartesian
Classes
GenericModel
GenericModelclass GenericModel(
salvus.project.configuration.model.volume.cartesian._CartesianBase
):
def __init__(
self,
name: str,
data: Union[pathlib.Path, str, xarray.core.dataset.Dataset],
extrapolate: bool = True,
use_symlink: bool = False,
mode: Optional[str] = None,
ignore_element_flags: Optional[Tuple[str, int]] = None,
):
...Generic background model.
Parameters
namestr — Model name.dataUnion[pathlib.Path, str, xarray.core.dataset.Dataset] — The model data.extrapolatebool — Extrapolate the values if necessary.use_symlinkbool — Don’t copy the data to the project but only use a symlink. Only works if the data is passed as a filename or path.modeOptional[str] — Which mode of interpolation should be used. See the documentation forsalvus.toolbox.interpolate_cartesian.ignore_element_flagsOptional[Tuple[str, int]] — A tuple of (elemental_field_name, elemental_field_value). Elements which contain this value in their elemental_field p will not be interpolated onto. For instance, to restrict interpolation to elastic elements only, one could passmask=('fluid', 1).
Attributes
dim int
dim intDimensions of the model.
ds xarray.core.dataset.Dataset
ds xarray.core.dataset.DatasetThe actual dataset representing the model.
extrapolate bool
extrapolate boolExtrapolate or not?
interpolation_mode str
interpolation_mode strInterpolation mode.
mode Optional[str]
mode Optional[str]Which interpolate mode?
name str
name strModel name.
restrict_to_layers Optional[int, List[int], str]
restrict_to_layers Optional[int, List[int], str]Layers to restrict to.
Methods
from_json()
from_json()def from_json(parent_folder: pathlib.Path, d: Dict) -> _ModelBase:
...Recreate the object from a dictionary serialization of its initialization parameters.
Parameters
parent_folderpathlib.Path — Path to which the serialized model is relative to.dDict — Dictionary containing its init parameters and a few other things.
Returns _ModelBase
to_json()
to_json()def to_json(self, parent_folder: Union[str, pathlib.Path]) -> Dict:
...Serialize the model to JSON (and an associated NetCDF file).
Parameters
parent_folderUnion[str, pathlib.Path] — Parent folder where the JSON + NetCDF files should be stored.
Returns Dict