Skip to content

Commit c9a0a2e

Browse files
committed
examples
1 parent 932fc1b commit c9a0a2e

6 files changed

Lines changed: 264 additions & 0 deletions

File tree

examples/BasicExamples/README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Basic examples
2+
--------------

examples/BasicExamples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
Anisotropic 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 anisotropic fractional Brownian field
47+
with random Hurst step function.
48+
"""
49+
from afbf import tbfield, perfunction
50+
51+
# Define the field.
52+
hurst = perfunction(ftype='step', param=2, fname='Hurst function')
53+
topo = perfunction(ftype='step', param=2, fname='Topothesy function')
54+
Z = tbfield(fname='afbf', topo=topo, hurst=hurst)
55+
Z.NormalizeModel()
56+
57+
# Simulate the field.
58+
z = Z.Simulate()
59+
60+
# Display the simulation.
61+
z.Display()
62+
Z.DisplayParameters()
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
Anisotropic 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 anisotropic fractional Brownian field
47+
with random Hurst smooth-step function.
48+
"""
49+
from afbf import tbfield, perfunction
50+
51+
# Define the field.
52+
hurst = perfunction(ftype='smooth-step', param=2, fname='Hurst function')
53+
topo = perfunction(ftype='smooth-step', param=2, fname='Topothesy function')
54+
Z = tbfield(fname='afbf', topo=topo, hurst=hurst)
55+
Z.NormalizeModel()
56+
57+
# Simulate the field.
58+
z = Z.Simulate()
59+
60+
# Display the simulation.
61+
z.Display()
62+
Z.DisplayParameters()
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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()

examples/BasicExamples/plot_fbf.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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+
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 a fractional Brownian field with
47+
a prescribed Hurst index.
48+
"""
49+
50+
import numpy as np
51+
from afbf import tbfield
52+
53+
N = 256 # Image size.
54+
H = 0.2 # Hurst index in (0, 1).
55+
56+
# Define the field.
57+
Z = tbfield('fbf')
58+
59+
# Change the parameter of the Hurst function.
60+
Z.hurst.ChangeParameters(np.array([[H]]))
61+
Z.NormalizeModel()
62+
63+
# Simulate the field.
64+
z = Z.Simulate()
65+
66+
# Display the simulation.
67+
z.Display()

0 commit comments

Comments
 (0)