pygimli.frameworks

Unified and method independent inversion frameworks.

Overview

Functions

fit(funct, data[, err])

Generic function fitter.

harmfit(y[, x, error, nc, resample, lam, ...])

GIMLi-based curve-fit by harmonic functions.

harmfitNative(y[, x, nc, xc, err])

Python-based curve-fit by harmonic functions.

Classes

Block1DInversion([fop])

Inversion of layered models (including layer thickness)

Block1DModelling([nPara, nLayers])

General forward operator for 1D layered models.

HarmFunctor(A, coeff, xmin, xSpan)

Functor for harmonic functions plus offset and drift.

Inversion([fop, inv])

Basic inversion framework.

JointModelling(fopList)

Cumulative (joint) forward operator.

JointPetroInversionManager(petros, mgrs)

Joint inversion targeting at the same parameter through petrophysics.

LCInversion([fop])

Quasi-2D Laterally constrained inversion (LCI) framework.

LCModelling(fop, **kwargs)

2D Laterally constrained (LC) modelling.

LinearModelling(A)

Modelling class for linearized problems with a given matrix.

MarquardtInversion([fop])

Marquardt scheme, i.e. local damping with decreasing strength.

MeshMethodManager(**kwargs)

MeshModelling(**kwargs)

Modelling class with a mesh discretization.

MethodManager([fop, fw, data])

General manager to maintenance a measurement method.

MethodManager1d([fop])

Method Manager base class for managers on a 1d discretization.

Modelling(**kwargs)

Abstract Forward Operator.

MultiFrameModelling(modellingOperator[, scalef])

Full frame (multiple fop parallel) forward modelling.

ParameterInversionManager([funct, fop])

Framework to invert unconstrained parameters.

ParameterModelling([funct])

Model with symbolic parameter names instead of numbers

PetroInversionManager(petro[, mgr])

Class for petrophysical inversion (s.

PetroModelling(fop, petro, **kwargs)

Combine petrophysical relation with the modelling class f(p).

PriorModelling([mesh, pos])

Forward operator for grabbing values out of a mesh (prior data).

Functions

fit

pygimli.frameworks.fit(funct, data, err=None, **kwargs)[source]

Generic function fitter.

Fit data to a given function.

Parameters
  • funct (callable) – Function with the first argmument as data space, e.g., x, t, f, Nr. .. Any following arguments are the parameters to be fit. Except if a verbose flag if used.

  • data (iterable (float)) – Data values

  • err (iterable (float) [None]) – Data error values in %/100. Default is 1% if None are given.

  • *dataSpace* (iterable) – Keyword argument of the data space of len(data). The name need to fit the first argument of funct.

Returns

  • model (array) – Fitted model parameter.

  • response (array) – Model response.

Example

>>> import pygimli as pg
>>>
>>> func = lambda t, a, b: a*np.exp(b*t)
>>> t = np.linspace(1, 2, 20)
>>> data = func(t, 1.1, 2.2)
>>> model, response = pg.frameworks.fit(func, data, t=t)
>>> print(pg.core.round(model, 1e-5))
2 [1.1, 2.2]
>>> _ = pg.plt.plot(t, data, 'o', label='data')
>>> _ = pg.plt.plot(t, response, label='response')
>>> _ = pg.plt.legend()

harmfit

pygimli.frameworks.harmfit(y, x=None, error=None, nc=42, resample=None, lam=0.1, window=None, verbose=False, dosave=False, lineSearch=True, robust=False, maxiter=20)[source]

GIMLi-based curve-fit by harmonic functions.

Parameters
  • y (1d-array - values to be fitted) –

  • x (1d-array(len(y)) - data abscissa data. default: [0 .. len(y))) –

  • error (1d-array(len(y)) error of y. default (absolute error = 0.01)) –

  • nc (int - Number of harmonic coefficients) –

  • resample (1d-array - resample y to x using fitting coeffients) –

  • window (int - just fit data inside window bounds) –

Returns

  • response (1d-array(len(resample) or len(x)) - smoothed values)

  • coefficients (1d-array - fitting coefficients)

harmfitNative

pygimli.frameworks.harmfitNative(y, x=None, nc=None, xc=None, err=None)[source]

Python-based curve-fit by harmonic functions.

Parameters
  • y (iterable) – values of a curve to be fitted

  • x (iterable) – abscissa, if none [0..len(y))

  • nc (int) – number of coefficients

  • err (iterable) – absolute data error

  • xc (iterable) – abscissa to predict y on (otherwise equal to x)

Classes

Block1DInversion

class pygimli.frameworks.Block1DInversion(fop=None, **kwargs)[source]

Bases: MarquardtInversion

Inversion of layered models (including layer thickness)

Variables

nLayers (int) –

__init__(fop=None, **kwargs)[source]
fixLayers(fixLayers)[source]

Fix layer thicknesses.

Parameters

fixLayers (bool | [float]) – Fix all layers to the last value or set the fix layer thickness for all layers

run(dataVals, errorVals, nLayers=None, fixLayers=None, layerLimits=None, paraLimits=None, **kwargs)[source]
Parameters
  • nLayers (int [4]) – Number of layers.

  • fixLayers (bool | [thicknesses]) – See: pygimli.modelling.Block1DInversion.fixLayers For fixLayers=None, preset or defaults are uses.

  • layerLimits ([min, max]) – Limits the thickness off all layers. For layerLimits=None, preset or defaults are uses.

  • paraLimits ([min, max] | [[min, max],...]) – Limits the range of the model parameter. If you have multiple parameters you can set them with a list of limits.

  • **kwargs – Forwarded to the parent class. See: pygimli.modelling.MarquardtInversion

setForwardOperator(fop)[source]
setLayerLimits(limits)[source]

Set min and max layer thickness.

Parameters

limits (False | [min, max]) –

setParaLimits(limits)[source]

Set the limits for each parameter region.

Block1DModelling

class pygimli.frameworks.Block1DModelling(nPara=1, nLayers=4, **kwargs)[source]

Bases: Modelling

General forward operator for 1D layered models.

Model space: [thickness_i, parameter_jk], with i = 0 - nLayers-1, j = (0 .. nLayers), k=(0 .. nPara)

__init__(nPara=1, nLayers=4, **kwargs)[source]

Constructor

Parameters
  • nLayers (int [4]) – Number of layers.

  • nPara (int [1]) – Number of parameters per layer (e.g. nPara=2 for resistivity and phase)

drawData(ax, data, err=None, label=None, **kwargs)[source]

Default data view.

Modelling creates the data and should know best how to draw them.

Probably ugly and you should overwrite it in your derived forward operator.

drawModel(ax, model, **kwargs)[source]
initModelSpace(nLayers)[source]

Set number of layers for the 1D block model

property nLayers
property nPara

HarmFunctor

class pygimli.frameworks.HarmFunctor(A, coeff, xmin, xSpan)[source]

Bases: object

Functor for harmonic functions plus offset and drift.

__init__(A, coeff, xmin, xSpan)[source]

Initialize.

Inversion

class pygimli.frameworks.Inversion(fop=None, inv=None, **kwargs)[source]

Bases: object

Basic inversion framework.

Changes to prior Versions (remove me)

  • holds the starting model itself, forward operator only provides a

method to create the starting model fop.createStartModel(dataValues)

Variables
  • verbose (bool) – Give verbose output

  • debug (bool) – Give debug output

  • startModel (float|array|None) – Current starting model that can be set in the init or as property. If not set explicitly, it will be estimated from the forward operator methods. This property will be recalulated for every run call if not set explicitly with self.startModel = float|array, or None to reforce autogeneration. Note that the run call accepts a temporary startModel (for the current calculation only).

  • model (array) – Holds the last active model

  • maxIter (int [20]) – Maximal interation number.

  • stopAtChi1 (bool [True]) – Stop iteration when chi² is one. If set to False the iteration stops after maxIter or convergence reached (self.inv.deltaPhiAbortPercent())

__init__(fop=None, inv=None, **kwargs)[source]
absrms()[source]

Absolute root-mean-square misfit of the last run.

property blockyModel
chi2(response=None)[source]

Chi-squared misfit (mean of squared error-weighted misfit).

convertStartModel(model)[source]
Convert scalar or array into startmodel with valid range or

self.fop.parameterCount, if possible.

Variables

model (float|int|array|None) –

property dataErrs
property dataTrans
property dataVals
property debug
echoStatus()[source]

Echo inversion status (model, response, rms, chi^2, phi).

property errorVals
property fop
property inv
property lam
property maxIter
property minDPhi
property model

The last active model.

property modelTrans
phi(model=None, response=None)[source]

Total objective function (phiD + lambda * phiM)

phiData(response=None)[source]

Data objective function (sum of suqred error-weighted misfit).

phiModel(model=None)[source]

Model objective function (norm of regularization term).

relrms()[source]

Relative root-mean-square misfit of the last run.

reset()[source]

Reset function currently called at beginning of every inversion.

property response
property robustData
run(dataVals, errorVals, **kwargs)[source]

Run inversion.

The inversion will always start from the starting model taken from the forward operator. If you want to run the inversion from a specified prior model, e.g., from a other run, set this model as starting model to the FOP (fop.setStartModel). Any self.inv.setModel() settings will be overwritten.

Parameters
  • dataVals (iterable) – Data values

  • errorVals (iterable) – Relative error values. dv / v

Keyword Arguments
  • maxIter (int) – Overwrite class settings for maximal iterations number.

  • dPhi (float [1]) – Overwrite class settings for delta data phi aborting criteria. Default is 1%

  • cType (int[1]) – Temporary global contraint type for all regions.

  • startModel (array) – Temporary starting model for the current inversion run.

  • lam (float) – Temporary regularization parameter lambda.

setData(data)[source]

Set data.

setDeltaChiStop(**kwargs)
setDeltaPhiStop(it)[source]

Define minimum relative decrease in objective function to stop.

setForwardOperator(fop)[source]
setPostStep(p)[source]

Set a function to be called after each iteration.

setPreStep(p)[source]

Set a function to be called before each iteration.

setRegularization(*args, **kwargs)[source]

Set regularization properties for the inverse problem.

This can be for specific regions (args) or all regions (no args).

Parameters
  • regionNr (int, [ints], '*') – Region number, list of numbers, or wildcard “*” for all.

  • startModel (float) – starting model value

  • limits ([float, float]) – lower and upper limit for value using a barrier transform

  • trans (str) – transformation for model barrier: “log”, “cot”, “lin”

  • cType (int) – constraint (regularization) type

  • zWeight (float) – relative weight for vertical boundaries

  • background (bool) – exclude region from inversion completely (prolongation)

  • fix (float) – exclude region from inversion completely (fix to value)

  • single (bool) – reduce region to one unknown

  • correlationLengths ([floats]) – correlation lengths for geostatistical inversion (x’, y’, z’)

  • dip (float [0]) – angle between x and x’ (first correlation length)

  • strike (float [0]) – angle between y and y’ (second correlation length)

showProgress(style='all')[source]

Show the inversion progress after every iteration.

Can show models if drawModel method exists. The default fallback is plotting the \(\chi^2\) fit as a function of iterations. Called if showProgress=True is set for the inversion run.

property startModel

Gives the current default starting model.

Returns the current default starting model or calls fop.createStartmodel() if none is defined.

property stopAtChi1
property verbose

JointModelling

class pygimli.frameworks.JointModelling(fopList)[source]

Bases: MeshModelling

Cumulative (joint) forward operator.

__init__(fopList)[source]

Initialize with lists of forward operators

createJacobian(model)[source]

Fill the individual Jacobian matrices.

createStartModel(data)[source]

Use inverse transformation to get m(p) for the starting model.

response(model)[source]

Concatenate responses for all fops.

setData(data)[source]

Distribute list of data to the forward operators.

setMesh(mesh, **kwargs)[source]

Set the parameter mesh to all fops.

JointPetroInversionManager

class pygimli.frameworks.JointPetroInversionManager(petros, mgrs)[source]

Bases: MeshMethodManager

Joint inversion targeting at the same parameter through petrophysics.

This is just syntactic sugar for the combination of pygimli.frameworks.PetroModelling and pygimli.frameworks.JointModelling.

__init__(petros, mgrs)[source]

Initialize with lists of managers and transformations

checkData(data)[source]

Collect data values.

checkError(err, data=None)[source]

Collect error values.

invert(data, **kwargs)[source]

Run inversion

LCInversion

class pygimli.frameworks.LCInversion(fop=None, **kwargs)[source]

Bases: Inversion

Quasi-2D Laterally constrained inversion (LCI) framework.

__init__(fop=None, **kwargs)[source]
prepare(dataVals, errorVals, nLayers=4, **kwargs)[source]
run(dataVals, errorVals, nLayers=4, **kwargs)[source]

Run inversion.

The inversion will always start from the starting model taken from the forward operator. If you want to run the inversion from a specified prior model, e.g., from a other run, set this model as starting model to the FOP (fop.setStartModel). Any self.inv.setModel() settings will be overwritten.

Parameters
  • dataVals (iterable) – Data values

  • errorVals (iterable) – Relative error values. dv / v

Keyword Arguments
  • maxIter (int) – Overwrite class settings for maximal iterations number.

  • dPhi (float [1]) – Overwrite class settings for delta data phi aborting criteria. Default is 1%

  • cType (int[1]) – Temporary global contraint type for all regions.

  • startModel (array) – Temporary starting model for the current inversion run.

  • lam (float) – Temporary regularization parameter lambda.

LCModelling

class pygimli.frameworks.LCModelling(fop, **kwargs)[source]

Bases: Modelling

2D Laterally constrained (LC) modelling.

2D Laterally constrained (LC) modelling based on BlockMatrices.

__init__(fop, **kwargs)[source]

Parameters: fop class .

createDefaultStartModel(models)[source]

Create the default startmodel as the median of the data values.

createJacobian(par)[source]

Create Jacobian matrix by creating individual Jacobians.

createParametrization(nSoundings, nLayers=4, nPar=1)[source]

Create LCI mesh and suitable constraints informations.

Parameters
  • nLayers (int) – Numbers of depth layers

  • nSoundings (int) – Numbers of 1D measurements to laterally constrain

  • nPar (int) – Numbers of independent parameter types, e.g., nPar = 1 for VES (invert for resisitivies), nPar = 2 for VESC (invert for resisitivies and phases)

drawModel(ax, model, **kwargs)[source]
initJacobian(dataVals, nLayers, nPar=None)[source]
Parameters

dataVals (ndarray | RMatrix | list) – Data values of size (nSounding x Data per sounding). All data per sounding need to be equal in length. If they don’t fit into a matrix use list of sounding data.

initModelSpace(nLayers)[source]

API

response(par)[source]

Cut together forward responses of all soundings.

setDataBasis(**kwargs)[source]

Set homogeneous data basis.

Set a common data basis to all forward operators. If you want individual you need to set them manually.

LinearModelling

class pygimli.frameworks.LinearModelling(A)[source]

Bases: Modelling

Modelling class for linearized problems with a given matrix.

__init__(A)[source]

Initialize by storing the (reference to the) matrix.

createJacobian(model)[source]

Do not compute a jacobian (linear).

property parameterCount

Define the number of parameters from the matrix size.

response(model)[source]

Linearized forward modelling by matrix-vector product.

MarquardtInversion

class pygimli.frameworks.MarquardtInversion(fop=None, **kwargs)[source]

Bases: Inversion

Marquardt scheme, i.e. local damping with decreasing strength.

__init__(fop=None, **kwargs)[source]
run(dataVals, errorVals, **kwargs)[source]
Parameters

**kwargs – Forwarded to the parent class. See: pygimli.modelling.Inversion

MeshMethodManager

class pygimli.frameworks.MeshMethodManager(**kwargs)[source]

Bases: MethodManager

__init__(**kwargs)[source]

Constructor.

mesh: GIMLI::Mesh

Copy of the main mesh to be distributed to inversion and the fop. You can overwrite it with invert(mesh=mesh).

applyMesh(mesh, ignoreRegionManager=False, **kwargs)[source]
coverage()[source]

Return coverage vector considering the logarithmic transformation.

createMesh(data=None, **kwargs)[source]

API, implement in derived classes.

invert(data=None, mesh=None, startModel=None, **kwargs)[source]

Run the full inversion.

Parameters
  • data (pg.DataContainer) –

  • mesh (GIMLI::Mesh [None]) –

  • startModel (float | iterable [None]) – If set to None fop.createDefaultStartModel(dataValues) is called.

Keyword Arguments
  • zWeight (float [None]) – Set zWeight or use defaults from regionManager.

  • correlationLengths ([float, float, float]) – Correlation lengths for geostatistical regularization

  • dip (float) – rotation axis between first and last dimension (x and z)

  • strike (float) – rotation axis between first and second dimension (x and y)

  • limits ([float, float]) – lower and upper value bounds for logarithmic transformation

  • Inversion.run (Al other are forwarded to) –

Returns

model – Model mapped for match the paraDomain Cell markers. The calculated model is in self.fw.model.

Return type

array

property paraDomain
paraModel(model=None)[source]

Give the model parameter regarding the parameter mesh.

setMesh(mesh, **kwargs)[source]

Set a mesh and distribute it to the forward operator

showFit(axs=None, **kwargs)[source]

Show data and the inversion result model response.

standardizedCoverage(threshhold=0.01)[source]

Return standardized coverage vector (0|1) using thresholding.

MeshModelling

class pygimli.frameworks.MeshModelling(**kwargs)[source]

Bases: Modelling

Modelling class with a mesh discretization.

__init__(**kwargs)[source]
Variables
  • fop (pg.frameworks.Modelling) –

  • data (pg.DataContainer) –

  • modelTrans ([pg.trans.TransLog()]) –

Parameters

**kwargs – fop : Modelling

createConstraints()[source]

Create constraint matrix.

createFwdMesh_()[source]
createRefinedFwdMesh(mesh)[source]

Refine the current mesh for higher accuracy.

This is called automatic when accessing self.mesh() so it ensures any effect of changing region properties (background, single).

drawModel(ax, model, **kwargs)[source]

Draw the model as mesh-based distribution.

ensureContent()[source]

Internal function to ensure there is a valid initialized mesh.

Initialization means the cell marker are recounted and/or there was a mesh refinement or boundary enlargement, all to fit the needs for the method depending forward problem.

mesh()[source]

Returns the current used mesh.

property paraDomain

Return parameter (inverse) mesh.

paraModel(model)[source]
setDefaultBackground()[source]
setMesh(mesh, ignoreRegionManager=False)[source]

Set mesh and specify whether region manager can be ignored.

setMeshPost(data)[source]

Interface to be called when the mesh has been set successfully.

Might be overwritten by child classes.

MethodManager

class pygimli.frameworks.MethodManager(fop=None, fw=None, data=None, **kwargs)[source]

Bases: object

General manager to maintenance a measurement method.

Method Manager are the interface to end-user interaction and can be seen as simple but complete application classes which manage all tasks of geophysical data processing.

The method manager holds one instance of a forward operator and an appropriate inversion framework to handle modelling and data inversion.

Method Manager also helps with data import and export, handle measurement data error estimation as well as model and data visualization.

Variables
  • verbose (bool) – Give verbose output.

  • debug (bool) – Give debug output.

  • fop (pygimli.frameworks.Modelling) – Forward Operator instance .. knows the physics. fop is initialized by pygimli.manager.MethodManager.initForwardOperator and calls a valid pygimli.manager.MethodManager.createForwardOperator method in any derived classes.

  • inv (pygimli.frameworks.Inversion.) – Inversion framework instance .. knows the reconstruction approach. The attribute inv is initialized by default but can be changed overwriting pygimli.manager.MethodManager.initInversionFramework

__init__(fop=None, fw=None, data=None, **kwargs)[source]

Constructor.

applyData(data)[source]
checkData(data)[source]

Overwrite for special checks to return data values

checkError(err, dataVals=None)[source]

Return relative error. Default we assume ‘err’ are relative values. Overwrite is derived class if needed.

static createArgParser(dataSuffix='dat')[source]

Create default argument parser.

TODO move this to some kind of app class

Create default argument parser for the following options:

-Q, –quiet -R, –robustData: options.robustData -B, –blockyModel: options.blockyModel -l, –lambda: options.lam -i, –maxIter: options.maxIter –depth: options.depth

createForwardOperator(**kwargs)[source]

Mandatory interface for derived classes.

Here you need to specify which kind of forward operator FOP you want to use. This is called by any initForwardOperator() call.

Parameters

**kwargs – Any arguments that are necessary for your FOP creation.

Returns

Instance of any kind of pygimli.framework.Modelling.

Return type

Modelling

createInversionFramework(**kwargs)[source]

Create default Inversion framework.

Derived classes may overwrite this method.

Parameters

**kwargs – Any arguments that are necessary for your creation.

Returns

Instance of any kind of pygimli.framework.Inversion.

Return type

Inversion

property debug
estimateError(data, errLevel=0.01, absError=None)[source]

Estimate data error.

Create an error of estimated measurement error. On default it returns an array of constant relative errors. More sophisticated error estimation should be done in specialized derived classes.

Parameters
  • data (iterable) – Data values for which the errors should be estimated.

  • errLevel (float (0.01)) – Error level in percent/100 (i.e., 3% = 0.03).

  • absError (float (None)) – Absolute error in the unit of the data.

Returns

err – Returning array of size len(data)

Return type

array

property fop
property fw
property inv
invert(data=None, err=None, **kwargs)[source]

Invert the data.

Invert the data by calling self.inv.run() with mandatory data and error values.

TODO

*need dataVals mandatory? what about already loaded data

Parameters
  • dataVals (iterable) – Data values to be inverted.

  • errVals (iterable | float) – Error value for the given data. If errVals is float we assume this means to be a global relative error and force self.estimateError to be called.

load(fileName)[source]

API, overwrite in derived classes.

property model
postRun(*args, **kwargs)[source]

Called just after the inversion run.

preRun(*args, **kwargs)[source]

Called just before the inversion run starts.

reinitForwardOperator(**kwargs)[source]

Reinitialize the forward operator.

Sometimes it can be useful to reinitialize the forward operator. Keyword arguments will be forwarded to ‘self.createForwardOperator’.

setData(data)[source]

Set a data and distribute it to the forward operator

showData(data=None, ax=None, **kwargs)[source]

Show the data.

Draw data values into a given axes or show the data values from the last run. Forwards on default to the self.fop.drawData function of the modelling operator. If there is no given function given, you have to override this method.

Parameters
  • ax (mpl axes) – Axes object to draw into. Create a new if its not given.

  • data (iterable | pg.DataContainer) – Data values to be draw.

Return type

ax, cbar

showFit(ax=None, **kwargs)[source]

Show the last inversion data and response.

showModel(model, ax=None, **kwargs)[source]

Show a model.

Draw model into a given axes or show inversion result from last run. Forwards on default to the self.fop.drawModel function of the modelling operator. If there is no function given, you have to override this method.

Parameters
  • ax (mpl axes) – Axes object to draw into. Create a new if its not given.

  • model (iterable) – Model data to be draw.

Return type

ax, cbar

showResult(model=None, ax=None, **kwargs)[source]

Show the last inversion result.

Parameters
  • ax (mpl axes) – Axes object to draw into. Create a new if its not given.

  • model (iterable [None]) – Model values to be draw. Default is self.model from the last run

Return type

ax, cbar

showResultAndFit(**kwargs)[source]

Calls showResults and showFit.

saveFig: str[None]

If not None save figure.

axs: [mpl.Axes]

Give 3 axes and its plotted into them instead of creating 3 new.

simulate(model, **kwargs)[source]
property verbose

MethodManager1d

class pygimli.frameworks.MethodManager1d(fop=None, **kwargs)[source]

Bases: MethodManager

Method Manager base class for managers on a 1d discretization.

__init__(fop=None, **kwargs)[source]

Constructor.

createInversionFramework(**kwargs)[source]
invert(data=None, err=None, **kwargs)[source]

Modelling

class pygimli.frameworks.Modelling(**kwargs)[source]

Bases: ModellingBaseMT__

Abstract Forward Operator.

Abstract Forward Operator that is or can use a Modelling instance. Can be seen as some kind of proxy Forward Operator.

__init__(**kwargs)[source]
Variables
  • fop (pg.frameworks.Modelling) –

  • data (pg.DataContainer) –

  • modelTrans ([pg.trans.TransLog()]) –

Parameters

**kwargs – fop : Modelling

clearRegionProperties()[source]

Clear all region parameter.

createDefaultStartModel(dataVals)[source]

Create the default startmodel as the median of the data values.

createStartModel(dataVals=None)[source]

Create the default startmodel as the median of the data values.

Overwriting might be a good idea. Its used by inversion to create a valid startmodel if there are no starting values from the regions.

property data

Return the associated data container.

C++ signature :

GIMLI::DataContainer {lvalue} data(GIMLI::ModellingBase {lvalue})

drawData(ax, data, **kwargs)[source]
drawModel(ax, model, **kwargs)[source]
ensureContent()[source]
estimateError(data, **kwargs)[source]

Create data error fallback when the data error is not known. Should be implemented method depending.

property fop
initModelSpace(**kwargs)[source]

API

property modelTrans
property parameterCount
regionManager()[source]
regionProperties(regionNr=None)[source]

Return dictionary of all properties for region number regionNr.

setData(data)[source]
setDataContainer(data)[source]
setDataPost(data)[source]

Called when the dataContainer has been set sucessfully.

setDataSpace(**kwargs)[source]

Set data space, e.g., DataContainer, times, coordinates.

setInterRegionCoupling(region1, region2, weight=1.0)[source]

Set the weighting for constraints across regions.

setRegionProperties(regionNr, **kwargs)[source]

Set region properties. regionNr can be ‘*’ for all regions.

startModel=None, limits=None, trans=None, cType=None, zWeight=None, modelControl=None, background=None, fix=None, single=None, correlationLengths=None, dip=None, strike=None

Parameters
  • regionNr (int, [ints], '*') – Region number, list of numbers, or wildcard “*” for all.

  • startModel (float) – starting model value

  • limits ([float, float]) – lower and upper limit for value using a barrier transform

  • trans (str) – transformation for model barrier: “log”, “cot”, “lin”

  • cType (int) – constraint (regularization) type

  • zWeight (float) – relative weight for vertical boundaries

  • background (bool) – exclude region from inversion completely (prolongation)

  • fix (float) – exclude region from inversion completely (fix to value)

  • single (bool) – reduce region to one unknown

  • correlationLengths ([floats]) – correlation lengths for geostatistical inversion (x’, y’, z’)

  • dip (float [0]) – angle between x and x’ (first correlation length)

  • strike (float [0]) – angle between y and y’ (second correlation length)

MultiFrameModelling

class pygimli.frameworks.MultiFrameModelling(modellingOperator, scalef=1.0)[source]

Bases: MeshModelling

Full frame (multiple fop parallel) forward modelling.

__init__(modellingOperator, scalef=1.0)[source]

Init class and jacobian matrix.

createConstraints()[source]

Create constraint matrix (special type for this).

createDefaultStartModel()[source]

Create the default startmodel as the median of the data values.

createJacobian((object)arg1, (object)model) object :[source]
C++ signature :

void* createJacobian(GIMLI::ModellingBase {lvalue},GIMLI::Vector<double>)

createJacobian( (object)arg1, (object)model) -> object :

C++ signature :

void* createJacobian(ModellingBase_wrapper {lvalue},GIMLI::Vector<double>)

createJacobian( (object)arg1, (object)model, (object)resp) -> object :

C++ signature :

void* createJacobian(GIMLI::ModellingBase {lvalue},GIMLI::Vector<double>,GIMLI::Vector<double>)

createJacobian( (object)arg1, (object)model, (object)resp) -> object :

C++ signature :

void* createJacobian(ModellingBase_wrapper {lvalue},GIMLI::Vector<double>,GIMLI::Vector<double>)

createStartModel(dataVals)[source]

Create the default startmodel as the median of the data values.

Overwriting might be a good idea. Its used by inversion to create a valid startmodel if there are no starting values from the regions.

property parameterCount
prepareJacobian()[source]

Build up Jacobian block matrix (once the sizes are known).

response((object)arg1, (object)model) object :[source]
C++ signature :

GIMLI::Vector<double> response(GIMLI::ModellingBase {lvalue},GIMLI::Vector<double>)

response( (object)arg1, (object)model) -> object :

C++ signature :

GIMLI::Vector<double> response(ModellingBase_wrapper {lvalue},GIMLI::Vector<double>)

setData(alldata, modellingOperator=None)[source]

Distribute the data containers amongst the fops.

setDefaultBackground()[source]

Set the default background behaviour.

setMeshPost(mesh)[source]

Interface to be called when the mesh has been set successfully.

Might be overwritten by child classes.

ParameterInversionManager

class pygimli.frameworks.ParameterInversionManager(funct=None, fop=None, **kwargs)[source]

Bases: MethodManager

Framework to invert unconstrained parameters.

__init__(funct=None, fop=None, **kwargs)[source]

Constructor.

createInversionFramework(**kwargs)[source]
invert(data=None, err=None, **kwargs)[source]
Parameters
  • limits ({str: [min, max]}) – Set limits for parameter by parameter name.

  • startModel ({str: startModel}) – Set the start value for parameter by parameter name.

ParameterModelling

class pygimli.frameworks.ParameterModelling(funct=None, **kwargs)[source]

Bases: Modelling

Model with symbolic parameter names instead of numbers

__init__(funct=None, **kwargs)[source]
Variables
  • fop (pg.frameworks.Modelling) –

  • data (pg.DataContainer) –

  • modelTrans ([pg.trans.TransLog()]) –

Parameters

**kwargs – fop : Modelling

addParameter(name, id=None, **kwargs)[source]
drawModel(ax, model)[source]
property params
response((object)arg1, (object)model) object :[source]
C++ signature :

GIMLI::Vector<double> response(GIMLI::ModellingBase {lvalue},GIMLI::Vector<double>)

response( (object)arg1, (object)model) -> object :

C++ signature :

GIMLI::Vector<double> response(ModellingBase_wrapper {lvalue},GIMLI::Vector<double>)

setRegionProperties(k, **kwargs)[source]

Set Region Properties by parameter name.

PetroInversionManager

class pygimli.frameworks.PetroInversionManager(petro, mgr=None, **kwargs)[source]

Bases: MeshMethodManager

Class for petrophysical inversion (s. Rücker et al. 2017).

__init__(petro, mgr=None, **kwargs)[source]

Initialize instance with manager and petrophysical relation.

PetroModelling

class pygimli.frameworks.PetroModelling(fop, petro, **kwargs)[source]

Bases: MeshModelling

Combine petrophysical relation with the modelling class f(p).

Combine petrophysical relation \(p(m)\) with a modelling class \(f(p)\) to invert for the petrophysical model \(p\) instead of the geophysical model \(m\).

\(p\) be the petrophysical model, e.g., porosity, saturation, … \(m\) be the geophysical model, e.g., slowness, resistivity, …

__init__(fop, petro, **kwargs)[source]

Save forward class and transformation, create Jacobian matrix.

createJacobian(model)[source]

Fill the individual jacobian matrices. J = dF(m) / dm = dF(m) / dp * dp / dm

createStartModel(data)[source]

Use inverse transformation to get m(p) for the starting model.

property petro
response(model)[source]

Use transformation to get p(m) and compute response f(p).

setDataPost(data)[source]
setMeshPost(mesh)[source]

PriorModelling

class pygimli.frameworks.PriorModelling(mesh=None, pos=None, **kwargs)[source]

Bases: MeshModelling

Forward operator for grabbing values out of a mesh (prior data).

__init__(mesh=None, pos=None, **kwargs)[source]

Init with mesh and some positions that are converted into ids.

createJacobian(model)[source]

Do nothing (linear).

createRefinedFwdMesh(mesh)[source]

Refine the current mesh for higher accuracy.

This is called automatic when accessing self.mesh() so it ensures any effect of changing region properties (background, single).

response(model)[source]

Return values at the indexed cells.

setMesh(mesh)[source]

Set mesh and specify whether region manager can be ignored.