Note
Click here to download the full example code
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.
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
Download an example DC data csv file¶
# 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]
Out:
Downloading https://storage.googleapis.com/simpeg/examples/dc_data.csv
saved to: /Users/josephcapriotti/codes/simpeg/examples/04-dcip/test_url/dc_data.csv
Download completed!
Convert file to DC.IO object¶
# 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_ambn_locations_to_survey(
a,
b,
m,
n,
survey_type="dipole-dipole",
data_dc=apprho,
data_dc_type="apparent_resistivity",
)
Out:
/Users/josephcapriotti/opt/anaconda3/envs/py36/lib/python3.6/site-packages/SimPEG/electromagnetics/static/resistivity/IODC.py:190: UserWarning: code under construction - API might change in the future
warnings.warn("code under construction - API might change in the future")
Plot¶
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"))
Out:
/Users/josephcapriotti/codes/simpeg/examples/04-dcip/plot_read_DC_data_with_IO_class.py:74: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
plt.show()
Print the version of SimPEG and dependencies¶
Report()
Tue May 26 18:57:14 2020 MDT | |||||
OS | Darwin | CPU(s) | 8 | Machine | x86_64 |
Architecture | 64bit | Environment | Python | ||
Python 3.6.10 |Anaconda, Inc.| (default, May 7 2020, 23:06:31) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] | |||||
SimPEG | 0.14.0b2 | discretize | 0.4.11 | pymatsolver | 0.1.2 |
vectormath | 0.2.2 | properties | 0.6.1 | numpy | 1.18.1 |
scipy | 1.4.1 | cython | 0.29.17 | IPython | 7.13.0 |
matplotlib | 3.1.3 | ipywidgets | 7.5.1 | ||
Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications |
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
…
Total running time of the script: ( 0 minutes 1.241 seconds)