.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "content/tutorials/08-tdem/plot_fwd_1_em1dtm.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_tutorials_08-tdem_plot_fwd_1_em1dtm.py: 1D Forward Simulation for a Single Sounding =========================================== Here we use the module *simpeg.electromangetics.time_domain_1d* to predict the stepoff response for a single sounding over a 1D layered Earth. In this tutorial, we focus on the following: - Defining receivers, waveforms, sources and the survey - The units of the model and resulting data - Defining and running the 1D simulation for a single sounding Our survey geometry consists of a horizontal loop source with a radius of 6 m located 20 m above the Earth's surface. The receiver is located at the centre of the loop and measures the vertical component of the response. .. GENERATED FROM PYTHON SOURCE LINES 21-24 Import Modules -------------- .. GENERATED FROM PYTHON SOURCE LINES 24-38 .. code-block:: Python import numpy as np import os from matplotlib import pyplot as plt from simpeg import maps import simpeg.electromagnetics.time_domain as tdem from simpeg.utils import plot_1d_layer_model write_output = False plt.rcParams.update({"font.size": 16}) # sphinx_gallery_thumbnail_number = 2 .. GENERATED FROM PYTHON SOURCE LINES 39-47 Create Survey ------------- Here we demonstrate a general way to define the receivers, sources, waveforms and survey. For this tutorial, the source is a horizontal loop whose current waveform is a unit step-off. The receiver measures the vertical component of the magnetic flux density at the loop's center. .. GENERATED FROM PYTHON SOURCE LINES 47-88 .. code-block:: Python # Source properties source_location = np.array([0.0, 0.0, 20.0]) source_orientation = "z" # "x", "y" or "z" source_current = 1.0 # maximum on-time current source_radius = 6.0 # source loop radius # Receiver properties receiver_location = np.array([0.0, 0.0, 20.0]) receiver_orientation = "z" # "x", "y" or "z" times = np.logspace(-5, -2, 31) # time channels (s) # Define receiver list. In our case, we have only a single receiver for each source. # When simulating the response for multiple component and/or field orientations, # the list consists of multiple receiver objects. receiver_list = [] receiver_list.append( tdem.receivers.PointMagneticFluxDensity( receiver_location, times, orientation=receiver_orientation ) ) # Define the source waveform. Here we define a unit step-off. The definition of # other waveform types is covered in a separate tutorial. waveform = tdem.sources.StepOffWaveform() # Define source list. In our case, we have only a single source. source_list = [ tdem.sources.CircularLoop( receiver_list=receiver_list, location=source_location, waveform=waveform, current=source_current, radius=source_radius, ) ] # Define the survey survey = tdem.Survey(source_list) .. GENERATED FROM PYTHON SOURCE LINES 89-101 Defining a 1D Layered Earth Model --------------------------------- Here, we define the layer thicknesses and electrical conductivities for our 1D simulation. If we have N layers, we define N electrical conductivity values and N-1 layer thicknesses. The lowest layer is assumed to extend to infinity. If the Earth is a halfspace, the thicknesses can be defined by an empty array, and the physical property values by an array of length 1. In this case, we have a more conductive layer within a background halfspace. This can be defined as a 3 layered Earth model. .. GENERATED FROM PYTHON SOURCE LINES 101-126 .. code-block:: Python # Physical properties background_conductivity = 1e-1 layer_conductivity = 1e0 # Layer thicknesses thicknesses = np.array([40.0, 40.0]) n_layer = len(thicknesses) + 1 # physical property models model = background_conductivity * np.ones(n_layer) model[1] = layer_conductivity # Define a mapping for conductivities model_mapping = maps.IdentityMap(nP=n_layer) # Plot conductivity model thicknesses_for_plotting = np.r_[thicknesses, 40.0] fig = plt.figure(figsize=(6, 5)) ax = fig.add_axes([0.15, 0.15, 0.8, 0.8]) plot_1d_layer_model(thicknesses_for_plotting, model, ax=ax, show_layers=False) plt.gca().invert_yaxis() .. image-sg:: /content/tutorials/08-tdem/images/sphx_glr_plot_fwd_1_em1dtm_001.png :alt: plot fwd 1 em1dtm :srcset: /content/tutorials/08-tdem/images/sphx_glr_plot_fwd_1_em1dtm_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 127-137 Define the Forward Simulation, Predict Data and Plot ---------------------------------------------------- Here we define the simulation and predict the 1D TDEM sounding data. The simulation requires the user define the survey, the layer thicknesses and a mapping from the model to the conductivities of the layers. When using the *simpeg.electromagnetics.time_domain_1d* module, predicted data are organized by source, then by receiver, then by time channel. .. GENERATED FROM PYTHON SOURCE LINES 137-157 .. code-block:: Python # Define the simulation simulation = tdem.Simulation1DLayered( survey=survey, thicknesses=thicknesses, sigmaMap=model_mapping, ) # Predict data for a given model dpred = simulation.dpred(model) # Plot sounding fig = plt.figure(figsize=(6, 6)) ax = fig.add_axes([0.2, 0.15, 0.75, 0.78]) ax.loglog(times, dpred, "k-o", lw=2) ax.set_xlabel("Times (s)") ax.set_ylabel("|B| (T)") ax.set_title("Magnetic Flux") .. image-sg:: /content/tutorials/08-tdem/images/sphx_glr_plot_fwd_1_em1dtm_002.png :alt: Magnetic Flux :srcset: /content/tutorials/08-tdem/images/sphx_glr_plot_fwd_1_em1dtm_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Text(0.5, 1.0, 'Magnetic Flux') .. GENERATED FROM PYTHON SOURCE LINES 158-161 Write Output (Optional) ----------------------- .. GENERATED FROM PYTHON SOURCE LINES 161-175 .. code-block:: Python if write_output: dir_path = os.path.dirname(__file__).split(os.path.sep) dir_path.extend(["outputs"]) dir_path = os.path.sep.join(dir_path) + os.path.sep if not os.path.exists(dir_path): os.mkdir(dir_path) np.random.seed(347) noise = 0.05 * np.abs(dpred) * np.random.randn(len(dpred)) dpred += noise fname = dir_path + "em1dtm_data.txt" np.savetxt(fname, np.c_[times, dpred], fmt="%.4e", header="TIME BZ") .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.602 seconds) **Estimated memory usage:** 288 MB .. _sphx_glr_download_content_tutorials_08-tdem_plot_fwd_1_em1dtm.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_fwd_1_em1dtm.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_fwd_1_em1dtm.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_fwd_1_em1dtm.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_