.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_01_few_layer_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_auto_examples_plot_01_few_layer_inversion.py: Few-layer inversion with uncertainty ==================================== Simulate a Schlumberger sounding over a three-layer earth, invert it for a three-layer model, and report how well each parameter is determined. .. GENERATED FROM PYTHON SOURCE LINES 10-16 A three-layer earth and a sounding ---------------------------------- Resistive topsoil over a conductive weathered layer, on resistive bedrock. The sounding uses AB/2 from 2.5 m to 200 m, with MN/2 = 0.5 m for the short spacings and 5 m for the long ones, keeping MN at most AB/5 as is usual in the field. .. GENERATED FROM PYTHON SOURCE LINES 16-31 .. code-block:: Python import numpy as np import ertkit from ertkit import plot, ves truth = ves.LayeredModel(resistivity=[150.0, 30.0, 800.0], thickness=[2.0, 15.0]) ab2 = np.geomspace(2.5, 200.0, 22) survey = ves.Survey.schlumberger(ab2=ab2, mn2=np.where(ab2 < 25, 0.5, 5.0)) # Errors of 3% on the transfer resistance, the default, which includes a # modeling-error floor. noise = ertkit.ErrorModel(relative=0.03) data = ves.Sounding.synthetic(truth, survey, noise, rng=5) .. GENERATED FROM PYTHON SOURCE LINES 32-35 Inversion --------- Ten random starting models are tried and the best fit kept. .. GENERATED FROM PYTHON SOURCE LINES 35-41 .. code-block:: Python fit = ves.invert_few_layer(data, n_layers=3, rng=0) print( f"chi2 = {fit.chi2:.1f} for {fit.chi2_target:.0f} degrees of freedom (p = {fit.p_value:.2f})" ) .. rst-class:: sphx-glr-script-out .. code-block:: none chi2 = 16.1 for 17 degrees of freedom (p = 0.52) .. GENERATED FROM PYTHON SOURCE LINES 42-45 Each parameter with its linearized uncertainty, as a multiplicative factor (one standard deviation), next to the true value. "x/ 1.04" means "multiply or divide by 1.04". .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python true_values = np.concatenate([truth.resistivity, truth.thickness]) estimates = np.concatenate([fit.model.resistivity, fit.model.thickness]) for name, est, factor, true in zip( fit.parameter_names, estimates, fit.factor, true_values, strict=True ): print(f"{name:>6}: {est:8.2f} (x/ {factor:.3f}) true {true:8.2f}") .. rst-class:: sphx-glr-script-out .. code-block:: none rho_1: 144.60 (x/ 1.035) true 150.00 rho_2: 30.19 (x/ 1.034) true 30.00 rho_3: 788.16 (x/ 1.115) true 800.00 h_1: 2.04 (x/ 1.038) true 2.00 h_2: 15.22 (x/ 1.050) true 15.00 .. GENERATED FROM PYTHON SOURCE LINES 54-55 The depths to the interfaces, which matter most for siting a borehole: .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python for i, (z, dz) in enumerate(zip(fit.depths, fit.depth_std, strict=True), start=1): print(f"bottom of layer {i}: {z:6.2f} m +/- {dz:.2f} m") .. rst-class:: sphx-glr-script-out .. code-block:: none bottom of layer 1: 2.04 m +/- 0.08 m bottom of layer 2: 17.26 m +/- 0.70 m .. GENERATED FROM PYTHON SOURCE LINES 60-61 The data and the fitted curve, then the model with its uncertainty: .. GENERATED FROM PYTHON SOURCE LINES 61-64 .. code-block:: Python plot.sounding(data, fit, labels=["three-layer fit"]) .. image-sg:: /auto_examples/images/sphx_glr_plot_01_few_layer_inversion_001.png :alt: plot 01 few layer inversion :srcset: /auto_examples/images/sphx_glr_plot_01_few_layer_inversion_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 65-66 .. code-block:: Python plot.layered_model(truth, fit, labels=["true model", "three-layer fit"]) .. image-sg:: /auto_examples/images/sphx_glr_plot_01_few_layer_inversion_002.png :alt: plot 01 few layer inversion :srcset: /auto_examples/images/sphx_glr_plot_01_few_layer_inversion_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.506 seconds) .. _sphx_glr_download_auto_examples_plot_01_few_layer_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_01_few_layer_inversion.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_few_layer_inversion.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_few_layer_inversion.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_