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

salvus.project.configuration.model.volume.seismology

Classes

CrustalModel

class CrustalModel(
    salvus.project.configuration.model.volume.seismology._SeismologyBase
):
    def __init__(
        self,
        name: str,
        data: Union[pathlib.Path, str, xarray.core.dataset.Dataset],
        parameters: Optional[List[str]] = None,
        taper_in_degrees: Optional[float] = None,
        use_nan_mask_for_taper: Optional[str] = None,
        use_symlink: bool = False,
    ):
        ...

A crustal model.

Parameters
  • name str — Name of the model.
  • data Union[pathlib.Path, str, xarray.core.dataset.Dataset] — The actual data values.
  • parameters Optional[List[str]] — Only interpolate these parameters from the model.
  • taper_in_degrees Optional[float] — How many degrees to use to taper into the background model.
  • use_nan_mask_for_taper Optional[str] — Use a NaN mask for the taper.
  • use_symlink bool — 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.
Attributes
dim int

Dimensions of the model.

ds xarray.core.dataset.Dataset

The actual dataset representing the model.

interpolation_mode str

Interpolation mode.

name str

Model name.

restrict_to_layers Optional[int, List[int], str]

Layers to restrict to.

Methods
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_folder pathlib.Path — Path to which the serialized model is relative to.
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns _ModelBase
to_generic_model_cartesian()
def to_generic_model_cartesian(
    self,
    utm: Union[pyproj.crs.crs.CRS, str],
    ellipsoid: Union[pyproj.crs.crs.CRS, str],
    radius_in_meters: float = 6371000.0,
    points: Union[
        Tuple[int, int, int],
        Tuple[
            salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]
        ],
    ],
    method: str = "nearest",
    extrapolate: bool = True,
) -> salvus.project.configuration.model.volume.cartesian.GenericModel:
    ...

Convert a seismological model to a cartesian one.

Sometimes the model we work with are parameterized in spherical coordinates, but we would like to work on UTM domains. This function returns a Cartesian model which can then be used in a UTM context. This model is re-sampled onto a regular grid in Cartesian coordinates with, by default, the same extent as the original model in UTM coordinates. This behavior can be changed by additionally passing a UtmDomain object (see the documentation for points below).

If a model is passed with datasets suffixed with _nan, this routine will interpret the NANs in the model as defining transparent regions. Such a detection will automatically set extrapolate to False, and only the masked version of the parameter arrays will be present in the returned Cartesian model.

Parameters
  • utm Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the UTM domain to cast to.
  • ellipsoid Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the ellipsoid that the model is currently parameterized with respect to.
  • radius_in_meters float — The vertical units of the model are re-parameterized to depth. This radius is treated as depth 0.
  • points Union[Tuple[int, int, int], Tuple[salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]]] — A tuple of either: - A 3-tuple containing the number of grid point to use for the resampling in each dimension (nx, ny, nz). In this case the model extent will be the same as that defined by the spherical model. This may not be very appropriate if the model is, for instance, a global model. - A 4-tuple with the first entry being a UtmDomain object within which you would like to restrict the interpolation, and the next 2 entries being nx, ny as described above. The last entry should be another tuple itself with entries (max_depth, nz). This is because most global models go much deeper than the domain you’d like to simulate in a UTM setting.
  • method str — Which method to use for the scipy interpolation. Can be either “nearest” or “linear”. Note that “linear” may take a long time, depending on the size of the model.
  • extrapolate bool — Set the extrapolate flag on the resulting Cartesian model, which controls how the model is eventually interpolated onto a mesh which exceeds the model bounds.
Returns salvus.project.configuration.model.volume.cartesian.GenericModel
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_folder Union[str, pathlib.Path] — Parent folder where the JSON + NetCDF files should be stored.
Returns Dict

GenericModel

class GenericModel(
    salvus.project.configuration.model.volume.seismology._SeismologyBase
):
    def __init__(
        self,
        name: str,
        data: Union[pathlib.Path, str, xarray.core.dataset.Dataset],
        parameters: Optional[List[str]] = None,
        taper_in_degrees: Optional[float] = None,
        use_nan_mask_for_taper: Optional[str] = None,
        restrict_to_layers: Optional[int, List[int], str] = None,
        ignore_element_flags: Optional[Tuple[str, int]] = None,
        use_symlink: bool = False,
    ):
        ...

A generic (crust + mantle) model.

Parameters
  • name str — Name of the model.
  • data Union[pathlib.Path, str, xarray.core.dataset.Dataset] — The actual data values.
  • parameters Optional[List[str]] — Only interpolate these parameters from the model.
  • taper_in_degrees Optional[float] — How many degrees to use to taper into the background model.
  • use_nan_mask_for_taper Optional[str] — Use a NaN mask for the taper.
  • restrict_to_layers Optional[int, List[int], str] — Restrict to a few layers.
  • ignore_element_flags Optional[Tuple[str, int]] — Don’t do interpolation in elements which have a specific flag. For example, passing (“fluid”, 1) will ignore all elements where the elemental field “fluid” is set to 1.
  • use_symlink bool — 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.
Attributes
dim int

Dimensions of the model.

ds xarray.core.dataset.Dataset

The actual dataset representing the model.

interpolation_mode str

Interpolation mode.

name str

Model name.

restrict_to_layers Optional[int, List[int], str]

Layers to restrict to.

Methods
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_folder pathlib.Path — Path to which the serialized model is relative to.
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns _ModelBase
to_generic_model_cartesian()
def to_generic_model_cartesian(
    self,
    utm: Union[pyproj.crs.crs.CRS, str],
    ellipsoid: Union[pyproj.crs.crs.CRS, str],
    radius_in_meters: float = 6371000.0,
    points: Union[
        Tuple[int, int, int],
        Tuple[
            salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]
        ],
    ],
    method: str = "nearest",
    extrapolate: bool = True,
) -> salvus.project.configuration.model.volume.cartesian.GenericModel:
    ...

Convert a seismological model to a cartesian one.

Sometimes the model we work with are parameterized in spherical coordinates, but we would like to work on UTM domains. This function returns a Cartesian model which can then be used in a UTM context. This model is re-sampled onto a regular grid in Cartesian coordinates with, by default, the same extent as the original model in UTM coordinates. This behavior can be changed by additionally passing a UtmDomain object (see the documentation for points below).

If a model is passed with datasets suffixed with _nan, this routine will interpret the NANs in the model as defining transparent regions. Such a detection will automatically set extrapolate to False, and only the masked version of the parameter arrays will be present in the returned Cartesian model.

Parameters
  • utm Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the UTM domain to cast to.
  • ellipsoid Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the ellipsoid that the model is currently parameterized with respect to.
  • radius_in_meters float — The vertical units of the model are re-parameterized to depth. This radius is treated as depth 0.
  • points Union[Tuple[int, int, int], Tuple[salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]]] — A tuple of either: - A 3-tuple containing the number of grid point to use for the resampling in each dimension (nx, ny, nz). In this case the model extent will be the same as that defined by the spherical model. This may not be very appropriate if the model is, for instance, a global model. - A 4-tuple with the first entry being a UtmDomain object within which you would like to restrict the interpolation, and the next 2 entries being nx, ny as described above. The last entry should be another tuple itself with entries (max_depth, nz). This is because most global models go much deeper than the domain you’d like to simulate in a UTM setting.
  • method str — Which method to use for the scipy interpolation. Can be either “nearest” or “linear”. Note that “linear” may take a long time, depending on the size of the model.
  • extrapolate bool — Set the extrapolate flag on the resulting Cartesian model, which controls how the model is eventually interpolated onto a mesh which exceeds the model bounds.
Returns salvus.project.configuration.model.volume.cartesian.GenericModel
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_folder Union[str, pathlib.Path] — Parent folder where the JSON + NetCDF files should be stored.
Returns Dict

MantleModel

class MantleModel(
    salvus.project.configuration.model.volume.seismology._SeismologyBase
):
    def __init__(
        self,
        name: str,
        data: Union[pathlib.Path, str, xarray.core.dataset.Dataset],
        parameters: Optional[List[str]] = None,
        taper_in_degrees: Optional[float] = None,
        use_nan_mask_for_taper: Optional[str] = None,
        use_symlink: bool = False,
    ):
        ...

A mantle model.

Parameters
  • name str — Name of the model.
  • data Union[pathlib.Path, str, xarray.core.dataset.Dataset] — The actual data values.
  • parameters Optional[List[str]] — Only interpolate these parameters from the model.
  • taper_in_degrees Optional[float] — How many degrees to use to taper into the background model.
  • use_nan_mask_for_taper Optional[str] — Use a NaN mask for the taper.
  • use_symlink bool — 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.
Attributes
dim int

Dimensions of the model.

ds xarray.core.dataset.Dataset

The actual dataset representing the model.

interpolation_mode str

Interpolation mode.

name str

Model name.

restrict_to_layers Optional[int, List[int], str]

Layers to restrict to.

Methods
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_folder pathlib.Path — Path to which the serialized model is relative to.
  • d Dict — Dictionary containing its init parameters and a few other things.
Returns _ModelBase
to_generic_model_cartesian()
def to_generic_model_cartesian(
    self,
    utm: Union[pyproj.crs.crs.CRS, str],
    ellipsoid: Union[pyproj.crs.crs.CRS, str],
    radius_in_meters: float = 6371000.0,
    points: Union[
        Tuple[int, int, int],
        Tuple[
            salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]
        ],
    ],
    method: str = "nearest",
    extrapolate: bool = True,
) -> salvus.project.configuration.model.volume.cartesian.GenericModel:
    ...

Convert a seismological model to a cartesian one.

Sometimes the model we work with are parameterized in spherical coordinates, but we would like to work on UTM domains. This function returns a Cartesian model which can then be used in a UTM context. This model is re-sampled onto a regular grid in Cartesian coordinates with, by default, the same extent as the original model in UTM coordinates. This behavior can be changed by additionally passing a UtmDomain object (see the documentation for points below).

If a model is passed with datasets suffixed with _nan, this routine will interpret the NANs in the model as defining transparent regions. Such a detection will automatically set extrapolate to False, and only the masked version of the parameter arrays will be present in the returned Cartesian model.

Parameters
  • utm Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the UTM domain to cast to.
  • ellipsoid Union[pyproj.crs.crs.CRS, str] — A pyproj CRS object describing the ellipsoid that the model is currently parameterized with respect to.
  • radius_in_meters float — The vertical units of the model are re-parameterized to depth. This radius is treated as depth 0.
  • points Union[Tuple[int, int, int], Tuple[salvus.project.domain.dim3.UtmDomain, int, int, Tuple[float, int]]] — A tuple of either: - A 3-tuple containing the number of grid point to use for the resampling in each dimension (nx, ny, nz). In this case the model extent will be the same as that defined by the spherical model. This may not be very appropriate if the model is, for instance, a global model. - A 4-tuple with the first entry being a UtmDomain object within which you would like to restrict the interpolation, and the next 2 entries being nx, ny as described above. The last entry should be another tuple itself with entries (max_depth, nz). This is because most global models go much deeper than the domain you’d like to simulate in a UTM setting.
  • method str — Which method to use for the scipy interpolation. Can be either “nearest” or “linear”. Note that “linear” may take a long time, depending on the size of the model.
  • extrapolate bool — Set the extrapolate flag on the resulting Cartesian model, which controls how the model is eventually interpolated onto a mesh which exceeds the model bounds.
Returns salvus.project.configuration.model.volume.cartesian.GenericModel
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_folder Union[str, pathlib.Path] — Parent folder where the JSON + NetCDF files should be stored.
Returns Dict