{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib notebook"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nCSEM\n====\n\nReproducing a few published results in the field of Controlled-Source\nElectromagnetics. So far there are only two examples, Ziolkowski et al., 2007,\nFigure 3 and Constable and Weiss, 2006, Figure 3. notebooks.\n\nMore examples could be implemented. In the references are some papers listed\nthat have interesting 1D modelling results.\n\n**References**\n\n- **Constable, S., and C.~J. Weiss,  2006**, Mapping thin resistors and\n  hydrocarbons with marine EM methods: Insights from 1d modeling Geophysics,\n  71, G43-G51; DOI: `10.1190/1.2187748 <http://dx.doi.org/10.1190/1.2187748>`_.\n- **Constable, S.,  2010**, Ten years of marine CSEM for hydrocarbon\n  exploration: Geophysics, 75, 75A67-75A81; DOI: `10.1190/1.3483451\n  <http://dx.doi.org/10.1190/1.3483451>`_.\n- **MacGregor, L., and J. Tomlinson,  2014**, Marine controlled-source\n  electromagnetic methods in the hydrocarbon industry: A tutorial on method and\n  practice: Interpretation, 2, SH13-SH32; DOI: `10.1190/INT-2013-0163.1\n  <http://dx.doi.org/10.1190/INT-2013-0163.1>`_.\n- **Ziolkowski, A., B. Hobbs, and D. Wright,  2007**, Multitransient\n  electromagnetic demonstration survey in france  Geophysics, 72, F197-F209;\n  DOI: `10.1190/1.2735802 <http://dx.doi.org/10.1190/1.2735802>`_.\n- **Ziolkowski, A., and D. Wright,  2012**, The potential of the controlled\n  source electromagnetic method: A powerful tool for hydrocarbon exploration,\n  appraisal, and reservoir characterization Signal Processing Magazine, IEEE,\n  29, 36-52; DOI: `10.1109/MSP.2012.2192529\n  <http://dx.doi.org/10.1109/MSP.2012.2192529>`_.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import empymod\nimport numpy as np\nfrom copy import deepcopy as dc\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "1. Ziolkowski et al. (2007), Figure 3\n-------------------------------------\n\nA land MTEM example.\n\n![](../../_static/figures/Ziolkowski2007.jpg)\n\n\nComputation\n~~~~~~~~~~~\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Time\nt = np.linspace(0.001, 0.06, 101)\n\n# Target model\ninp2 = {'src': [0, 0, 0.001],\n        'rec': [1000, 0, 0.001],\n        'depth': [0, 500, 525],\n        'res': [2e14, 20, 500, 20],\n        'freqtime': t,\n        'verb': 1}\n\n# HS model\ninp1 = dc(inp2)\ninp1['depth'] = inp2['depth'][0]\ninp1['res'] = inp2['res'][:2]\n\n# Compute responses\nsths = empymod.dipole(**inp1, signal=1)  # Step, HS\nsttg = empymod.dipole(**inp2, signal=1)  # \" \"   Target\nimhs = empymod.dipole(**inp1, signal=0, ft='fftlog')  # Impulse, HS\nimtg = empymod.dipole(**inp2, signal=0, ft='fftlog')  # \" \"      Target"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Plot\n~~~~\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plt.figure(figsize=(9, 4))\nplt.subplots_adjust(wspace=.3)\n\n# Step response\nplt.subplot(121)\nplt.title('(a)')\nplt.plot(np.r_[0, 0, t], np.r_[0, sths[0], sths], 'k',\n         label='Uniform half-space')\nplt.plot(np.r_[0, 0, t], np.r_[0, sttg[0], sttg], 'r',\n         label='Hydrocarbon reservoir')\nplt.axis([-.02, 0.06, 0, 8e-9])\nplt.xlabel('Time (s)')\nplt.ylabel('Electric field amplitude (V/m/A-m)')\nplt.legend()\n\n# Impulse response\nplt.subplot(122)\nplt.title('(b)')\n\n# Normalize by max-response\nntg = np.max(np.r_[imtg, imhs])\n\nplt.plot(np.r_[0, 0, t], np.r_[2, 0, imhs/ntg], 'k',\n         label='Uniform half-space')\nplt.plot(np.r_[0, t], np.r_[0, imtg/ntg], 'r', label='Hydrocarbon reservoir')\nplt.axis([-.02, 0.06, 0, 1.02])\nplt.xlabel('Time (s)')\nplt.ylabel(r'Normalized derivative ($\\Omega$/m$^2$/s)')\nplt.legend()\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "2. Constable and Weiss (2006), Figure 3\n---------------------------------------\n\nNote: Exact reproduction is not possible, as source and receiver depths are\nnot explicitly specified in the publication. I made a few checks, and it\nlooks like a source-depth of 900 meter gives good accordance. Receivers are\non the sea-floor.\n\n![](../../_static/figures/Constable2006.jpg)\n\n\nComputation\n~~~~~~~~~~~\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Offsets\nx = np.linspace(0, 20000, 101)\n\n# TG model\ninp3 = {'src': [0, 0, 900],\n        'rec': [x, np.zeros(x.shape), 1000],\n        'depth': [0, 1000, 2000, 2100],\n        'res': [2e14, 0.3, 1, 100, 1],\n        'freqtime': 1,\n        'verb': 1}\n\n# HS model\ninp4 = dc(inp3)\ninp4['depth'] = inp3['depth'][:2]\ninp4['res'] = inp3['res'][:3]\n\n# Compute radial responses\nrhs = empymod.dipole(**inp4)  # Step, HS\nrhs = empymod.utils.EMArray(np.nan_to_num(rhs))\nrtg = empymod.dipole(**inp3)  # \" \"   Target\nrtg = empymod.utils.EMArray(np.nan_to_num(rtg))\n\n# Compute azimuthal response\nahs = empymod.dipole(**inp4, ab=22)  # Step, HS\nahs = empymod.utils.EMArray(np.nan_to_num(ahs))\natg = empymod.dipole(**inp3, ab=22)  # \" \"   Target\natg = empymod.utils.EMArray(np.nan_to_num(atg))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Plot\n~~~~\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plt.figure(figsize=(9, 13))\nplt.subplots_adjust(wspace=.3, hspace=.3)\n\n# Radial amplitude\nplt.subplot(321)\nplt.title('(a) Radial mode fields')\nplt.plot(x/1000, np.log10(rtg.amp()), 'k', label='Model')\nplt.plot(x/1000, np.log10(rhs.amp()), 'k-.', label='Half-space response')\nplt.axis([0, 20, -18, -8])\nplt.xlabel('Range (km)')\nplt.ylabel(r'Log$_{10}$(E-field magnitude, V/Am$^2$)')\nplt.legend()\n\n# Radial phase\nplt.subplot(323)\nplt.title('(b) Radial mode phase')\nplt.plot(x/1000, rtg.pha(deg=True), 'k')\nplt.plot(x/1000, rhs.pha(deg=True), 'k-.')\nplt.axis([0, 20, -500, 0])\nplt.xlabel('Range (km)')\nplt.ylabel('Phase (degrees)')\n\n# Azimuthal amplitude\nplt.subplot(325)\nplt.title('(c) Azimuthal mode fields')\nplt.plot(x/1000, np.log10(atg.amp()), 'k', label='Model')\nplt.plot(x/1000, np.log10(ahs.amp()), 'k-.', label='Half-space response')\nplt.axis([0, 20, -18, -8])\nplt.xlabel('Range (km)')\nplt.ylabel(r'Log$_{10}$(E-field magnitude, V/Am$^2$)')\nplt.legend()\n\n# Azimuthal phase\nplt.subplot(322)\nplt.title('(d) Azimuthal mode phase')\nplt.plot(x/1000, atg.pha(deg=True)+180, 'k')\nplt.plot(x/1000, ahs.pha(deg=True)+180, 'k-.')\nplt.axis([0, 20, -500, 0])\nplt.xlabel('Range (km)')\nplt.ylabel('Phase (degrees)')\n\n# Normalized\nplt.subplot(324)\nplt.title('(e) Normalized E-field magnitude')\nplt.plot(x/1000, np.abs(rtg/rhs), 'k', label='Radial')\nplt.plot(x/1000, np.abs(atg/ahs), 'k--', label='Azimuthal')\nplt.axis([0, 20, 0, 70])\nplt.xlabel('Range (km)')\nplt.legend()\n\nplt.show()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "empymod.Report()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}