In [1]:
import sys
from resipy import R2
import pyvista as pv  # needed for 3D plotting 
C:\Program Files (x86)\WPy64-3770\python-3.7.7.amd64\lib\site-packages\pyvista\core\pyvista_ndarray.py:2: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
  from collections import Iterable
API path =  C:\Program Files (x86)\WPy64-3770\python-3.7.7.amd64\lib\site-packages\resipy
ResIPy version =  2.2.2
cR2.exe found and up to date.
R3t.exe found and up to date.
cR3t.exe found and up to date.
In [2]:
k = R2(typ='R3t')
Working directory is: C:\Program Files (x86)\WPy64-3770\python-3.7.7.amd64\lib\site-packages\resipy
clearing dirname
In [3]:
k.createSurvey(r'C:\ResIPy\Notebook examples\3D inversion\protocol.dat', ftype='ProtocolDC')
5360/5480 reciprocal measurements found.
0 measurements error > 20 %
In [4]:
k.importElec(r'C:\ResIPy\Notebook examples\3D inversion\electrodes.csv')
In [5]:
k.fitErrorPwl() # fit a power law to the error
Error model is R_err = 0.005 R_avg^1.071 (R^2 = 0.996)
In [6]:
k.createMesh()
Creating tetrahedral mesh...fmd in gmshWrap.py: 4.805206
writing .geo to file completed, save location:
C:\Program Files (x86)\WPy64-3770\python-3.7.7.amd64\lib\site-packages\resipy\invdir

Reading mesh3d.msh
Gmsh version == 3.x
reading node coordinates...
Determining element type...Tetrahedra
Reading connection matrix...
ignoring 27586 elements in the mesh file, as they are not required for R2/R3t
Finished reading .msh file
interpolating topography onto mesh using triangulate interpolation...done
ResIPy Estimated RAM usage = 4.359734 Gb
done
In [7]:
k.err = True # setting this flag is necessary for adopting the fitted error model, otherwise a default error is set
k.invert()
Writing .in file and protocol.dat... done!
--------------------- MAIN INVERSION ------------------


 >> R 3 t     E R T    M o d e l    v2.01 <<

 >> Date: 18-08-2020
 >> My beautiful 3D survey                                                          
 >> I n v e r s e   S o l u t i o n   S e l e c t e d <<
 >> T e t r a h e d r a l   E l e m e n t   M e s h <<

 >> Reading mesh file 
 >> Determining storage needed for finite element conductance matrix
 >> Generating index array for finite element conductance matrix
 >> Reading resistivity model from res0.dat                                                                        

 >> 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 <<

 >> Memory estimates:
    For   1000 measurements the memory needed is:          1.646 Gb
    For   2000 measurements the memory needed is:          3.203 Gb
    For   5000 measurements the memory needed is:          7.874 Gb
    For  10000 measurements the memory needed is:         15.660 Gb

 >> Forming roughness matrix

 >> Number of measurements read: 2800

 >> Total Memory required is:          4.448 Gb


 Processing frame   1 - output to file f001.dat

   Iteration   1
     Initial RMS Misfit:       120.09      Number of data ignored:     0
     Alpha:        6901.147   RMS Misfit:        8.34  Roughness:       37.409
     Alpha:        3203.229   RMS Misfit:        8.06  Roughness:       39.418
     Alpha:        1486.807   RMS Misfit:        6.02  Roughness:       62.056
     Alpha:         690.115   RMS Misfit:        5.29  Roughness:       81.625
     Alpha:         320.323   RMS Misfit:        5.16  Roughness:      107.012
     Alpha:         148.681   RMS Misfit:        5.54  Roughness:      134.735
     Step length set to      1.000
     Final RMS Misfit:        5.16
     Updated data weights

   Iteration   2
     Initial RMS Misfit:         4.02      Number of data ignored:     0
     Alpha:         186.868   RMS Misfit:        1.75  Roughness:      122.271
     Alpha:          86.736   RMS Misfit:        1.40  Roughness:      146.267
     Alpha:          40.259   RMS Misfit:        1.27  Roughness:      169.693
     Alpha:          18.687   RMS Misfit:        1.27  Roughness:      200.711
     Step length set to      1.000
     Final RMS Misfit:        1.27
     Attempted to update data weights and caused overshoot
     treating as converged

 Solution converged - Outputing results to file

 Calculating sensitivity map

 End of data:  Terminating


 >> Program ended normally

1/1 results parsed (1 ok; 0 failed)
In [8]:
pl = pv.Plotter()
k.showResults(ax=pl, color_map='jet', contour=True, pvgrid=True, vmin=1.6, vmax=2.2)
In [9]:
pl = pv.Plotter()
k.showResults(ax=pl, color_map='jet', pvslices=([0.5,1.5,2.5],[],[-2]), contour=True, pvgrid=True, vmin=1.6, vmax=2.2)
In [10]:
k.meshResults[0].df.columns # find out attributes available
Out[10]:
Index(['param', 'elm_id', 'region', 'cellType', 'X', 'Y', 'Z', 'Resistivity',
       'Resistivity(log10)', 'Sensitivity_map(log10)', 'Parameter_zones',
       'Conductivity(mS/m)'],
      dtype='object')
In [11]:
pl = pv.Plotter()
k.showResults(ax=pl, attr='Sensitivity_map(log10)', color_map='jet', contour=True)  # plot sensitivity map