.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/04_full_dataprocessing/plot_sEIT_import_inversion.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr__examples_04_full_dataprocessing_plot_sEIT_import_inversion.py: Full sEIT data processing example ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Full processing of one timestep of the data from Weigand and Kemna 2017 (Biogeosciences). .. GENERATED FROM PYTHON SOURCE LINES 12-13 imports .. GENERATED FROM PYTHON SOURCE LINES 13-21 .. code-block:: Python import os import subprocess import reda from reda.utils.fix_sign_with_K import fix_sign_with_K import reda.utils.geometric_factors as geom_facs import numpy as np import reda.importers.eit_fzj as eit_fzj .. GENERATED FROM PYTHON SOURCE LINES 22-23 data import .. GENERATED FROM PYTHON SOURCE LINES 23-31 .. code-block:: Python seit = reda.sEIT() seit.import_eit_fzj( 'data/bnk_raps_20130408_1715_03_einzel.mat', 'data/configs.dat' ) print(seit.data[['a', 'b', 'm', 'n']].iloc[0:10]) # In order to keep things fast, we only keep the following frequencies seit.keep_frequencies((1, 10, 100, 1000, 10000)) .. rst-class:: sphx-glr-script-out .. code-block:: none Constructing four-point measurements Summary: a b ... frequency rpha count 67375.000000 67375.000000 ... 67375.000000 67375.000000 mean 17.907532 20.831169 ... 2577.580109 473.723981 std 10.333167 10.677015 ... 8258.716055 2729.735973 min 1.000000 2.000000 ... 0.462963 -3141.592649 25% 10.000000 12.000000 ... 29.411765 -3131.399200 50% 17.000000 22.000000 ... 122.222220 5.510219 75% 27.000000 30.000000 ... 700.000000 3139.297772 max 37.000000 38.000000 ... 45000.000000 3141.592652 [8 rows x 7 columns] a b m n 17 1 2 20 21 47 1 27 30 28 48 1 27 31 29 49 1 27 32 28 50 1 27 32 30 73 2 3 20 21 86 2 3 32 1 93 2 4 5 8 94 2 4 6 9 95 2 4 7 10 .. GENERATED FROM PYTHON SOURCE LINES 32-33 compute geometric factors and correct for signs/phase shifts by pi .. GENERATED FROM PYTHON SOURCE LINES 33-45 .. code-block:: Python settings = { 'rho': 100, 'elem': 'data/elem.dat', 'elec': 'data/elec.dat', 'sink_node': '6467', '2D': True, } k = geom_facs.compute_K_numerical(seit.data, settings) seit.data = geom_facs.apply_K(seit.data, k) # input('nr 2, press enter to continue') fix_sign_with_K(seit.data) .. rst-class:: sphx-glr-script-out .. code-block:: none SETTINGS {'rho': 100, 'elem': 'data/elem.dat', 'elec': 'data/elec.dat', 'sink_node': '6467', '2D': True} 2D modeling .. GENERATED FROM PYTHON SOURCE LINES 46-47 apply correction factors for 2D rhizotron tank .. GENERATED FROM PYTHON SOURCE LINES 47-52 .. code-block:: Python corr_facs_nor = np.loadtxt('data/corr_fac_avg_nor.dat') corr_facs_rec = np.loadtxt('data/corr_fac_avg_rec.dat') corr_facs = np.vstack((corr_facs_nor, corr_facs_rec)) seit.data, cfacs = eit_fzj.apply_correction_factors(seit.data, corr_facs) .. GENERATED FROM PYTHON SOURCE LINES 53-54 apply data filters .. GENERATED FROM PYTHON SOURCE LINES 54-69 .. code-block:: Python seit.filter('r < 0') seit.filter('rho_a < 15 or rho_a > 35') seit.filter('rpha < - 40 or rpha > 3') seit.filter('rphadiff < -5 or rphadiff > 5') seit.filter('k > 400') seit.filter('rho_a < 0') seit.filter('a == 12 or b == 12 or m == 12 or n == 12') seit.filter('a == 13 or b == 13 or m == 13 or n == 13') # import IPython # IPython.embed() seit.print_data_journal() seit.filter_incomplete_spectra(flimit=300, percAccept=85) seit.print_data_journal() seit.print_log() .. rst-class:: sphx-glr-script-out .. code-block:: none --- Data Journal Start --- 2024-11-14 10:34:05.382368 A filter was applied with query "r < 0". In total 75 records were removed A filter was applied with query "rho_a < 15 or rho_a > 35". In total 1963 records were removed A filter was applied with query "rpha < - 40 or rpha > 3". In total 1570 records were removed A filter was applied with query "rphadiff < -5 or rphadiff > 5". In total 2016 records were removed A filter was applied with query "k > 400". In total 557 records were removed A filter was applied with query "rho_a < 0". In total 0 records were removed A filter was applied with query "a == 12 or b == 12 or m == 12 or n == 12". In total 141 records were removed A filter was applied with query "a == 13 or b == 13 or m == 13 or n == 13". In total 130 records were removed --- Data Journal End --- --- Data Journal Start --- 2024-11-14 10:34:05.594825 A filter was applied with query "r < 0". In total 75 records were removed A filter was applied with query "rho_a < 15 or rho_a > 35". In total 1963 records were removed A filter was applied with query "rpha < - 40 or rpha > 3". In total 1570 records were removed A filter was applied with query "rphadiff < -5 or rphadiff > 5". In total 2016 records were removed A filter was applied with query "k > 400". In total 557 records were removed A filter was applied with query "rho_a < 0". In total 0 records were removed A filter was applied with query "a == 12 or b == 12 or m == 12 or n == 12". In total 141 records were removed A filter was applied with query "a == 13 or b == 13 or m == 13 or n == 13". In total 130 records were removed --- Data Journal End --- 2024-11-14 10:34:05,353 - reda.main.logger - INFO - Data sized changed from 9625 to 9550 2024-11-14 10:34:05,357 - reda.main.logger - INFO - Data sized changed from 9550 to 7587 2024-11-14 10:34:05,361 - reda.main.logger - INFO - Data sized changed from 7587 to 6017 2024-11-14 10:34:05,365 - reda.main.logger - INFO - Data sized changed from 6017 to 4001 2024-11-14 10:34:05,369 - reda.main.logger - INFO - Data sized changed from 4001 to 3444 2024-11-14 10:34:05,373 - reda.main.logger - INFO - Data sized changed from 3444 to 3444 2024-11-14 10:34:05,377 - reda.main.logger - INFO - Data sized changed from 3444 to 3303 2024-11-14 10:34:05,382 - reda.main.logger - INFO - Data sized changed from 3303 to 3173 .. GENERATED FROM PYTHON SOURCE LINES 70-85 .. code-block:: Python import crtomo grid = crtomo.crt_grid('data/elem.dat', 'data/elec.dat') seitinv = seit.export_to_crtomo_seit_manager(grid, norrec='nor') seitinv.crtomo_cfg['robust_inv'] = 'F' seitinv.crtomo_cfg['mag_abs'] = 0.012 seitinv.crtomo_cfg['mag_rel'] = 0.5 seitinv.crtomo_cfg['hom_bg'] = 'T' seitinv.crtomo_cfg['d2_5'] = 0 seitinv.crtomo_cfg['fic_sink'] = 'T' seitinv.crtomo_cfg['fic_sink_node'] = 6467 seitinv.apply_crtomo_cfg() .. rst-class:: sphx-glr-script-out .. code-block:: none This grid was sorted using CutMcK. The nodes were resorted! Rectangular grid found 1.0 (295, 28) 8260 10.0 (295, 28) 8260 100.0 (295, 28) 8260 1000.0 (190, 28) 5320 10000.0 (102, 28) 2856 .. GENERATED FROM PYTHON SOURCE LINES 86-89 now run the inversion we do this the "old" style using the command td_run_all_local, which is also included in the crtomo_tools .. GENERATED FROM PYTHON SOURCE LINES 89-99 .. code-block:: Python # only invert if the sipdir does not already exist if not os.path.isdir('sipdir'): # save to a sip-directory seitinv.save_to_eitdir('sipdir') os.chdir('sipdir') subprocess.call('td_run_all_local -t 1 -n 2', shell=True) os.chdir('..') .. GENERATED FROM PYTHON SOURCE LINES 100-105 Now plot the results at this point all plot scripts for sEIT results are located in old, deprecated, packages, and thus we need to write a new plotting tools. In the mean time you can enter each tomodir in the sipdir/invmod subdirectory and plot it using the single-frequency plot command "td_plot" .. GENERATED FROM PYTHON SOURCE LINES 105-107 .. code-block:: Python # TODO .. GENERATED FROM PYTHON SOURCE LINES 108-113 .. code-block:: Python import crtomo import numpy as np sinv = crtomo.eitMan(seitdir='sipdir/') # sinv.extract_points('rpha', np.atleast_2d(np.array((-0.5, 13)))) sinv.extract_points('rpha', np.atleast_2d(np.array((20, -5)))) .. rst-class:: sphx-glr-script-out .. code-block:: none This grid was sorted using CutMcK. The nodes were resorted! Rectangular grid found reading voltages Reading inversion results is robust False Info: res_m.diag not found: sipdir//invmod/00_1.000000//inv/res_m.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing Info: ata.diag not found: sipdir//invmod/00_1.000000//inv/ata.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing reading voltages Reading inversion results is robust False Info: res_m.diag not found: sipdir//invmod/01_10.000000//inv/res_m.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing Info: ata.diag not found: sipdir//invmod/01_10.000000//inv/ata.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing reading voltages Reading inversion results is robust False Info: res_m.diag not found: sipdir//invmod/02_100.000000//inv/res_m.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing Info: ata.diag not found: sipdir//invmod/02_100.000000//inv/ata.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing reading voltages Reading inversion results is robust False Info: res_m.diag not found: sipdir//invmod/03_1000.000000//inv/res_m.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing Info: ata.diag not found: sipdir//invmod/03_1000.000000//inv/ata.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing reading voltages Reading inversion results is robust False Info: res_m.diag not found: sipdir//invmod/04_10000.000000//inv/res_m.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing Info: ata.diag not found: sipdir//invmod/04_10000.000000//inv/ata.diag /home/runner/work/crtomo_tools/crtomo_tools/examples/04_full_dataprocessing .. rst-class:: sphx-glr-timing **Total running time of the script:** (6 minutes 41.525 seconds) .. _sphx_glr_download__examples_04_full_dataprocessing_plot_sEIT_import_inversion.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sEIT_import_inversion.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sEIT_import_inversion.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sEIT_import_inversion.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_