.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_04_static_shift.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_04_static_shift.py: Static shifts between MN segments ================================= When the potential electrodes are moved apart partway through a Schlumberger sounding, the curve often shows a step between the two segments, caused by small near-surface heterogeneities around the electrodes. ertkit can estimate a multiplicative shift for each segment along with the model. .. GENERATED FROM PYTHON SOURCE LINES 12-16 Data with a shifted second segment ---------------------------------- The two segments overlap between AB/2 = 10 m and 14 m, as field crews arrange to check the step between segments. .. GENERATED FROM PYTHON SOURCE LINES 16-38 .. code-block:: Python import numpy as np import ertkit from ertkit import plot, ves truth = ves.LayeredModel(resistivity=[200.0, 30.0, 2000.0], thickness=[1.5, 12.0]) short = np.geomspace(2.5, 14.0, 10) long = np.geomspace(10.0, 300.0, 14) survey = ves.Survey.schlumberger( ab2=np.concatenate([short, long]), mn2=np.concatenate([np.full(short.size, 0.5), np.full(long.size, 2.0)]), ) shift = np.where(survey.mn2 > 1.0, 1.2, 1.0) clean = ves.forward(truth, survey) * shift rng = np.random.default_rng(5) data = ves.Sounding( survey=survey, rhoa=clean * np.exp(0.03 * rng.standard_normal(survey.n_readings)), error=ertkit.ErrorModel(relative=0.03), ) .. GENERATED FROM PYTHON SOURCE LINES 39-43 Without and with a static-shift factor -------------------------------------- Ignoring the shift gives a poorer fit; ertkit warns when the goodness-of-fit p-value falls below 0.01: .. GENERATED FROM PYTHON SOURCE LINES 43-53 .. code-block:: Python import warnings with warnings.catch_warnings(record=True) as caught: warnings.simplefilter("always") plain = ves.invert_few_layer(data, n_layers=3, rng=0) print(f"no shift: p = {plain.p_value:.4f}") for w in caught: print("warning:", w.message) .. rst-class:: sphx-glr-script-out .. code-block:: none no shift: p = 0.0001 warning: poor fit: chi2 = 51.8 for 19 degrees of freedom (p = 7e-05); the errors may be underestimated, or more layers may be needed; if the curve steps where MN changes, estimate static shifts (invert_few_layer(..., static_shift=True)). The uncertainties are then too small: the standard deviations should be about sqrt(chi2/19) = 1.7 times larger. .. GENERATED FROM PYTHON SOURCE LINES 54-56 The shifts are relative to the first segment, whose factor is 1 by definition; ``segment_mn2`` gives the MN/2 of each segment. .. GENERATED FROM PYTHON SOURCE LINES 56-65 .. code-block:: Python shifted = ves.invert_few_layer(data, n_layers=3, static_shift=True, rng=0) print(f"with shift: p = {shifted.p_value:.2f}") print( f"estimated shift of the segment with MN/2 = {shifted.segment_mn2[1]:g} m: " f"{shifted.static_shift[1]:.3f} (x/ {shifted.factor[-1]:.3f}); " f"simulated shift {shift.max():.2f}" ) .. rst-class:: sphx-glr-script-out .. code-block:: none with shift: p = 0.68 estimated shift of the segment with MN/2 = 2 m: 1.166 (x/ 1.025); simulated shift 1.20 .. GENERATED FROM PYTHON SOURCE LINES 66-67 .. code-block:: Python plot.sounding(data, plain, shifted, labels=["no shift", "with static shift"]) .. image-sg:: /auto_examples/images/sphx_glr_plot_04_static_shift_001.png :alt: plot 04 static shift :srcset: /auto_examples/images/sphx_glr_plot_04_static_shift_001.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.888 seconds) .. _sphx_glr_download_auto_examples_plot_04_static_shift.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_04_static_shift.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_04_static_shift.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_04_static_shift.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_