In this example we are going to invert one of the example given in the R2 manual. The aim is to detect a hidden block in the bottom left of the picture as shown below: and this pictures:
%matplotlib inline
import warnings
warnings.filterwarnings('ignore')
import os
import sys
import numpy as np # just for parsing the electrode position file
sys.path.append((os.path.relpath('../src'))) # add here the relative path of the API folder
testdir = '../src/examples/dc-2d-borehole/'
from resipy import Project
API path = /media/jkl/data/phd/tmp/resipy/src/resipy ResIPy version = 3.2.0 cR2.exe found and up to date. R3t.exe found and up to date. cR3t.exe found and up to date.
Then we will import the protocol.dat
file that was outputed by the forward model with this geometry and invert it. Note what we also need to import the electrodes position from a .csv file with 3 columns:x, y, buried. The buried
column contains 1 if the electrode is buried and 0 if not.
k = Project(typ='R2')
k.createSurvey(testdir + 'protocol.dat', ftype='ProtocolDC')
k.importElec(testdir + 'elec.csv')
k.createMesh('trian', cl=0.5, cl_factor=20, fmd=20)
# cl is characteristic length, it defines the resolution of the mesh around the electrodes, the smaller, the finer
# cl_factor is how the mesh will grow away from the electrode
# NOTE that a too fine mesh (very small cl) will takes a lot of RAM
# but a too coarse mesh won't be able to resolve the target
k.zlim = [-20, 0]
k.showMesh()
k.invert()
k.showResults(sens=False, contour=True)
`should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.
Working directory is: /media/jkl/data/phd/tmp/resipy/src/resipy clearing dirname 0/407 reciprocal measurements found. Creating triangular mesh...Reading mesh.msh Gmsh version == 3.x reading node coordinates... Determining element type...Triangle Reading connection matrix... ignoring 0 elements in the mesh file, as they are not required for R2/R3t Finished reading .msh file Done ResIPy Estimated RAM usage = 0.010318 Gb done Writing .in file and protocol.dat... done! --------------------- MAIN INVERSION ------------------ >> R 2 R e s i s t i v i t y I n v e r s i o n v4.02 << >> D a t e : 20 - 01 - 2021 >> My beautiful survey >> I n v e r s e S o l u t i o n S e l e c t e d << >> Determining storage needed for finite element conductance matrix >> Generating index array for finite element conductance matrix >> Reading start resistivity from res0.dat >> R e g u l a r i s e d T y p e << >> L i n e a r F i l t e r << >> L o g - D a t a I n v e r s i o n << >> N o r m a l R e g u l a r i s a t i o n << >> D a t a w e i g h t s w i l l b e m o d i f i e d << Processing dataset 1 Measurements read: 407 Measurements rejected: 0 Geometric mean of apparent resistivities: 0.92723E+02 >> Total Memory required is: 0.046 Gb Iteration 1 Initial RMS Misfit: 5.98 Number of data ignored: 1 Alpha: 2110.974 RMS Misfit: 2.35 Roughness: 0.441 Alpha: 979.827 RMS Misfit: 2.05 Roughness: 0.793 Alpha: 454.796 RMS Misfit: 1.74 Roughness: 1.468 Alpha: 211.097 RMS Misfit: 1.47 Roughness: 2.510 Alpha: 97.983 RMS Misfit: 1.28 Roughness: 3.821 Alpha: 45.480 RMS Misfit: 1.15 Roughness: 5.345 Alpha: 21.110 RMS Misfit: 1.06 Roughness: 7.246 Alpha: 9.798 RMS Misfit: 1.02 Roughness: 9.988 Alpha: 4.548 RMS Misfit: 1.07 Roughness: 14.655 Step length set to 1.00000 Final RMS Misfit: 1.02 Attempted to update data weights and caused overshoot treating as converged Solution converged - Outputing results to file Calculating sensitivity map Processing dataset 2 End of data: Terminating 1/1 results parsed (1 ok; 0 failed)