pybert.manager package

What we have here?

Submodules

pybert.manager.ertipmanager module

pybert.manager.ertmanager module

Resistivity manager for administrating ERT data, modelling and inversion

class pybert.manager.ertmanager.ERTManager(filename=None, verbose=True, debug=False, **kwargs)[source]

Bases: pygimli.manager.methodManager.MeshMethodManager

Class for managing a resistivity inversion.

Takes care of the standard setup logistics.

Methods

apparentData() Convert data into apparent data.
checkData() Check data validity.
coverageDC() Return coverage vector considering the logarithmic transformation.
createArgParser([dataSuffix]) Create argument parser for the manager.
createData(sensors, scheme) Create an empty data set.
createFOP([verbose, sr]) Create forward operator working on refined mesh.
createFOP_([verbose]) Create forward operator working on refined mesh.
createInv(fop[, verbose, dosave]) create inversion instance
createInv_(fop[, verbose, dosave]) Create inversion instance, data- and model transformations.
createMesh([depth, quality, maxCellArea, …]) create (inversion) WRITEME
dataToken() Token name for the data in a DataContainer.
echoStatus() Echo inversion status as known from pygimli core (invisible).
estimateError(data[, absoluteError, …]) Estimate error composed of an absolute and a relative part.
getDepth() get typical investigation depth
invert([data, rhoa, err, mesh]) Run the full inversion.
loadData(filename) ” load data from file
model() Return resistivity model (for compatibility).
run(**kwargs) Run inversion.
saveResult([folder, size]) Saves the results in the specified folder.
setData(data) set data container from outside
setDataToken(token) Set the token name to identity the data in a DataContainer.
setMesh(mesh[, refine, refineP2, omitBackground]) -> maybe in base
setMeshPot([mesh, pot]) set mesh and potential from outside (mesh/matrix or filename)
setPrimPot(pot) set primary potential (string or matrix) and check size
setSingularityRemoval([sr]) Turn on singularity removal (should only be used when initializing).
setVerbose(verbose) Make the class verbose (put output to the console)
show(mesh, model) Show data in form of apparent resistivity.
showCoverage([ax, name]) Show resulting resistivity vector.
showData([ax, vals, name]) Show data in form of apparent resistivity.
showMesh([all, ax, marker]) show mesh in given axes or in a new figure
showModel([ax, vals]) Show any vector in new or existing axis.
showResult([ax, name]) Show resulting resistivity vector.
showResultAndFit([figsize]) Show resstivity distribution with data and forward response.
simulate(mesh, res, scheme[, verbose]) Simulate an ERT measurement.
standardizedCoverage([threshhold]) Return standardized coverage vector (0|1) using thresholding.
createApparentData  
coverageDC()[source]

Return coverage vector considering the logarithmic transformation.

createApparentData(data)[source]
static createFOP(verbose=False, sr=True)[source]

Create forward operator working on refined mesh.

Parameters:
verbose : bool, optional

Turn verbose output on/off. Is propagated to the fop object. Default: False

sr : bool, optional

Return a forward operator with singularity removal turned on or off. Default: True

Returns:
fop: :bertapi:`Bert::DCSRMultiElectrodeModelling` |
:bertapi:`Bert::pb.DCMultiElectrodeModelling`
createInv(fop, verbose=True, dosave=False)[source]

create inversion instance

createMesh(depth=None, quality=34.3, maxCellArea=0.0, paraDX=0.3, plc=None)[source]

create (inversion) WRITEME

echoStatus()[source]

Echo inversion status as known from pygimli core (invisible).

static estimateError(data, absoluteError=0.001, relativeError=0.03, absoluteUError=None, absoluteCurrent=0.1)[source]

Estimate error composed of an absolute and a relative part. This is a static method and will not alter any member of the Manager

Parameters:
absoluteError : float [0.001]

Absolute data error in Ohm m. Need ‘rhoa’ values in data.

relativeError : float [0.03]

relative error level in %/100

absoluteUError : float [0.001]

Absolute potential error in V. Need ‘u’ values in data. Or calculate them from ‘rhoa’, ‘k’ and absoluteCurrent if no ‘i’ is given

absoluteCurrent : float [0.1]

Current level in A for reconstruction for absolute potential V

Returns:
error : Array
getDepth()[source]

get typical investigation depth

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

Run the full inversion.

The data and error needed to be set before. The meshes will be created if necessary.

Parameters:
data : pg.DataContainerERT

The data scheme with ‘rhoa’ and ‘err’ data array.

rhoa : iterable

Will overwrite data(‘rhoa’)

err : iterable

Will overwrite data(‘err’)

mesh : pg.Mesh

Inversion mesh, needs the usual regions. Only 1 region for Neumann domains(no Boundary). Two region (marker 1 and 2) one for Background Boundary and one for the Inversion domain.

**kwargs
  • lam : float [20]
    regularization parameter
  • zWeight : float [0.7]
    relative vertical weight
  • maxIter : int [20]
    maximum iteration number
  • robustData : bool [False]
    robust data reweighting using an L1 scheme (IRLS reweighting)
  • blockyModel : bool [False]
    blocky model constraint using L1 reweighting roughness vector
  • startModelIsReference : bool [False]
    startmodel is the reference model for the inversion

forwarded to createMesh

  • depth
  • quality
  • paraDX
  • maxCellArea
loadData(filename)[source]

” load data from file

model()[source]

Return resistivity model (for compatibility).

run(**kwargs)[source]

Run inversion. deprecated, use invert instead.

saveResult(folder=None, size=(16, 10), **kwargs)[source]

Saves the results in the specified folder.

Saved items are:
Inverted profile Resistivity vector Coverage vector Standardized coverage vector Mesh (bms and vtk with results)
setData(data)[source]

set data container from outside

base api

setMesh(mesh, refine=True, refineP2=False, omitBackground=False)[source]

-> maybe in base

setMeshPot(mesh='mesh/mesh.bms', pot=None)[source]

set mesh and potential from outside (mesh/matrix or filename)

setPrimPot(pot)[source]

set primary potential (string or matrix) and check size

setSingularityRemoval(sr=True)[source]

Turn on singularity removal (should only be used when initializing).

show(mesh, model)[source]

Show data in form of apparent resistivity.

showCoverage(ax=None, name='result', **kwargs)[source]

Show resulting resistivity vector.

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

Show data in form of apparent resistivity.

showMesh(all=False, ax=None, marker=False)[source]

show mesh in given axes or in a new figure

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

Show any vector in new or existing axis.

Parameters:
adjustWorldAxes : bool [True]

Adjust world axes to y-Depth and x (m) if y max <= 0.

showResult(ax=None, name='result', **kwargs)[source]

Show resulting resistivity vector.

showResultAndFit(figsize=(10, 15), **kwargs)[source]

Show resstivity distribution with data and forward response.

simulate(mesh, res, scheme, verbose=False, **kwargs)[source]

Simulate an ERT measurement.

Perform the forward task for a given mesh, a resistivity distribution (per cell) and return data (apparent resistivity) for a measurement scheme.

This is a static method since it does not interfere with the Managers inversion approaches.

This function can also operate on complex resistivity models, thereby computing complex apparent resistivities.

Parameters:
mesh : :gimliapi:`GIMLI::Mesh`

Mesh to calculate for.

res : array(mesh.cellCount()) | array(N, mesh.cellCount())
Resistivity distribution for the given mesh cells can be:
  • single array of len mesh.cellCount()
  • matrix of N resistivity distributions of len mesh.cellCount()
  • res map as [[marker0, res0], [marker1, res1], …]
scheme : :bertapi:`Bert::DataContainerERT`

data measurement scheme

**kwargs :
  • sr : bool [True]
    Calculate with singularity removal. Recommended only for meshes with topography beacause the primary potential must be known.
  • calcOnly : bool [False]
    Use fop.calculate instead of fop.response. Usefull if you want to force the caluclation of impedances for homogeneous models. No noise handling. Solution is put in scheme(‘u’) and a dataMap instance will be returned.
  • noiseLevel : float[0.0]
    add normal distributed noise based on scheme(‘err’) or on noiseLevel if scheme did not contain ‘err’
  • noiseAbs : float[0.0]
    Absolute voltage error in V
  • returnArray : bool [False]
    Return array instead of datacontainer
  • returnFields : bool [False]
    Return matrix of all potential values per injection electrodes.
Returns:
rhoa : DataContainerERT | array(N, data.size()) | array(N, data.size()),
array(N, data.size())

Data container with resulting data and errors with noisify = True. Matrix of rhoa values (case of resistivity matrix noisify = False). In case of a complex valued resistivity model, phase values will be returned in the DataContainerERT (see example below), or as an additional returned array.

Examples

>>> world = pg.meshtools.createWorld(start=[-20, 0], end=[20, -10],
>>>                                  layers=[-1,-3])
>>> mesh = pg.meshtools.createMesh(world, quality=33, area=0.1,
>>>                                smooth=[1,2])
>>> rhoMap = [[1, 1.0], [2, 10.0], [3, 1.0]]
>>> ax, _ = pg.show(mesh, pg.solver.parseArgToArray(rhoMap,
>>>                 mesh.cellCount(), mesh),
>>>                 label='Resistivity ($\Omega$m)')
>>> pg.show(mesh, axes=ax)
>>> scheme = pb.createData(np.linspace(0, 10., 11), schemeName='dd')
>>> rhoa1 = ERTManager.simulate(mesh, res=rhoMap, scheme=scheme)
>>> rhoa2 = ERTManager.simulate(mesh, res=pg.solver.parseArgToArray(
>>>     rhoMap, mesh.cellCount(), mesh), scheme=scheme)
>>> np.testing.assert_array_equal(rhoa1, rhoa2)
>>> pb.show(scheme, vals=rhoa1)
>>> import pybert as pb
>>> import pygimli as pg
>>> import pygimli.meshtools as mt
>>> world = mt.createWorld(start=[-50, 0], end=[50, -50],
...                        layers=[-1, -5], worldMarker=True)
>>> scheme = pb.createData(
... elecs=pg.utils.grange(start=-10, end=10, n=21), schemeName='dd')
>>> for pos in scheme.sensorPositions():
... world.createNode(pos)
... world.createNode(pos + pg.RVector3(0, -0.1))
>>> mesh = mt.createMesh(world, quality=34)
>>> rhomap = [
...    [1, 100. + 0j],
...    [2, 50. + 0j],
...    [3, 10.+ 0j],
... ]
>>> ert = pb.ERTManager()
>>> data = ert.simulate(mesh, res=rhomap, scheme=scheme, verbose=True)
>>> rhoa = data.get('rhoa').array()
>>> phia = data.get('phia').array()
standardizedCoverage(threshhold=0.01)[source]

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

pybert.manager.ertmanager.main(argv)[source]

Main function for direct calling with data file (and options).

pybert.manager.ertmanager.simulate(mesh, res, scheme, verbose=False, **kwargs)[source]

Convenience function of you like it static

pybert.manager.ertmanager.test()[source]

run some test that checks the functionality

pybert.manager.ertmanagerCP module