In this tutorial, we will see how to use ResIPy API to do forward and inverse modelling of synthetic problems.
from resipy import R2
k = R2(typ='R2')
import numpy as np # numpy for electrode generation
First we need to design some surface electrodes using numpy
elec = np.zeros((25,3))
elec[:,0] = np.arange(0, 25*5.0, 5.0) # with 25 electrodes at 5 m spacing
k.setElec(elec)
print(k.elec)
Now we need to assign objects we wish to add and then create a mesh
geom_input = {'polygon1':[[30,45,45,30], [-5, -5, -30, -30]],
'polygon2':[[75,90,90,75],[-5,-5,-30,-30]]}
k.createMesh(typ='trian', res0=200, geom_input=geom_input) # let's create the mesh based on these electrodes position
k.showMesh(xlim=[0,120], zlim=[-40,0])
Based on this mesh, we can define resistities for the regions
k.setStartingRes(regionValues={1:50, 2:500, 3:200}) # this assign a resistivity value (ohm.m) for each region defined.
k.showMesh(attr='res0')
We then need to define the sequence that we will use. We can easily create a dipole-dipole sequence using R2.createSequence()
or import one using R2.importSequence()
.
k.createSequence([('dpdp1', 1, 10)]) # create a dipole-dipole of diple spacing of 1 (=skip 0) with 10 levels
print(k.sequence) # the sequence is stored inside the R2 object
Then comes the forward modelling part itself. The forward modelling will run R2, cR2, ... in forward mode inside a fwd
directory inside the working directory. The resulting apparent resistivity are then embeded inside a Survey
object and directly available for inversion for instance.
k.forward(noise=0.05, iplot=True) # forward modelling with 5 % noise added to the output
k.param['b_wgt'] = 0.05 # we are now informing R2 that the relative error is 0.05 for inversion
k.param['a_wgt'] = 0.0 # the offset error is zero, to be consistent with the error added to the forward model
We can already see that the pseudo-section already show clearly the import on the region we defined. We can now invert these apparent resistivities. Inverting the forward models allow the user to see if the parameters of the surveys (the sequence and electrode spacing) were optimium to resolve the target. If needed the user can change them and do the whole process again.
k.invert()
k.showResults(index=0, color_map='jet') # show the initial model
k.showResults(index=1, sens=False, color_map='jet') # show the inverted model