{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Using an Unstructured Grid\n\nFor many applications, the random fields are needed on an unstructured grid.\nNormally, such a grid would be read in, but we can simply generate one and\nthen create a random field at those coordinates.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport gstools as gs"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Creating our own unstructured grid\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "seed = gs.random.MasterRNG(19970221)\nrng = np.random.RandomState(seed())\nx = rng.randint(0, 100, size=10000)\ny = rng.randint(0, 100, size=10000)\n\nmodel = gs.Exponential(dim=2, var=1, len_scale=[12, 3], angles=np.pi / 8)\nsrf = gs.SRF(model, seed=20170519)\nfield = srf((x, y))\nsrf.vtk_export(\"field\")\n# Or create a PyVista dataset\n# mesh = srf.to_pyvista()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "ax = srf.plot()\nax.set_aspect(\"equal\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Comparing this image to the previous one, you can see that be using the same\nseed, the same field can be computed on different grids.\n\n"
      ]
    }
  ],
  "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.9"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}