seismicmodel¶
- class dsmpy.seismicmodel.SeismicModel(vrmin, vrmax, rho, vpv, vph, vsv, vsh, eta, qmu, qkappa, model_id, mesh_type=None, model_params=None, discontinuous=False)¶
Represent a seismic Earth model for computation using DSM.
- Parameters
vrmin (ndarray) – 1D array containing lower bounds of layered structure [km]
vrmax (ndarray) – 1D array containing upper bounds of layered structure [km]
rho (ndarray) – 2D array specifying density using 3-degree polynomials for each layer [g/cm^3]
vpv (ndarray) – 2D array specifying V_PV using 3-degree polynomials for each layer [km/s]
vph (ndarray) – V_PH [km/s]
vsh (ndarray) – V_SH [km/s]
eta (ndarray) – radial anisotropy []
qmu (ndarray) – shear anelasic factor []
qkappa (ndarray) – bulk anelasic factor []
model_id (str) – model identifier (e.g., ‘prem’)
Attributes:
- classmethod ak135()¶
Return model AK135.
References
Kennett et al. (1995)
- classmethod ak135_prime()¶
Return model AK135.
References
Kennett et al. (1995)
- boxcar_mesh(model_parameters)¶
Create a boxcar mesh.
- Parameters
nodes (ndarray) – nodes of the boxcar mesh
- Returns
copy of self with added nodes mesh (SeismicModel): mesh with boxcar polynomials
- Return type
model (SeismicModel)
- build_model(model, model_params, value_dict: dict)¶
Convenience function to build an updated seismic model with model perturbations added.
- Parameters
model (SeismicModel) – the reference seismic model
model_params (ModelParameters) – model parameters
value_dict_p (dict) – dict of ParameterType:ndarray
- Returns
the updated seismic model
- Return type
- compute_avg(izones: list, type: dsmpy.modelparameters.ParameterType, n=2) → float¶
Return the average value for type in layers izones.
- get_value(izone: int, type: dsmpy.modelparameters.ParameterType) → numpy.ndarray¶
Get the polynomial coefficients for layer izone.
- Parameters
izone (int) – index of the layer
type (ParameterType) – type (e.g., ParameterType.VSH)
- Returns
3-degree polynomial coefficients
- Return type
np.ndarray
- get_value_at(r: float, type: dsmpy.modelparameters.ParameterType) → float¶
Return value at radius r.
- Parameters
r (float) – radius
type (ParameterType) – type (e.g., ParameterType.VSH)
- Returns
value for type at radius r
- Return type
float
- get_values(dr=1.0) -> (<class 'numpy.ndarray'>, <class 'dict'>)¶
Return a dict with values for each ParameterType.
- Parameters
dr (float) – radius increment in km (default: 1)
- Returns
radii dict: values. Keys are of type ParameterType
- Return type
ndarray
- get_zone(r: float) → int¶
Return index of layer that contains radius r (left inclusive, right exclusive).
- gradient_models()¶
Return a list of seismic models to compute the waveform gradients with respect to model parameters using central differences.
- Returns
the first half of the list corresponds to positive perturbations, the second half corresponds to negative perturbations list of float: corresponding perturbation vector
- Return type
list of SeismicModel
Examples
>>> from dsmpy.dsm import compute_models_parallel >>> model_params = ModelParameters( ... types=[ParameterType.VSH], ... radii=[3480., 3680.], ... mesh_type='boxcar') >>> model = SeismicModel.prem().boxcar_mesh(model_params) >>> grad_models, dxs = model.gradient_models() >>> outputs = compute_models_parallel( ... dataset, grad_models, tlen=1638.4, ... nspc=256, sampling_hz=20, mode=0) >>> n_params = len(grad_models) // 2 >>> n_evs = len(outputs[0]) >>> waveform_grads = [] >>> for i in range(n_params): ... waveform_grad_i = [] ... for iev in range(len(outputs[0])): ... outputs[i][iev].to_time_domain() ... outputs[i + n_params][iev].to_time_domain() ... waveform_grad_i_iev = (outputs[i][iev].us ... - outputs[i + n_params][iev].us) / (dxs[i] ... - dxs[i + n_params]) ... waveform_grad_i.append(waveform_grad_i_iev) ... waveform_grads.append(waveform_grad_i) >>> _, itypes, igrds = model_params.get_free_all_indices() >>> types = [model_params.types[i] for i in itypes] >>> radii = [model_params.get_grd_params()[i] ... for i in igrds]
- classmethod iasp91()¶
Return model IAS91.
References:
- lininterp_mesh(model_parameters, discontinuous=False)¶
- Parameters
nodes (ndarray) – nodes of the boxcar mesh
- Returns
copy of self with added nodes mesh (SeismicModel): mesh with boxcar polynomials
- Return type
model (SeismicModel)
- classmethod model_from_name(model_name)¶
Return SeismicModel from its identifier. Supported models are: - ak135 - prem
- multiply(values: numpy.ndarray)¶
Return a copy of self with the model perturbations in values added.
- Parameters
values (np.ndarray) – perturbations to model parameters (see ModelParameter.get_values_matrix())
- Returns
new mesh with added values
- Return type
Examples
>>> model_params = ModelParameters( types=[ParameterType.VSH], radii=[3480., 3680.], mesh_type='boxcar') >>> model = SeismicModel.prem().boxcar_mesh(model_params) >>> values_dict = {ParameterType.VSH: [0.1]} >>> values = model_params.get_values_matrix(values_dict) >>> updated_model = model.multiply(values)
>>> model_params = ModelParameters( types=[ParameterType.VSH], radii=[3480., 3680.], mesh_type='boxcar') >>> model = SeismicModel.prem().boxcar_mesh(model_params) >>> values = np.random.rand( model_params.get_n_grd_params(), 9) >>> updated_model = model.multiply(values)
- plot(dr=1.0, ax=None, types=None, color=None, **kwargs)¶
Plot the seismicModel.
- Parameters
dr (float) – depth increment (default is 1)
ax (matplotlib.ax) – ax
types (ParameterTypes) – e.g., RHO, VSH
color (str) – color
kwargs (dict) –
- Returns
matplotlib Figure object Axes: matplotlib Axes object
- Return type
Figure
- classmethod prem()¶
Return the Preliminary Reference Earth Model (PREM).
References
Dziewonski and Anderson (1981)
- set_value(izone: int, type: dsmpy.modelparameters.ParameterType, values: numpy.ndarray)¶
Set the polynomial coefficients for layer izone.
- Parameters
izone (int) – index of the layer
type (ParameterType) – type (e.g., ParameterType.VSH)
values (np.ndarray) – 3-degree polynomial coefficient
- triangle_mesh(model_parameters)¶
Create a triangular mesh.
- Parameters
nodes (ndarray) – nodes of the triangle mesh (defines the
of the triangles' peaks) (radii) –
- Returns
copy of self with added nodes mesh (SeismicModel): mesh with boxcar polynomials
- Return type
model (SeismicModel)