{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib notebook"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Hunziker et al., 2015, Geophysics\n\nReproducing Figure 3 of the manual from `EMmod`. This example does, as such,\nnot actually reproduce a figure of Hunziker et al., 2015, but of the manual\nthat comes with the software accompanying the paper. With the software comes an\nexample input file named `simplemod.scr`, and the corresponding result is shown\nin the manual of the code in Figure 3.\n\nIf you are interested in reproducing the figures of the actual paper have a\nlook at the notebooks in the repo [article-geo2017](https://github.com/emsig/article-geo2017).\n\n**Reference**\n\n- **Hunziker, J., J. Thorbecke, and E. Slob, 2015**, The electromagnetic\n  response in a layered vertical transverse isotropic medium: A new look at an\n  old problem: Geophysics, 80(1), F1\u2013F18; DOI: [10.1190/geo2013-0411.1](https://doi.org/10.1190/geo2013-0411.1); Software:\n  [software.seg.org/2015/0001](https://software.seg.org/2015/0001).\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import empymod\nimport numpy as np\nimport matplotlib.pyplot as plt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Compute the data\n\nCompute the electric field with the parameters defined in `simplemod.scr`.\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# x- and y-offsets\nx = np.arange(4000)*7-1999.5*7\ny = np.arange(1500)*10-749.5*10\n\n# Create 2D arrays of them\nrx = np.repeat([x, ], np.size(y), axis=0)\nry = np.repeat([y, ], np.size(x), axis=0)\nry = ry.transpose()\n\n# Compute the electric field\nefield = empymod.dipole(\n    src=[0, 0, 150],\n    rec=[rx.ravel(), ry.ravel(), 200],\n    depth=[0, 200, 1000, 1200],\n    res=[2e14, 1/3, 1, 50, 1],\n    aniso=[1, 1, np.sqrt(10), 1, 1],\n    freqtime=0.5,\n    epermH=[1, 80, 17, 2.1, 17],\n    epermV=[1, 80, 17, 2.1, 17],\n    mpermH=[1, 1, 1, 1, 1],\n    mpermV=[1, 1, 1, 1, 1],\n    ab=11,\n    htarg={'pts_per_dec': -1},\n).reshape(np.shape(rx))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Plot\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "# Create a similar colormap as Hunziker et al., 2015.\ncmap = plt.cm.get_cmap(\"jet\", 61)\n\nplt.figure(figsize=(9, 8))\n\n# 1. Amplitude\nplt.subplot(211)\nplt.title('Amplitude (V/m)')\nplt.xlabel('Offset (km)')\nplt.ylabel('Offset (km)')\nplt.pcolormesh(x/1e3, y/1e3, np.log10(efield.amp()),\n               cmap=cmap, vmin=-16, vmax=-7, shading='nearest')\nplt.colorbar()\n\n# 2. Phase\nplt.subplot(212)\nplt.title('Phase (\u00b0)')\nplt.xlabel('Offset (km)')\nplt.ylabel('Offset (km)')\nplt.pcolormesh(x/1e3, y/1e3, efield.pha(deg=False, unwrap=False, lag=True),\n               cmap=cmap, vmin=-np.pi, vmax=np.pi, shading='nearest')\nplt.colorbar()\n\nplt.tight_layout()\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Original Figure\n\nFigure 3 of the manual of `EMmod`.\n\n<img src=\"file://../../_static/figures/Hunziker2015.png\">\n\n"
      ]
    },
    {
      "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.8.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}