Time-lapse inversion

In this notebook we will see how to use ResIPy API to do a time-lapse inversion (difference).

    import warnings
warnings.filterwarnings('ignore')
import os
import sys
sys.path.append(os.path.relpath('../src')) # add here the relative path of the API folder
testdir = '../src/examples/dc-2d-timelapse/'
from resipy import Project
API path =  /builds/hkex/resipy/src/resipy
ResIPy version =  3.4.1
cR2.exe found and up to date.
R3t.exe found and up to date.
cR3t.exe found and up to date.
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32"

Then we can import all the dataset. Note that they should all be in the same directory and will be sorted according to alphabetical order.

k = Project(typ='R2')
k.createTimeLapseSurvey(testdir + 'data/')
Working directory is: /builds/hkex/resipy/src/resipy
3/3 imported
k.surveys # to display the list of the surveys object
[<resipy.Survey.Survey at 0x7f62105e9b20>,
 <resipy.Survey.Survey at 0x7f6214668340>,
 <resipy.Survey.Survey at 0x7f61d90a1bb0>]

The inversion is seamlessly the same. It will automatically take the first survey os background model. Invert it in a specific ref directory inside the working directory and then invert the other datasets.

k.invert(parallel=True) # takes a while because it invert all the surveys together
Creating triangular mesh...done (1928 elements)
Writing .in file and protocol.dat... Matching quadrupoles between surveys for difference inversion...344 in common...done in 0.0112s
done
------------ INVERTING REFERENCE SURVEY ---------------
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32"
 >> 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 : 25 - 10 - 2022
 >> 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:   190     Measurements rejected:     0
   Geometric mean of apparent resistivities:  0.51162E+02

 >> Total Memory required is:          0.020 Gb

   Iteration   1
     Initial RMS Misfit:        30.42       Number of data ignored:     0
     Alpha:         406.879   RMS Misfit:        1.61  Roughness:        1.760
     Alpha:         188.857   RMS Misfit:        1.23  Roughness:        2.443
     Alpha:          87.660   RMS Misfit:        0.97  Roughness:        3.209
     Step length set to   1.00000
     Final RMS Misfit:        0.97

 Cannot fit quadratic through step lengths
     Final RMS Misfit:        0.97

 Solution converged - Outputing results to file

 Calculating sensitivity map


 Processing dataset   2


 End of data:  Terminating

--------------------- MAIN INVERSION ------------------
All ok
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32"
0/2 inversions completed

 >> 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 : 25 - 10 - 2022
 >> 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 Start_res.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    <<
 >> T r u e - D a t a   I n v e r s i o n <<
 >> D i f f e r e n c e    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:   344     Measurements rejected:     0
   Geometric mean of apparent resistivities:  0.70496E+02

 >> Total Memory required is:          0.023 Gb

   Iteration   1
     Initial RMS Misfit:        14.53       Number of data ignored:     0
     Alpha:         357.922   RMS Misfit:        4.55  Roughness:       11.151
     Alpha:         166.133   RMS Misfit:        4.45  Roughness:       19.141
     Alpha:          77.112   RMS Misfit:        4.53  Roughness:       30.542
     Step length set to   1.00000
     Final RMS Misfit:        4.45
     Updated data weights

   Iteration   2
     Initial RMS Misfit:         3.30       Number of data ignored:     0
     Alpha:         105.239   RMS Misfit:        1.89  Roughness:       13.687
     Alpha:          48.848   RMS Misfit:        1.34  Roughness:       20.000
     Alpha:          22.673   RMS Misfit:        1.13  Roughness:       27.317
     Alpha:          10.524   RMS Misfit:        1.27  Roughness:       35.661
     Step length set to   1.00000
     Final RMS Misfit:        1.13
     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/2 inversions completed
All ok
it looks like wine32 is missing, you should install it.
multiarch needs to be enabled first.  as root, please
execute "dpkg --add-architecture i386 && apt-get update &&
apt-get install wine32"
 >> 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 : 25 - 10 - 2022
 >> 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 Start_res.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    <<
 >> T r u e - D a t a   I n v e r s i o n <<
 >> D i f f e r e n c e    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:   344     Measurements rejected:     0
   Geometric mean of apparent resistivities:  0.53348E+02

 >> Total Memory required is:          0.023 Gb

   Iteration   1
     Initial RMS Misfit:         2.54       Number of data ignored:     0
     Alpha:         606.516   RMS Misfit:        0.80  Roughness:        0.259
     Step length set to   1.00000
     Final RMS Misfit:        0.80
     Final RMS Misfit:        1.03

 Solution converged - Outputing results to file

 Calculating sensitivity map


 Processing dataset   2


 End of data:  Terminating
2/2 inversions completed
----------- END OF INVERSION IN // ----------
3/3 results parsed (3 ok; 0 failed)
All ok

Note that we can visualize the different inverted sections using R2.showResults(index=0, attr='Resistivity(log10)').

k.showResults(index=0, attr='Resistivity(log10)', contour=False, vmin=1.5, vmax=2)
k.showResults(index=1, attr='Resistivity(log10)', contour=False, vmin=1.5, vmax=2)
k.showResults(index=2, attr='Resistivity(log10)', contour=False, vmin=1.5, vmax=2)
../_images/nb_03time-lapse_0.png ../_images/nb_03time-lapse_1.png ../_images/nb_03time-lapse_2.png

We can also look for the differences between each survey.

# the differnces are in percent in reference to the backround survey (index=0)
k.showResults(index=1, attr='difference(percent)', contour=False, vmin=0, vmax=100)
k.showResults(index=2, attr='difference(percent)', contour=False, vmin=0, vmax=100)
../_images/nb_03time-lapse_3.png ../_images/nb_03time-lapse_4.png

Like this we can observe a deeper positive change (drying) during the growth season of wheat mainly due to the root water uptake.

Download python script: nb_03time-lapse.py

Download Jupyter notebook: nb_03time-lapse.ipynb

View the notebook in the Jupyter nbviewer

Run this example interactively: binder