.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_03_equivalence.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_03_equivalence.py: When the data cannot decide: a suppressed layer =============================================== A fractured zone between a weathered layer and fresh basement is often the target of a borehole, yet a sounding may barely see it. This example shows how the uncertainty reported by ertkit reveals that, instead of hiding it behind a single best-fitting model. .. GENERATED FROM PYTHON SOURCE LINES 12-16 Four layers, one of them suppressed ----------------------------------- The fractured zone (third layer) has a resistivity between those of the layers above and below it, so its effect on the sounding curve is small. .. 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, 40.0, 400.0, 3000.0], thickness=[2.0, 15.0, 25.0] ) ab2 = np.geomspace(1.0, 500.0, 32) # Three MN segments, each keeping MN at most AB/5. mn2 = np.select([ab2 < 10, ab2 < 100], [0.2, 2.0], default=20.0) survey = ves.Survey.schlumberger(ab2=ab2, mn2=mn2) data = ves.Sounding.synthetic(truth, survey, ertkit.ErrorModel(relative=0.03), rng=3) .. GENERATED FROM PYTHON SOURCE LINES 32-39 Two fits that both match the data --------------------------------- A four-layer fit, started from the true model so that the search settles on the true structure, and a three-layer fit that omits the fractured zone. (With random starting models the four-layer search may settle on a different structure that fits equally well: another face of the same problem.) .. GENERATED FROM PYTHON SOURCE LINES 39-47 .. code-block:: Python four = ves.invert_few_layer(data, n_layers=4, start=truth) three = ves.invert_few_layer(data, n_layers=3, rng=0) for name, fit in (("four layers", four), ("three layers", three)): print( f"{name}: chi2 = {fit.chi2:5.1f} for {fit.chi2_target:.0f} degrees of freedom, p = {fit.p_value:.2f}" ) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/runner/work/ertkit/ertkit/examples/plot_03_equivalence.py:40: DataWarning: poorly determined parameters (uncertainty factor above 10): rho_3, h_3. Other values fit the data equally well (equivalence; see LayerFit.correlation); consider fewer layers. four = ves.invert_few_layer(data, n_layers=4, start=truth) four layers: chi2 = 35.9 for 25 degrees of freedom, p = 0.07 three layers: chi2 = 36.6 for 27 degrees of freedom, p = 0.10 .. GENERATED FROM PYTHON SOURCE LINES 48-52 Both fits are acceptable. Even knowing the true structure, the four-layer fit reports, with a warning, how poorly the data determine the fractured zone: large multiplicative uncertainties on its resistivity (``rho_3``) and thickness (``h_3``), while the layers above remain well determined. .. GENERATED FROM PYTHON SOURCE LINES 52-56 .. code-block:: Python for name, factor in zip(four.parameter_names, four.factor, strict=True): print(f"{name:>6}: known within a factor of {factor:.2f}") .. rst-class:: sphx-glr-script-out .. code-block:: none rho_1: known within a factor of 1.02 rho_2: known within a factor of 1.04 rho_3: known within a factor of 29.45 rho_4: known within a factor of 1.21 h_1: known within a factor of 1.04 h_2: known within a factor of 1.23 h_3: known within a factor of 10.18 .. GENERATED FROM PYTHON SOURCE LINES 57-61 The depth to fresh basement, the usual drilling target, is 42 m in the true model. The four-layer fit reports that the data barely determine it. The three-layer fit gives a precise depth, but to the top of the fractured zone, which it merges with the basement: a precise answer to a different question. .. GENERATED FROM PYTHON SOURCE LINES 61-65 .. code-block:: Python for name, fit in (("four layers", four), ("three layers", three)): print(f"{name}: basement at {fit.depths[-1]:.1f} +- {fit.depth_std[-1]:.1f} m") .. rst-class:: sphx-glr-script-out .. code-block:: none four layers: basement at 42.9 +- 61.8 m three layers: basement at 18.7 +- 0.5 m .. GENERATED FROM PYTHON SOURCE LINES 66-67 The fitted curves are almost indistinguishable: .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python plot.sounding(data, four, three, labels=["four layers", "three layers"]) .. image-sg:: /auto_examples/images/sphx_glr_plot_03_equivalence_001.png :alt: plot 03 equivalence :srcset: /auto_examples/images/sphx_glr_plot_03_equivalence_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 71-75 .. code-block:: Python plot.layered_model( truth, four, three, labels=["true model", "four layers", "three layers"] ) .. image-sg:: /auto_examples/images/sphx_glr_plot_03_equivalence_002.png :alt: plot 03 equivalence :srcset: /auto_examples/images/sphx_glr_plot_03_equivalence_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 76-79 A linearized uncertainty is only a first warning here: for equivalent models it can still understate the range of models that fit. An equivalence analysis that samples that range directly is planned for release 0.2. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.475 seconds) .. _sphx_glr_download_auto_examples_plot_03_equivalence.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_equivalence.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_equivalence.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_equivalence.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_