salvus.mesh.models_1D
A class to handle 1D seismic velocity models
Functions
str2bool()
str2bool()def str2bool(s: str) -> bool:
...Convert string to bool
sstr — The string to convert.
Classes
ConstInterpolator
ConstInterpolatorclass ConstInterpolator(builtins.object):
def __init__(self, const: float):
...constfloat — The constant to “interpolate”.
model
modelclass 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
namestr — Model namemodel_typestr — Model typeacousticbool — acousticanelasticbool — anelasticanisotropicbool — anisotropicnregionsint — nregionsdiscontinuitiesnumpy.ndarray — discontinuitiesis_fluidnumpy.ndarray — is_fluidmodel_parameters_fctDict[str, List[Callable]] — model_parameters_fctscalefloat — scalefreffloat — frefmoho_idxOptional[int] — moho_idxmoho_comp_idxOptional[int] — moho_comp_idxdescriptionstr — description
available_parameters List[str]
available_parameters List[str]All model parameters.
built_in()
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.
model_namestr — name of the modelfluid_tolerancefloat — maximum absolute value for the scaled vs to detect fluid
deck()
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.
file_namestr — the model filedisc_tolerancefloat — maximum absolute value for detecting two layers as the same depth (after scaling).fluid_tolerancefloat — maximum absolute value for the scaled vs to detect fluidspline_orderint — 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.linesOptional[List[str]] — lines
homogeneous()
homogeneous()def homogeneous(
model_parameters: Dict, scale: float, name: str = "", fref: float = 1.0
) -> model:
...Create a simple homogeneous model.
model_parametersDict — 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”],scalefloat — scaling factornamestr — namefreffloat — reference frequency at which the model is defined
layered()
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.
file_namestr — the model filedisc_tolerancefloat — maximum absolute value for detecting two layers as the same depth (after scaling).fluid_tolerancefloat — maximum absolute value for the scaled vs to detect fluidspline_orderint — 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.linesOptional[List[str]] — lines
polynomial()
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.
file_namestr — the model filefluid_tolerancefloat — maximum absolute value for the scaled vs to detect fluidlinesOptional[List[str]] — lines
read()
read()def read(file_name: str) -> model:
...A wrapper around the built_in() and external() constructors, determines the model type automatically
file_namestr — path to the model file
compute_ellipticity()
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:
...epsilon_surfUnion[str, float] — epsilon_surfnstepsint — nstepsrtolfloat — rtolr_0float — The inner radius from which to start the ellipticity computation. Must be larger than 0, but should be very small.nsamp_per_layerint — How finely to discretize each layer for the subsequent integration. The 1-D density of the model will be extracted at these points.orderint — order
compute_norms()
compute_norms()def compute_norms(self, nsamp_per_layer: int = 100) -> None:
...nsamp_per_layerint — Samples per layer.
get_builtin_models()
get_builtin_models()def get_builtin_models() -> List[str]:
...Get a list of builtin models that can be loaded by model name only.
get_edgelengths()
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’)
dominant_periodfloat — dominant period to be propagated through the mesh in secondselements_per_wavelengthfloat — element size criterion: how many elements per dominant wavelengthnsamp_minint — how many samples to use for finding the minium velocity in each regionvp_modebool — Use vp instead of vs.
get_edgelengths_radius()
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’)
radiusnumpy.ndarray — Radius at which to get the edge length.dominant_periodfloat — dominant period to be propagated through the mesh in secondselements_per_wavelengthfloat — element size criterion: how many elements per dominant wavelengthnsamp_minint — how many samples to use for finding the minium velocity in each regionvp_modebool — Use vp instead of vs.
get_elastic_parameter()
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.
parameter_namestr — name of the elastic parameterradiusnumpy.ndarray — radius at which the velocity should be evaluatedelement_centroidsOptional[numpy.ndarray] — optionally provide the element centroids alongside with the radius to determine the region from which the parameter should be evaluatedscaledbool — scaledget_elastic_parameterOptional[Callable] — get_elastic_parameterregionOptional[numpy.ndarray] — regionmasksOptional[numpy.ndarray, List[numpy.ndarray]] — masks
get_elastic_parameter_list()
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.
parameter_nameList[str] — name of the elastic parameterradiusnumpy.ndarray — radius at which the velocity should be evaluatedelement_centroidsOptional[numpy.ndarray] — optionally provide the element centroids alongside with the radius to determine the region from which the parameter should be evaluatedscaledbool — scaledregionOptional[numpy.ndarray] — regionmasksOptional[numpy.ndarray] — masks
get_ellipticity()
get_ellipticity()def get_ellipticity(
self, radius: numpy.ndarray, compute_ellipticity_kwargs: Dict = {}
) -> Callable:
...Get the ellipticity as a function of radius.
radiusnumpy.ndarray — radius at which the density should be evaluatedcompute_ellipticity_kwargsDict — Extra args passed tocompute_ellipticity.
get_fluid_regions()
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
get_gradient_gravity()
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.
radiusnumpy.ndarray — radius at which the density should be evaluatedelement_centroidsOptional[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 densityr_0float — r_0compute_ellipticity_kwargsDict — compute_ellipticity_kwargs
get_gravitational_potential()
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.
radiusnumpy.ndarray — radius at which the density should be evaluatedcompute_ellipticity_kwargsDict — compute_ellipticity_kwargsget_mass_kwargsDict — get_mass_kwargsget_ith_moment_radius_kwargsDict — get_ith_moment_radius_kwargs
get_gravity()
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.
radiusnumpy.ndarray — radius at which the density should be evaluatedcompute_ellipticity_kwargsDict — compute_ellipticity_kwargsget_mass_kwargsDict — get_mass_kwargs
get_is_fluid()
get_is_fluid()def get_is_fluid(self, radius: numpy.ndarray) -> numpy.ndarray:
...Get a boolean array for fluid regions (True = fluid)
radiusnumpy.ndarray — radius
get_mass()
get_mass()def get_mass(self, relative_error: float = 1e-10) -> float:
...relative_errorfloat — relative_error
get_moment_of_inertia()
get_moment_of_inertia()def get_moment_of_inertia(self, relative_error: float = 1e-10) -> float:
...relative_errorfloat — relative_error
get_native_parameter()
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.
paramstr — parameter nameradiusnumpy.ndarray — radius at which the density should be evaluatedregionOptional[int] — regionscaledbool — scaled
get_radial_mesh()
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:
...dominant_periodfloat — dominantelements_per_wavelengthfloat — elements_per_wavelengthnsamp_minint — nsamp_minrminfloat — rminrmaxOptional[float] — rmax
get_rho()
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.
radiussalvus.mesh.models_1D.V — radius at which the density should be evaluatedscaledbool — scaledregionOptional[int] — region
get_solid_fluid_boundaries()
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
rminfloat — rminrmaxfloat — rmax
get_vmin()
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
radiusnumpy.ndarray — radius at which the velocity should be evaluatedscaledbool — scaledregionOptional[numpy.ndarray] — region
get_vpmax()
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.
radiusnumpy.ndarray — radius at which the velocity should be evaluatedscaledbool — scaledregionOptional[numpy.ndarray] — region
plot()
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]:
...nsamp_per_layerint — nsamp_per_layerfigureOptional[matplotlib.figure.Figure] — figureshowbool — showdiscontinuitiesbool — discontinuities
plot_ellipticity()
plot_ellipticity()def plot_ellipticity(
self,
nsamp: int = 100,
show: bool = True,
compute_ellipticity_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
...nsampint — nsampshowbool — showcompute_ellipticity_kwargsDict — compute_ellipticity_kwargs
plot_ellipticity_gravity()
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]:
...nsampint — nsamplogbool — logshowbool — showcompute_ellipticity_kwargsDict — compute_ellipticity_kwargs
plot_gravity()
plot_gravity()def plot_gravity(
self,
nsamp: int = 500,
rmax: float = 5.0,
show: bool = True,
compute_ellipticity_kwargs: Dict = {},
) -> Optional[matplotlib.figure.Figure]:
...nsampint — nsamprmaxfloat — rmaxshowbool — showcompute_ellipticity_kwargsDict — compute_ellipticity_kwargs
plot_vp_vs_profile()
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]:
...nsamp_per_layerint — nsamp_per_layerdepthbool — depthrhobool — rhoflat_earthbool — flat_earthcrust_zoom_depth_kmOptional[float] — crust_zoom_depth_kmvlim_crustTuple[float, float] — vlim_crusttitleOptional[str] — titleshowbool — showinset_axes_kwargsAny — inset_axes_kwargsfigureOptional[matplotlib.figure.Figure] — figurehighlight_lvlbool — highlight_lvlcolormapDict — colormaplinestylemapDict — linestylemapdiscontinuitiesbool — discontinuities