.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "content/examples/04-dcip/plot_read_DC_data_with_IO_class.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_content_examples_04-dcip_plot_read_DC_data_with_IO_class.py: Reading and Plotting data with DC.IO class ========================================== The DC.IO class is a convenient way to handle DC data and carry inversions within a same class. It also has several plotting utils such as pseudosections. We show here an example of plotting DC data based on a demonstration dataset. .. GENERATED FROM PYTHON SOURCE LINES 10-20 .. code-block:: Python import numpy as np import pandas as pd import shutil import os import matplotlib.pyplot as plt from simpeg.electromagnetics.static import resistivity as DC from simpeg import Report from simpeg.utils.io_utils import download .. GENERATED FROM PYTHON SOURCE LINES 21-24 Download an example DC data csv file ------------------------------------ .. GENERATED FROM PYTHON SOURCE LINES 24-36 .. code-block:: Python # file origina and name url = "https://storage.googleapis.com/simpeg/examples/dc_data.csv" fname = download(url, folder="./test_url", overwrite=True) # read csv using pandas df = pd.read_csv(fname) # header for ABMN locations header_loc = ["Spa." + str(i + 1) for i in range(4)] # Apparent resistivity header_apprho = df.keys()[6] .. rst-class:: sphx-glr-script-out .. code-block:: none Downloading https://storage.googleapis.com/simpeg/examples/dc_data.csv saved to: /home/vsts/work/1/s/examples/04-dcip/test_url/dc_data.csv Download completed! .. GENERATED FROM PYTHON SOURCE LINES 37-40 Convert file to DC.IO object ---------------------------- .. GENERATED FROM PYTHON SOURCE LINES 41-65 .. code-block:: Python # Number of the data ndata = df[header_loc[0]].values.size # ABMN locations a = np.c_[df[header_loc[0]].values, np.zeros(ndata)] b = np.c_[df[header_loc[1]].values, np.zeros(ndata)] m = np.c_[df[header_loc[2]].values, np.zeros(ndata)] n = np.c_[df[header_loc[3]].values, np.zeros(ndata)] # Apparent resistivity apprho = df[header_apprho].values # Create DC.IO survey Object object IO = DC.IO() # Generate DC survey using IO object dc_survey = IO.from_abmn_locations_to_survey( a, b, m, n, survey_type="dipole-dipole", data_dc=apprho, data_dc_type="apparent_resistivity", ) .. rst-class:: sphx-glr-script-out .. code-block:: none /home/vsts/work/1/s/examples/04-dcip/plot_read_DC_data_with_IO_class.py:53: UserWarning: code under construction - API might change in the future .. GENERATED FROM PYTHON SOURCE LINES 66-69 Plot ---- .. GENERATED FROM PYTHON SOURCE LINES 70-79 .. code-block:: Python fig, ax = plt.subplots(1, 1, figsize=(10, 3)) IO.plotPseudoSection( data_type="apparent_resistivity", scale="linear", clim=(0, 1000), ncontour=3, ax=ax ) plt.show() # clean up shutil.rmtree(os.path.expanduser("./test_url")) .. image-sg:: /content/examples/04-dcip/images/sphx_glr_plot_read_DC_data_with_IO_class_001.png :alt: plot read DC data with IO class :srcset: /content/examples/04-dcip/images/sphx_glr_plot_read_DC_data_with_IO_class_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 80-83 Print the version of SimPEG and dependencies -------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 83-86 .. code-block:: Python Report() .. raw:: html
Thu Sep 19 08:46:54 2024 UTC
OS Linux (Ubuntu 22.04) CPU(s) 2 Machine x86_64
Architecture 64bit RAM 6.8 GiB Environment Python
File system ext4
Python 3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]
simpeg 0.22.2.dev13+g048ef809f discretize 0.10.0 pymatsolver 0.2.0
numpy 1.26.4 scipy 1.14.1 matplotlib 3.9.2
empymod 2.3.1 geoana 0.6.0 pydiso 0.0.5
numba 0.60.0 dask 2024.9.0 sklearn 1.5.2
pandas 2.2.2 sympy 1.13.2 plotly 5.24.1
memory_profiler 0.61.0 choclo 0.2.0


.. GENERATED FROM PYTHON SOURCE LINES 87-97 Moving Forward -------------- If you have suggestions for improving this example, please create a `pull request on the example in SimPEG `_ You might try: - changing the contour levels - try with you own dataset - create a mask for negative apparent resistivities - ... .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.867 seconds) **Estimated memory usage:** 234 MB .. _sphx_glr_download_content_examples_04-dcip_plot_read_DC_data_with_IO_class.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_read_DC_data_with_IO_class.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_read_DC_data_with_IO_class.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_read_DC_data_with_IO_class.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_