{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Combinations\n\nYou can combine different transformations simply by successively applying them.\n\nHere, we first force the single field realization to hold the given moments,\nnamely mean and variance.\nThen we apply the Zinn & Harvey transformation to connect the low values.\nAfterwards the field is transformed to a binary field and last but not least,\nwe transform it to log-values.\n\nWe can select the desired field by its name and we can define an output name\nto store the field.\n\nIf you don't specify `field` and `store` everything happens inplace.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import gstools as gs\n\n# structured field with a size of 100x100 and a grid-size of 1x1\nx = y = range(100)\nmodel = gs.Gaussian(dim=2, var=1, len_scale=10)\nsrf = gs.SRF(model, mean=-9, seed=20170519)\nsrf.structured([x, y])\nsrf.transform(\"force_moments\", field=\"field\", store=\"f_forced\")\nsrf.transform(\"zinnharvey\", field=\"f_forced\", store=\"f_zinnharvey\", conn=\"low\")\nsrf.transform(\"binary\", field=\"f_zinnharvey\", store=\"f_binary\")\nsrf.transform(\"lognormal\", field=\"f_binary\", store=\"f_result\")\nsrf.plot(field=\"f_result\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The resulting field could be interpreted as a transmissivity field, where\nthe values of low permeability are the ones being the most connected\nand only two kinds of soil exist.\n\nAll stored fields can be accessed and plotted by name:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(\"Max binary value:\", srf.f_binary.max())\nsrf.plot(field=\"f_zinnharvey\")"
      ]
    }
  ],
  "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
}