The problems.base
module¶
Base classes for Grond’s problem definition and the model history container.
Common behaviour of all source models offered by Grond is implemented here. Source model specific details are implemented in the respective submodules.
- class grond.problems.base.ModelHistory(problem, nchains=None, path=None, mode='r')[source]¶
Write, read and follow sequences of models produced in an optimisation run.
- Parameters
- add_listener(listener)[source]¶
Add a listener to the history
The listening class can implement the following methods: *
extend
- classmethod follow(path, nchains=None, wait=20.0)[source]¶
Start following a rundir (constructor).
- Parameters
path (str, optional) – the path to follow, a grond rundir
wait (number in seconds, optional) – wait time until the folder become alive
- Returns
A
ModelHistory
instance
- class grond.problems.base.Problem(**kwargs)[source]¶
Base class for objective function setup.
Defines the problem to be solved by the optimiser.
- ♦ name¶
str
- ♦ ranges¶
dict
ofpyrocko.gf.seismosizer.Range
objects, default:{}
- ♦ dependants¶
list
ofgrond.meta.Parameter
objects, default:[]
- ♦ norm_exponent¶
int
, default:2
- ♦ base_source¶
pyrocko.gf.seismosizer.Source
, optional
- ♦ targets¶
list
ofgrond.targets.base.MisfitTarget
objects, default:[]
- ♦ target_groups¶
list
ofgrond.targets.base.TargetGroup
objects, default:[]
- ♦ grond_version¶
str
, optional
- ♦ nthreads¶
int
, default:1
- combine_misfits(misfits, extra_weights=None, extra_residuals=None, extra_correlated_weights={}, get_contributions=False)[source]¶
Combine misfit contributions (residuals) to global or bootstrap misfits
- Parameters
misfits – 3D array
misfits[imodel, iresidual, 0]
are the misfit contributions (residuals)misfits[imodel, iresidual, 1]
are the normalisation contributions. It is also possible to give the misfit and normalisation contributions for a single model asmisfits[iresidual, 0]
and misfits[iresidual, 1]`` in which case, the first dimension (imodel) of the result will be stipped off.extra_weights – if given, 2D array of extra weights to be applied to the contributions, indexed as
extra_weights[ibootstrap, iresidual]
.extra_residuals – if given, 2D array of perturbations to be added to the residuals, indexed as
extra_residuals[ibootstrap, iresidual]
.extra_correlated_weights – if a dictionary of
imisfit: correlated weight matrix
is passed a correlated weight matrix is applied to the misfit and normalisation values. imisfit is the starting index in the misfits vector the correlated weight matrix applies to.get_contributions – get the weighted and perturbed contributions (don’t do the sum).
- Returns
if no extra_weights or extra_residuals are given, a 1D array indexed as
misfits[imodel]
containing the global misfit for each model is returned, otherwise a 2D arraymisfits[imodel, ibootstrap]
with the misfit for every model and weighting/residual set is returned.