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

salvus.mesh.models_1D

A class to handle 1D seismic velocity models

Functions

str2bool()

def str2bool(s: str) -> bool:
    ...

Convert string to bool

Parameters
  • s str — The string to convert.
Returns bool

Classes

ConstInterpolator

class ConstInterpolator(builtins.object):
    def __init__(self, const: float):
        ...
Parameters
  • const float — The constant to “interpolate”.

model

class model(builtins.object):
    def __init__(
        self,
        name: str,
        model_type: str,
        acoustic: bool,
        anelastic: bool,
        anisotropic: bool,
        nregions: int,
        discontinuities: numpy.ndarray,
        is_fluid: numpy.ndarray,
        model_parameters_fct: Dict[str, List[Callable]],
        scale: float,
        fref: float = 1.0,
        moho_idx: Optional[int] = None,
        moho_comp_idx: Optional[int] = None,
        description: str = "",
    ):
        ...

A class to handle the 1D background models

Parameters
  • name str — Model name
  • model_type str — Model type
  • acoustic bool — acoustic
  • anelastic bool — anelastic
  • anisotropic bool — anisotropic
  • nregions int — nregions
  • discontinuities numpy.ndarray — discontinuities
  • is_fluid numpy.ndarray — is_fluid
  • model_parameters_fct Dict[str, List[Callable]] — model_parameters_fct
  • scale float — scale
  • fref float — fref
  • moho_idx Optional[int] — moho_idx
  • moho_comp_idx Optional[int] — moho_comp_idx
  • description str — description
Attributes
available_parameters List[str]

All model parameters.

Methods
built_in()
def built_in(model_name: str, fluid_tolerance: float = 1e-10) -> model:
    ...

Create a 1D model from the predefined models. Call get_builtin_models() to find out which ones are available.

Parameters
  • model_name str — name of the model
  • fluid_tolerance float — maximum absolute value for the scaled vs to detect fluid
Returns model
deck()
def deck(
    file_name: str,
    disc_tolerance: float = 1e-10,
    fluid_tolerance: float = 1e-10,
    spline_order: int = 3,
    lines: Optional[List[str]] = None,
) -> model:
    ...

Create a 1D model from a ‘deck’ file format as used by Mineos and in the insight Science Team. Anisotropic files only.

Parameters
  • file_name str — the model file
  • disc_tolerance float — maximum absolute value for detecting two layers as the same depth (after scaling).
  • fluid_tolerance float — maximum absolute value for the scaled vs to detect fluid
  • spline_order int — maximum order of the spline interpolation. In regions with few layers the order will be adapted to nlayer - 1, i.e. for two nodes the interolation is linear.
  • lines Optional[List[str]] — lines
Returns model
homogeneous()
def homogeneous(
    model_parameters: Dict, scale: float, name: str = "", fref: float = 1.0
) -> model:
    ...

Create a simple homogeneous model.

Parameters
  • model_parameters Dict — dictionary with one of the following sets of keys: [“VP”, “VS”, “RHO”], [“VP”, “VS”, “RHO”, “QMU”, “QKAPPA”], [“VPV”, “VPH”, “VSV”, “VSH”, “ETA”, “RHO”], [“VPV”, “VPH”, “VSV”, “VSH”, “ETA”, “RHO”, “QMU”, “QKAPPA”], [“VP”, “RHO”], [“VP”, “RHO”, “QKAPPA”], [“VPV”, “VPH”, “RHO”], [“VPV”, “VPH”, “RHO”, “QKAPPA”],
  • scale float — scaling factor
  • name str — name
  • fref float — reference frequency at which the model is defined
Returns model
layered()
def layered(
    file_name: str,
    disc_tolerance: float = 1e-10,
    fluid_tolerance: float = 1e-10,
    spline_order: int = 3,
    lines: Optional[List[str]] = None,
) -> model:
    ...

Create a 1D model from a layered model file as introduced with AxiSEM 1.2.

Parameters
  • file_name str — the model file
  • disc_tolerance float — maximum absolute value for detecting two layers as the same depth (after scaling).
  • fluid_tolerance float — maximum absolute value for the scaled vs to detect fluid
  • spline_order int — maximum order of the spline interpolation. In regions with few layers the order will be adapted to nlayer - 1, i.e. for two nodes the interolation is linear.
  • lines Optional[List[str]] — lines
Returns model
polynomial()
def polynomial(
    file_name: str,
    fluid_tolerance: float = 1e-10,
    lines: Optional[List[str]] = None,
) -> model:
    ...

Create a 1D model from a polynomial model file, somewhat similar to the MINEOS polynomial models, but different file format.

Parameters
  • file_name str — the model file
  • fluid_tolerance float — maximum absolute value for the scaled vs to detect fluid
  • lines Optional[List[str]] — lines
Returns model
read()
def read(file_name: str) -> model:
    ...

A wrapper around the built_in() and external() constructors, determines the model type automatically

Parameters
  • file_name str — path to the model file
Returns model
compute_ellipticity()
def compute_ellipticity(
    self,
    epsilon_surf: Union[str, float] = "WGS84",
    nsteps: int = 100000,
    rtol: float = 1e-15,
    r_0: float = 1e-10,
    nsamp_per_layer: int = 100,
    order: int = 3,
) -> None:
    ...
Parameters
  • epsilon_surf Union[str, float] — epsilon_surf
  • nsteps int — nsteps
  • rtol float — rtol
  • r_0 float — The inner radius from which to start the ellipticity computation. Must be larger than 0, but should be very small.
  • nsamp_per_layer int — How finely to discretize each layer for the subsequent integration. The 1-D density of the model will be extracted at these points.
  • order int — order
Returns None
compute_norms()
def compute_norms(self, nsamp_per_layer: int = 100) -> None:
    ...
Parameters
  • nsamp_per_layer int — Samples per layer.
Returns None
get_builtin_models()
def get_builtin_models() -> List[str]:
    ...

Get a list of builtin models that can be loaded by model name only.

Returns List[str]
get_edgelengths()
def get_edgelengths(
    self,
    dominant_period: float = 50.0,
    elements_per_wavelength: float = 2.0,
    nsamp_min: int = 100,
    vp_mode: bool = False,
) -> numpy.ndarray:
    ...

Get maximum edge lengths (‘hmax’)

Parameters
  • dominant_period float — dominant period to be propagated through the mesh in seconds
  • elements_per_wavelength float — element size criterion: how many elements per dominant wavelength
  • nsamp_min int — how many samples to use for finding the minium velocity in each region
  • vp_mode bool — Use vp instead of vs.
Returns numpy.ndarray
get_edgelengths_radius()
def get_edgelengths_radius(
    self,
    radius: numpy.ndarray,
    dominant_period: float = 50.0,
    elements_per_wavelength: float = 2.0,
    nsamp_min: int = 100,
    vp_mode: bool = False,
) -> float:
    ...

Get maximum edge lengths (‘hmax’)

Parameters
  • radius numpy.ndarray — Radius at which to get the edge length.
  • dominant_period float — dominant period to be propagated through the mesh in seconds
  • elements_per_wavelength float — element size criterion: how many elements per dominant wavelength
  • nsamp_min int — how many samples to use for finding the minium velocity in each region
  • vp_mode bool — Use vp instead of vs.
Returns float
get_elastic_parameter()
def get_elastic_parameter(
    self,
    parameter_name: str,
    radius: numpy.ndarray,
    element_centroids: Optional[numpy.ndarray] = None,
    scaled: bool = True,
    get_elastic_parameter: Optional[Callable] = None,
    region: Optional[numpy.ndarray] = None,
    masks: Optional[numpy.ndarray, List[numpy.ndarray]] = None,
) -> numpy.ndarray:
    ...

Get elastic parameter as a function of radius.

Parameters
  • parameter_name str — name of the elastic parameter
  • radius numpy.ndarray — radius at which the velocity should be evaluated
  • element_centroids Optional[numpy.ndarray] — optionally provide the element centroids alongside with the radius to determine the region from which the parameter should be evaluated
  • scaled bool — scaled
  • get_elastic_parameter Optional[Callable] — get_elastic_parameter
  • region Optional[numpy.ndarray] — region
  • masks Optional[numpy.ndarray, List[numpy.ndarray]] — masks
Returns numpy.ndarray
get_elastic_parameter_list()
def get_elastic_parameter_list(
    self,
    parameter_name: List[str],
    radius: numpy.ndarray,
    element_centroids: Optional[numpy.ndarray] = None,
    scaled: bool = True,
    region: Optional[numpy.ndarray] = None,
    masks: Optional[numpy.ndarray] = None,
) -> Dict[str, numpy.ndarray]:
    ...

get elastic parameter as a function of radius. Same as get_elastic_parameter, but optimized for computing a whole list of parameters.

Parameters
  • parameter_name List[str] — name of the elastic parameter
  • radius numpy.ndarray — radius at which the velocity should be evaluated
  • element_centroids Optional[numpy.ndarray] — optionally provide the element centroids alongside with the radius to determine the region from which the parameter should be evaluated
  • scaled bool — scaled
  • region Optional[numpy.ndarray] — region
  • masks Optional[numpy.ndarray] — masks
Returns Dict[str, numpy.ndarray]
get_ellipticity()
def get_ellipticity(
    self, radius: numpy.ndarray, compute_ellipticity_kwargs: Dict = {}
) -> Callable:
    ...

Get the ellipticity as a function of radius.

Parameters
  • radius numpy.ndarray — radius at which the density should be evaluated
  • compute_ellipticity_kwargs Dict — Extra args passed to compute_ellipticity.
Returns Callable
get_fluid_regions()
def get_fluid_regions(self) -> List[Tuple[float, float]]:
    ...

get inner and outer radius of fluid regions as a list of tuples

Returns List[Tuple[float, float]]
get_gradient_gravity()
def get_gradient_gravity(
    self,
    radius: numpy.ndarray,
    element_centroids: Optional[numpy.ndarray] = None,
    r_0: float = 1e-10,
    compute_ellipticity_kwargs: Dict = {},
) -> numpy.ndarray:
    ...

Compute the derivative of the gravitational acceleration, needed for the operator H in Komatitsch & Tromp 2002b, eq 5. Is computed via the Poisson equation.

Parameters
  • radius numpy.ndarray — radius at which the density should be evaluated
  • element_centroids Optional[numpy.ndarray] — optionally provide the element centroids alongside with the radius to determine the region from which the the denty should be evaluated. Needed because the the gradient of the gravitational force is discontinuous at discontinuities of the density
  • r_0 float — r_0
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
Returns numpy.ndarray
get_gravitational_potential()
def get_gravitational_potential(
    self,
    radius: numpy.ndarray,
    compute_ellipticity_kwargs: Dict = {},
    get_mass_kwargs: Dict = {},
    get_ith_moment_radius_kwargs: Dict = {},
) -> numpy.ndarray:
    ...

get the gravitational potential as a function of radius.

Parameters
  • radius numpy.ndarray — radius at which the density should be evaluated
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
  • get_mass_kwargs Dict — get_mass_kwargs
  • get_ith_moment_radius_kwargs Dict — get_ith_moment_radius_kwargs
Returns numpy.ndarray
get_gravity()
def get_gravity(
    self,
    radius: numpy.ndarray,
    compute_ellipticity_kwargs: Dict = {},
    get_mass_kwargs: Dict = {},
) -> numpy.ndarray:
    ...

Get the gravity as a function of radius.

Parameters
  • radius numpy.ndarray — radius at which the density should be evaluated
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
  • get_mass_kwargs Dict — get_mass_kwargs
Returns numpy.ndarray
get_is_fluid()
def get_is_fluid(self, radius: numpy.ndarray) -> numpy.ndarray:
    ...

Get a boolean array for fluid regions (True = fluid)

Parameters
  • radius numpy.ndarray — radius
Returns numpy.ndarray
get_mass()
def get_mass(self, relative_error: float = 1e-10) -> float:
    ...
Parameters
  • relative_error float — relative_error
Returns float
get_moment_of_inertia()
def get_moment_of_inertia(self, relative_error: float = 1e-10) -> float:
    ...
Parameters
  • relative_error float — relative_error
Returns float
get_native_parameter()
def get_native_parameter(
    self,
    param: str,
    radius: numpy.ndarray,
    region: Optional[int] = None,
    scaled: bool = True,
) -> numpy.ndarray:
    ...

Get a native parameter as a function of radius.

Parameters
  • param str — parameter name
  • radius numpy.ndarray — radius at which the density should be evaluated
  • region Optional[int] — region
  • scaled bool — scaled
Returns numpy.ndarray
get_radial_mesh()
def get_radial_mesh(
    self,
    dominant_period: float = 50.0,
    elements_per_wavelength: float = 2.0,
    nsamp_min: int = 100,
    rmin: float = 0.0,
    rmax: Optional[float] = None,
) -> numpy.ndarray:
    ...
Parameters
  • dominant_period float — dominant
  • elements_per_wavelength float — elements_per_wavelength
  • nsamp_min int — nsamp_min
  • rmin float — rmin
  • rmax Optional[float] — rmax
Returns numpy.ndarray
get_rho()
def get_rho(
    self,
    radius: salvus.mesh.models_1D.V,
    scaled: bool = True,
    region: Optional[int] = None,
) -> salvus.mesh.models_1D.V:
    ...

Get the density as a function of radius.

Parameters
  • radius salvus.mesh.models_1D.V — radius at which the density should be evaluated
  • scaled bool — scaled
  • region Optional[int] — region
Returns salvus.mesh.models_1D.V
get_solid_fluid_boundaries()
def get_solid_fluid_boundaries(
    self, rmin: float = 0, rmax: float = 1.0
) -> numpy.ndarray:
    ...

get radii of solid-fluid boundaries

Parameters
  • rmin float — rmin
  • rmax float — rmax
Returns numpy.ndarray
get_vmin()
def get_vmin(
    self,
    radius: numpy.ndarray,
    scaled: bool = True,
    region: Optional[numpy.ndarray] = None,
) -> numpy.ndarray:
    ...

Get the minimum p- or s-wave velocity as a function of radius

Parameters
  • radius numpy.ndarray — radius at which the velocity should be evaluated
  • scaled bool — scaled
  • region Optional[numpy.ndarray] — region
Returns numpy.ndarray
get_vpmax()
def get_vpmax(
    self,
    radius: numpy.ndarray,
    scaled: bool = True,
    region: Optional[numpy.ndarray] = None,
) -> numpy.ndarray:
    ...

Get the maximum p-wave velocity as a function of radius.

Parameters
  • radius numpy.ndarray — radius at which the velocity should be evaluated
  • scaled bool — scaled
  • region Optional[numpy.ndarray] — region
Returns numpy.ndarray
plot()
def plot(
    self,
    nsamp_per_layer: int = 10,
    figure: Optional[matplotlib.figure.Figure] = None,
    show: bool = True,
    discontinuities: bool = False,
) -> Optional[matplotlib.figure.Figure]:
    ...
Parameters
  • nsamp_per_layer int — nsamp_per_layer
  • figure Optional[matplotlib.figure.Figure] — figure
  • show bool — show
  • discontinuities bool — discontinuities
Returns Optional[matplotlib.figure.Figure]
plot_ellipticity()
def plot_ellipticity(
    self,
    nsamp: int = 100,
    show: bool = True,
    compute_ellipticity_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
    ...
Parameters
  • nsamp int — nsamp
  • show bool — show
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
Returns Optional[matplotlib.figure.Figure]
plot_ellipticity_gravity()
def plot_ellipticity_gravity(
    self,
    nsamp: int = 100,
    log: bool = False,
    show: bool = True,
    compute_ellipticity_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
    ...
Parameters
  • nsamp int — nsamp
  • log bool — log
  • show bool — show
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
Returns Optional[matplotlib.figure.Figure]
plot_gravity()
def plot_gravity(
    self,
    nsamp: int = 500,
    rmax: float = 5.0,
    show: bool = True,
    compute_ellipticity_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
    ...
Parameters
  • nsamp int — nsamp
  • rmax float — rmax
  • show bool — show
  • compute_ellipticity_kwargs Dict — compute_ellipticity_kwargs
Returns Optional[matplotlib.figure.Figure]
plot_vp_vs_profile()
def plot_vp_vs_profile(
    self,
    nsamp_per_layer: int = 100,
    depth: bool = False,
    rho: bool = False,
    flat_earth: bool = False,
    crust_zoom_depth_km: Optional[float] = None,
    vlim_crust: Tuple[float, float] = (2.5, 8.0),
    title: Optional[str] = None,
    show: bool = True,
    inset_axes_kwargs: Any = None,
    figure: Optional[matplotlib.figure.Figure] = None,
    highlight_lvl: bool = False,
    colormap: Dict = {"VP": "k", "VS": "r", "RHO": "g"},
    linestylemap: Dict = {"VP": "-", "VS": "-", "RHO": "-"},
    discontinuities: bool = False,
) -> Optional[matplotlib.figure.Figure]:
    ...
Parameters
  • nsamp_per_layer int — nsamp_per_layer
  • depth bool — depth
  • rho bool — rho
  • flat_earth bool — flat_earth
  • crust_zoom_depth_km Optional[float] — crust_zoom_depth_km
  • vlim_crust Tuple[float, float] — vlim_crust
  • title Optional[str] — title
  • show bool — show
  • inset_axes_kwargs Any — inset_axes_kwargs
  • figure Optional[matplotlib.figure.Figure] — figure
  • highlight_lvl bool — highlight_lvl
  • colormap Dict — colormap
  • linestylemap Dict — linestylemap
  • discontinuities bool — discontinuities
Returns Optional[matplotlib.figure.Figure]