|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# ######### COPYRIGHT ######### |
| 4 | +# Credits |
| 5 | +# ####### |
| 6 | +# |
| 7 | +# Copyright(c) 2021-2021 |
| 8 | +# ---------------------- |
| 9 | +# |
| 10 | +# * Institut de Mathématiques de Marseille <https://www.i2m.univ-amu.fr/> |
| 11 | +# * Université d'Aix-Marseille <http://www.univ-amu.fr/> |
| 12 | +# * Centre National de la Recherche Scientifique <http://www.cnrs.fr/> |
| 13 | +# |
| 14 | +# Contributors |
| 15 | +# ------------ |
| 16 | +# |
| 17 | +# * `Frédéric Richard <mailto:frederic.richard@univ-amu.fr>`_ |
| 18 | +# |
| 19 | +# |
| 20 | +# * This module is part of the package PyAFBF. |
| 21 | +# |
| 22 | +# Licence |
| 23 | +# ------- |
| 24 | +# |
| 25 | +# This program is free software: you can redistribute it and/or modify |
| 26 | +# it under the terms of the GNU General Public License as published by |
| 27 | +# the Free Software Foundation, either version 3 of the License, or |
| 28 | +# (at your option) any later version. |
| 29 | +# |
| 30 | +# This program is distributed in the hope that it will be useful, |
| 31 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 32 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 33 | +# GNU General Public License for more details. |
| 34 | +# |
| 35 | +# You should have received a copy of the GNU General Public License |
| 36 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 37 | +# |
| 38 | +# ######### COPYRIGHT ######### |
| 39 | +r""" |
| 40 | +==================================== |
| 41 | +Elementary Fractional Brownian field |
| 42 | +==================================== |
| 43 | +
|
| 44 | +.. codeauthor:: Frédéric Richard <frederic.richard_at_univ-amu.fr> |
| 45 | +
|
| 46 | +This example shows how to simulate an elementary fractional Brownian field |
| 47 | +with prescribed Hurst index, step intervals and directions. |
| 48 | +""" |
| 49 | +import numpy as np |
| 50 | +from afbf import tbfield |
| 51 | + |
| 52 | +N = 256 # Image size. |
| 53 | +H = 0.2 # Hurst index in (0, 1). |
| 54 | +T = np.pi / 8 # Interval bound for selected frequencies. |
| 55 | +D = np.pi / 3 # Direction. |
| 56 | + |
| 57 | +# Define the field. |
| 58 | +Z = tbfield('efbf') |
| 59 | + |
| 60 | +# Change the parameter of the Hurst and topothesy functions. |
| 61 | +Z.hurst.ChangeParameters(fparam=np.array([[H]])) |
| 62 | +Z.topo.ChangeParameters(fparam=np.array([0, 1]), finter=np.array([-T, T])) |
| 63 | +# Translate the topothesy function to be at the right orientation. |
| 64 | +Z.topo.ApplyTransforms(translate=-D) |
| 65 | + |
| 66 | +# Simulate the field. |
| 67 | +z = Z.Simulate() |
| 68 | + |
| 69 | +# Display the simulation. |
| 70 | +z.Display() |
0 commit comments