{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Truncated Power Law Variograms\n\nGSTools also implements truncated power law variograms,\nwhich can be represented as a superposition of scale dependant modes\nin form of standard variograms, which are truncated by\na lower- $\\ell_{\\mathrm{low}}$ and\nan upper length-scale $\\ell_{\\mathrm{up}}$.\n\nThis example shows the truncated power law (:any:`TPLStable`) based on the\n:any:`Stable` covariance model and is given by\n\n\\begin{align}\\gamma_{\\ell_{\\mathrm{low}},\\ell_{\\mathrm{up}}}(r) =\n   \\intop_{\\ell_{\\mathrm{low}}}^{\\ell_{\\mathrm{up}}}\n   \\gamma(r,\\lambda) \\frac{\\rm d \\lambda}{\\lambda}\\end{align}\n\nwith `Stable` modes on each scale:\n\n\\begin{align}\\gamma(r,\\lambda) &=\n   \\sigma^2(\\lambda)\\cdot\\left(1-\n   \\exp\\left[- \\left(\\frac{r}{\\lambda}\\right)^{\\alpha}\\right]\n   \\right)\\\\\n   \\sigma^2(\\lambda) &= C\\cdot\\lambda^{2H}\\end{align}\n\nwhich gives Gaussian modes for ``alpha=2``\nor Exponential modes for ``alpha=1``.\n\nFor $\\ell_{\\mathrm{low}}=0$ this results in:\n\n\\begin{align}\\gamma_{\\ell_{\\mathrm{up}}}(r) &=\n   \\sigma^2_{\\ell_{\\mathrm{up}}}\\cdot\\left(1-\n   \\frac{2H}{\\alpha} \\cdot\n   E_{1+\\frac{2H}{\\alpha}}\n   \\left[\\left(\\frac{r}{\\ell_{\\mathrm{up}}}\\right)^{\\alpha}\\right]\n   \\right) \\\\\n   \\sigma^2_{\\ell_{\\mathrm{up}}} &=\n   C\\cdot\\frac{\\ell_{\\mathrm{up}}^{2H}}{2H}\\end{align}\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n\nimport gstools as gs\n\nx = y = np.linspace(0, 100, 100)\nmodel = gs.TPLStable(\n    dim=2,  # spatial dimension\n    var=1,  # variance (C is calculated internally, so variance is actually 1)\n    len_low=0,  # lower truncation of the power law\n    len_scale=10,  # length scale (a.k.a. range), len_up = len_low + len_scale\n    nugget=0.1,  # nugget\n    anis=0.5,  # anisotropy between main direction and transversal ones\n    angles=np.pi / 4,  # rotation angles\n    alpha=1.5,  # shape parameter from the stable model\n    hurst=0.7,  # hurst coefficient from the power law\n)\nsrf = gs.SRF(model, mean=1.0, seed=19970221)\nsrf.structured([x, y])\nsrf.plot()"
      ]
    }
  ],
  "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
}