.. 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:: default 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:: default # 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:: default # 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:: default 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:: default Report() .. raw:: html
Wed Sep 06 18:14:11 2023 UTC
OS Linux CPU(s) 2 Machine x86_64
Architecture 64bit RAM 6.8 GiB Environment Python
File system ext4
Python 3.8.17 | packaged by conda-forge | (default, Jun 16 2023, 07:06:00) [GCC 11.4.0]
SimPEG 0.20.0.post2 discretize 0.9.0 pymatsolver 0.2.0
numpy 1.24.4 scipy 1.10.1 sklearn 1.3.0
matplotlib 3.7.2 empymod 2.2.2 geoana 0.5.0
pandas 2.0.3 pydiso 0.0.3 numba 0.57.1
dask 2023.5.0 sympy 1.12 IPython 8.12.2
ipywidgets 8.1.0 plotly 5.16.1 vtk 9.2.6
memory_profiler 0.61.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 2.355 seconds) **Estimated memory usage:** 56 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-python :download:`Download Python source code: plot_read_DC_data_with_IO_class.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_read_DC_data_with_IO_class.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_