multifaultsolve class

class csi.multifaultsolve(name, faults, verbose=True)

A class that assembles the linear inverse problem for multiple faults and multiple datasets. This class can also solve the problem using simple linear least squares (bounded or unbounded).

Args:
  • name : Name of the project.

  • faults : List of faults from verticalfault or pressure .

ConstrainedLeastSquareSoln(mprior=None, Mw_thresh=None, bounds=None, method='SLSQP', rcond=None, iterations=100, tolerance=None, maxfun=100000, checkIter=False, checkNorm=False)

Solves the least squares problem:

\(\text{min} [ (\textbf{d} - \textbf{Gm})^t \textbf{C}_d^{-1} (\textbf{d} - \textbf{Gm}) + \textbf{m}^t \textbf{C}_m^{-1} \textbf{m}]\)

Args:
  • mprior : a priori model; if None, mprior = np.zeros((Nm,))

  • Mw_thresh : upper bound on moment magnitude

  • bounds : list of tuple bounds for every parameter

  • method : solver for constrained minimization: SLSQP, COBYLA, or nnls

  • rcond : Add some conditionning for all inverse matrix to compute

  • iterations : Modifies the maximum number of iterations for the solver (default=100).

  • tolerance : Solver’s tolerance

  • maxfun : maximum number of funcrtion evaluation

  • checkIter : Show Stuff

  • checkNorm : prints the norm

Returns:
  • None

GeneralizedLeastSquareSoln(mprior=None, rcond=None, useCm=True)

Solves the generalized least-square problem using the following formula (Tarantolla, 2005, Inverse Problem Theory, SIAM):

\(\textbf{m}_{post} = \textbf{m}_{prior} + (\textbf{G}^t \textbf{C}_d^{-1} \textbf{G} + \textbf{C}_m^{-1})^{-1} \textbf{G}^t \textbf{C}_d^{-1} (\textbf{d} - \textbf{Gm}_{prior})\)

Args:
  • mprior : A Priori model. If None, then mprior = np.zeros((Nm,)).

Returns:
  • None

NonNegativeBruteSoln()

Solves the least square problem argmin_x || Ax - b ||_2 for x>=0. No Covariance can be used here, maybe in the future.

Returns:
  • None

OrganizeGBySlipmode()

Organize G by slip mode instead of fault segment Return the new G matrix.

Returns:
  • array

RunAltar(tasks=2, chains=1024, steps=100, support=(-10, 10))

Runs Altar on the d = Gm problem with a Cd covariance matrix.

Kwargs:
  • tasks : Number of mpi tasks.

  • chains : Number of chains.

  • steps : Number of metropolis steps.

  • support : Upper and Lower bounds of the parameter exploration.

Returns:
  • None

SetSolutionFromExternal(soln)

Takes a vector where the solution of the problem is and affects it to mpost.

Args:
  • soln : array

Returns:
  • None

SimpleLeastSquareSoln()

Solves the simple least square problem.

\(\textbf{m}_{post} = (\textbf{G}^t \textbf{G})^{-1} \textbf{G}^t \textbf{d}\)

Returns:
  • None

UnregularizedLeastSquareSoln(mprior=None)

Solves the unregularized generalized least-square problem using the following formula (Tarantolla, 2005, “Inverse Problem Theory”, SIAM):

\(\textbf{m}_{post} = \textbf{m}_{prior} + (\textbf{G}^t \textbf{C}_d^{-1} \textbf{G})^{-1} \textbf{G}^t \textbf{C}_d^{-1} (\textbf{d} - \textbf{Gm}_{prior})\)

Kwargs:
  • mprior : A Priori model. If None, then mprior = np.zeros((Nm,)).

Returns:
  • None

affectIndexParameters(fault)

Build the index parameter for a fault.

Args:
  • fault : instance of a fault

Returns:
  • None

assembleCm()

Assembles the Model Covariance Matrix for the concerned faults.

Returns:
  • None

assembleGFs()

Assembles the Green’s functions matrix G for the concerned faults or pressure sources.

Returns:
  • None

computeCmPostGeneral()

Computes the general posterior covariance matrix. See Tarantola 2005. Result is stored in self.Cmpost

conditionCd(singularValue)

Simple Conditioning of Cd.

Args:
  • singularValue : minimum of the kept singular Values

Returns:
  • None

describeParams(redo=True)

Print the parameter description.

Returns:
  • None

distributem(verbose=False)

After computing the m_post model, this routine distributes the m parameters to the faults.

Kwargs:
  • verbose : talk to me

Returns:
  • None

equalizeParams(iparams, Cm=None)

This is a step to force parameters to be equal. Effectively, since the problem is linear, we sum columns of G to have a single parameter. The parameter in question is set at the end of G. Cm is modified so that it has 1 on the idagonal or what is provided in Cm

The original G is saved as Goriginal. The original Cm is in Cmoriginal. The method distributem accounts for such modification by restoring G and Cm and the mpost vector according to the original problem.

iparams is a list of list of groups of parameters:

iparams = [ [1,2,3,19,39], [23, 24]]

Args:
  • iparams: List of lists

Kwargs:
  • Cm : List of covariances

makeParamDescription()

Store what parameters mean

Returns:
  • None

sensitivity()

Calculates the sensitivity matrix of the problem, \(S = \text{diag}( G^t C_d^{-1} G )\)

Returns:
  • array

simpleSampler(priors, initialSample, nSample, nBurn, plotSampler=False, writeSamples=False, dryRun=False, adaptiveDelay=300)

Uses a Metropolis algorithme to sample the posterior distribution of the model following Bayes’s rule. This is exactly what is done in AlTar, but using an open-source library called pymc. This routine is made for simple problems with few parameters (i.e. More than 30 params needs a very fast computer).

Args:
  • priorsList of priors. Each prior is specified by a list.
    • Example: priors = [ [‘Name of parameter’, ‘Uniform’, min, max], [‘Name of parameter’, ‘Gaussian’, center, sigma] ]

  • initialSample : List of initialSample.

  • nSample : Length of the Metropolis chain.

  • nBurn : Number of samples burned.

Kwargs:
  • plotSampler : Plot some usefull stuffs from the sampler (default: False).

  • writeSamples : Write the samples to a binary file.

  • dryRun : If True, builds the sampler, saves it, but does not run. This can be used for debugging.

  • adaptiveDelay : Recompute the covariance of the proposal every adaptiveDelay steps

The result is stored in self.samples. The variable mpost is the mean of the final sample set.

Returns:
  • None

strongConstraint(iparams, cov=1e-06)

Adds a bunch of lines to force the parameters {iparams} to be equal, within {cov}. Effectively, it adds a line of +1 and -1 to the parameters so that all {iparams} are equal to the first one. The equality will fall within {cov} as this number is set as the diagonal term of the data covariance for the corresponding lines.

Args:
  • iparams : List of parameters

Kwargs:
  • cov : Covariance

unequalizeParams()

Restores the shape of G and Cm and organizes mpost accordingly whem the problem has been altered by equalizedParams.

writeAltarCfgFile(prefix='linearfullcov', tasks=2, chains=1024, steps=100, support=(-10, 10), minimumratio=1e-06)

Writes a cfg and a py file to be used by altar.

Kwargs:
  • outfile : Prefix of problem

  • tasks : Number of mpi tasks.

  • chains : Number of chains.

  • steps : Number of metropolis steps.

  • support : Upper and Lower bounds of the parameter exploration.

  • minimumratio : Minimum Eignevalue to cut in the metropolis covariance matrix.

Returns:
  • None

writeAltarPriors(priors, params, modelName, files=['static.data.txt', 'static.Cd.txt', 'static.gf.txt'], prefix='model', chains=2048)

Writes the cfg file containing the priors to be used by altar. ONLY works with gaussian and uniform prior. And as if it was not bad enough, initial and run priors are the same.

Args:
  • priors : type of prior and corresponding parameters for each slip mode. ex: prior[‘Strike Slip’]=’gaussian’ & prior[‘Dip Slip’]=’uniform’

  • paramsParameters associated with each type of prior
    • params[‘gaussian’]=[[center,sigma]]

    • params[‘uniform’]=[[low,high]]

  • modelName : Name of the model

Kwargs:
  • files : Names of problem files

  • prefix : Prefix of problem

  • chains : Number of chains.

Returns:
  • None

writeCd2BinaryFile(outfile='Cd.dat', dtype='f', scale=1.0)

Writes the assembled Data Covariance matrix to a binary file.

Args:
  • outfile : Name of the output file.

  • scale : Multiply the data covariance.

  • dtype : Type of data to write. Can be ‘f’, ‘float’, ‘d’ or ‘double’.

Returns:
  • None

writeCd2H5File(outfile, name='static.Cd', scale=1.0)

Writes the assembled Data Covariance matrix to a hdf5 file

Args:
  • outfile : Name of the output file.

Kwargs:
  • scale : Multiply the data covariance.

  • name : name of the dataset in the file

Returns:
  • None

writeData2BinaryFile(outfile='d.dat', dtype='f')

Writes the assembled data vector to an output file.

Args:
  • outfile : Name of the output file.

  • dtype : Type of data to write. Can be ‘f’, ‘float’, ‘d’ or ‘double’.

Returns:
  • None

writeData2H5File(outfile, name='static.data')

Writes the assembled data vector to an output file.

Args:
  • outfile : Name of the output file.

Kwargs:
  • name : name of the dataset in the file

Returns:
  • None

writeGFs2BinaryFile(outfile='GF.dat', dtype='f')

Writes the assembled GFs to the file outfile.

Kwargs:
  • outfile : Name of the output file.

  • dtype : Type of data to write. Can be ‘f’, ‘float’, ‘d’ or ‘double’.

Returns:
  • None

writeGFs2H5File(outfile, name='static.gf')

Writes the assembled GFs to the file outfile.

Args:
  • outfile : Name of the output file.

Kwargs:
  • name : Name of the dataset in the file

Returns:
  • None

writeMpost2BinaryFile(outfile, dtype='d')

Writes the solution to a binary file.

Args:
  • outfile : Output file name

Kwargs:
  • dtype : ‘d’ for double and ‘f’ for single

Returns:
  • None

writeMpost2File(outfile)

Writes the solution to a file.

Args:
  • outfile : Output file name

Returns:
  • None

writeMpost2H5File(outfile, name='static.initialModel')

Writes the solution to a binary file.

Args:
  • outfile : Output file name

Kwargs:

*name : Name of the dataset

Returns:
  • None

writePatchAreasFile(outfile='PatchAreas.dat', dtype='d', npadStart=None, npadEnd=None)

Write a binary file for the patch areas to be read into altar.

Kwargs:
  • outfile : output file name

  • dtype : output data type

  • npadStart : number of starting zeros to pad output

  • npadEnd : number of ending zeros to pad output

Returns:
  • None

writeSamples2hdf5()

Writes the result of sampling to and HDF5 file.

Returns:
  • None