modelparameters¶
- class dsmpy.modelparameters.ModelParameters(types, radii, mesh_type='boxcar')¶
Represent parameters for a seismic model.
- The parameters are specified by:
- their types: ParameterType.VSH, VSV, VPH, VPV, ETA, QMU,
QKAPPA
- their radii (in km): the model parameters represent a layered
model, and the radii specify the boundaries of these layers.
- the mesh type:
‘boxcar’: constant properties in each layer
‘lininterp’: discontinuous linear spline in each layer
‘triangle’: still in development
- Parameters
types (list of ParameterType) – e.g., RHO, VSH
radii (ndarray) – radii of boundaries of perturbed layers
mesh_type (str) – ‘boxcar’, ‘triangle’, or ‘lininterp’
- apply_constraint(values: numpy.ndarray) → numpy.ndarray¶
Apply the model parameter constraints to the valye matrix.
- Parameters
values (np.ndarray) – (n_grd_params, 9)-matrix with model perturbations
- Returns
a copy of values with constraints applied
- Return type
np.ndarray
- get_free_all_indices() -> (<class 'list'>, <class 'list'>, <class 'list'>)¶
Return the generic, type, and grid indices of parameters without constraints.
- Returns
counter-like monotonous indices list of int: corresponding type index as in self.types list of int: corresponding grd_param index as in self.get_grd_params()
- Return type
list of int
- get_free_indices() → numpy.ndarray¶
Return the indices of parameters without constraints.
- get_mesh_type() → int¶
Return the mesh type.
- get_n_grd_params() → int¶
Get the number of radial parameters at which structure parameters (e.g. ParameterType.VSH) can be set.
- The number of parameters depend on the mesh type:
boxcar: get_n_grd_params() = get_nodes() - 1
- lininterp: get_n_grd_params() = get_nodes() * 2.
At each radial node, there is one parameter for the line segment above the node, and one parameter for the line segment below the node.
- get_n_nodes() → int¶
Return the number of radial grid nodes.
- get_n_params() → int¶
Return the total number of parameters get_n_grd_params() * len(get_types()).
- get_nodes() → numpy.ndarray¶
Return an array of radial grid nodes.
- get_shape_value_matrix() -> (<class 'int'>, <class 'int'>)¶
Return the shape of the value matrix
- get_types() → int¶
Return the parameter types
- get_values_matrix(values_dict: dict) → numpy.ndarray¶
Get the matrix used in Seismicmodel.multiply
- next() -> (<class 'int'>, <class 'int'>, <class 'int'>)¶
Increment and return the indices of the next model parameter. next() skips indices with constraints.
- Returns
iteration counter int: index of the current type (get_types()[i]) int: index of the current radial parameter
- Return type
int
- set_constraints(mask_dict=None, equal_dict=None, discon_arr=None)¶
Set constraints for model parameters at each grid point.
Three types of constraits. mask_dict and equal_dict act on the n_grd_params grid parameters; discon_arr acts on the n_nodes radial nodes.
- mask_dict: fix the value for a given ParameterType
and grid point (among n_grd_params)
- equal_dict: for a given ParameterType, an integer array
specify grid points that takes the same value
- discon_arr: for each radial node, specify wether this node
is discontinuous or not
- Parameters
mask_dict (dict) – keys are of type ParameterType,
are boolean np.ndarray of shape (values) –
equal_dict (dict) – keys are of type ParameterType,
are integer np.ndarray of shape (values) –
discon_arr (np.ndarray) – boolean array of shape (n_nodes,)
Examples
>>> mask_dict[ParameterType.VSH] = np.ones( model_params.get_n_grd_params(), dtype='bool') >>> equal_dict[ParameterType.VSH] = np.ones( model_params.get_n_grd_params(), dtype='bool') >>> discon_arr = np.ones( model_params.get_n_nodes(), dtype='bool') >>> model_params.set_constraints( mask_dict, equal_dict, discon_arr)