.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_05_read_csv.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_05_read_csv.py: Reading a sounding from a CSV file ================================== Field data are usually kept in a spreadsheet. Save it as CSV with a header row naming the columns ``ab2``, ``mn2`` and either ``rhoa`` (apparent resistivity, ohm meters) or ``resistance`` (transfer resistance, ohms). .. GENERATED FROM PYTHON SOURCE LINES 11-13 A small file like those exported from a field sheet. Lines starting with ``#`` are comments; extra columns are ignored. .. GENERATED FROM PYTHON SOURCE LINES 13-39 .. code-block:: Python import tempfile from pathlib import Path import ertkit from ertkit import plot, ves text = """# Example sounding (synthetic values) ab2,mn2,rhoa,remarks 1.5,0.3,140.9, 2.2,0.3,121.5, 3.2,0.3,95.1, 4.6,0.3,70.8, 6.8,0.3,54.0, 10,0.3,45.3, 10,2.0,46.9,overlap 15,2.0,46.0, 22,2.0,52.1, 32,2.0,66.0, 46,2.0,86.3, 68,2.0,118.8, 100,2.0,164.4, """ path = Path(tempfile.mkdtemp()) / "sounding.csv" path.write_text(text, encoding="utf-8") .. rst-class:: sphx-glr-script-out .. code-block:: none 245 .. GENERATED FROM PYTHON SOURCE LINES 40-42 Read it with a 3% error model. Files from some instruments are not UTF-8; pass, for example, ``encoding="latin-1"`` for those. .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python data = ves.read_csv(path, error=ertkit.ErrorModel(relative=0.03)) print( f"{data.n_data} readings, AB/2 from {data.survey.ab2.min()} to {data.survey.ab2.max()} m" ) .. rst-class:: sphx-glr-script-out .. code-block:: none 13 readings, AB/2 from 1.5 to 100.0 m .. GENERATED FROM PYTHON SOURCE LINES 49-50 A smooth inversion is a good first look before choosing a number of layers: .. GENERATED FROM PYTHON SOURCE LINES 50-55 .. code-block:: Python smooth = ves.invert_smooth(data) print(f"depth of investigation: {smooth.doi:.1f} m") plot.sounding(data, smooth, labels=["smooth model"]) .. image-sg:: /auto_examples/images/sphx_glr_plot_05_read_csv_001.png :alt: plot 05 read csv :srcset: /auto_examples/images/sphx_glr_plot_05_read_csv_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none depth of investigation: 29.4 m .. GENERATED FROM PYTHON SOURCE LINES 56-57 .. code-block:: Python plot.layered_model(smooth, labels=["smooth model"], log_depth=True) .. image-sg:: /auto_examples/images/sphx_glr_plot_05_read_csv_002.png :alt: plot 05 read csv :srcset: /auto_examples/images/sphx_glr_plot_05_read_csv_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 1.415 seconds) .. _sphx_glr_download_auto_examples_plot_05_read_csv.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_05_read_csv.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_05_read_csv.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_05_read_csv.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_