afbf.Simulation package

Submodules

afbf.Simulation.TurningBands module

Module for the management of turning band fields.

Code author: Frédéric Richard <frederic.richard_at_univ-amu.fr>

class afbf.Simulation.TurningBands.tbfield(fname='fbf', topo=None, hurst=None, K=500)

Bases: afbf.Classes.Field.field

This class handles the turning-band fields.

They are defined as follows. Let \(\{ \phi_k, k =1,\cdots, K\}\) be a set of ordered angles in \([-\pi/2,\pi/2)\), called turning bands. Let \(\tau\) and \(\beta\) be the topothesy and Hurst functions of an AFBF.

\[W(y) = \sum_{k=1}^K \lambda_k X_k(\langle \phi_k, y \rangle),\]

where \(\lambda_k\) are coefficients depending on \(\tau(\phi_k)\) and \(X_k\) are independent fractional Brownian motions of Hurst index \(\beta(\phi_k)\).

Turning band fields are used for simulation.

Example

Simulation of a fractional Brownian field.

>>> from afbf import tbfield
>>> # Definition of a fractional Brownian field.
>>> field = tbfield()
>>> field.DisplayParameters(1)
>>> field.tb.DisplayInformation()
>>> # Simulation of the field.
>>> X = field.Simulate()
>>> X.Display(3)
Parameters
  • tb (tbparameters) – Turning band parameters of the fields.

  • svario (sdata) – The semi variogram of the turning-band field.

Constructor method.

Parameters
  • fname (str, optional) – Name of the field. The default is ‘fbf’.

  • topo (perfunction, optional) – The topothesy function of the field.

  • hurst (perfunction, optional) – The Hurst function of the field.

  • K (int or tbparameters) – Number of bands. The default is 500. if K is of the class tbparameters, the bands are given directly in K.

Returns

Attributes fname, topo, hurst and tb.

See also

Constructor method of the class AFBF (field).

ComputeApproximateSemiVariogram(lags, logvario=0, evaluate=True)

Compute the semi-variogram of the turning-band field.

Parameters
  • lags (coordinates) – Lags at which to compute the semi-variogram.

  • logvario (int, optional) – If log>0, a log semi-variogram is computed instead of the semi-variogram. The default is 0.

  • evaluate (boolean, optional) – if True the topothesy and hurst functions are evaluated at bands. If not, the current values are used. The default is True.

Returns

Attribute svario.

EvaluateTurningBandParameters()

Evaluate the topothesy and Hurst function at turning band angles.

Returns

Attributes topo and hurst.

ExtendTopothesy(M1=2, M2=4)

Extend the definition of the topothesy of the field.

Parameters
  • M1 (int) – Number of spectrum subdivisions.

  • M2 (int) – Number of angle subdivisions.

InitTurningBands(K)

Set parameters of turning bands.

Parameters

K (int) – The number of bands.

Returns

Attribute tb.

Simulate(coord=None, vario=False, evaluate=True)

Simulate the anisotropic fractional Brownian fields by a turning-band method.

Note

The method was designed by H. Biermé, L. Moisan and F. Richard. It is described in [11].

Parameters
  • coord (coordinates) – Coordinates where to simulate the field or evaluate its semi-variogram. The default is None, indicating that coordinates will be set automatically.

  • vario (boolean, optional) – if True, the function computes the semi-variogram of the simulation field. The default is False.

  • evaluate (boolean, optional) – if True, the topothesy and hurst functions are evaluated at bands. If not, the current values are used. The default is True.

Returns

A simulation of the field or the semi-variogram of the simulation field (if vario=True).

Return type

sdata

class afbf.Simulation.TurningBands.tbparameters(K=500)

Bases: object

This class handles parameters of the turning band field.

Parameters
  • K (int) – the number of bands.

  • Kangle (ndarray) –

    Angles of the turning bands. The tangent of each angle \(\varphi\) have a tangent which satisfies

    \[\tan(\varphi) = \frac{p}{q},\]

    for some \(p \in \mathbb{Z}\) and \(q \in \mathbb{N}^*\).

  • Pangle (ndarray) – Denominators \(q\) of angle tangents.

  • Qangle (ndarray) – Numerators \(p\) of angle tangents.

  • cost (scalar) – Angle cost (dynamic programming).

  • acc (scalar) – Precision (dynamic programming).

Constructor method.

Parameters

K (int, optional) – An approximate number of turning bands. The default is 500.

Note

This parameter determines the simulation accuracy which is about \(\frac{\pi}{K}\) (in radians).

DisplayInformation()

Display information about simulation.

OptimalAngles(N=500)

Compute a set of optimal angles by dynamic programming.

Parameters

N (scalar) – The expected precision. if \(N < 1\), the precision is set to N else the precision (in radians) is set to \(\frac{pi}{N}\).

Returns

Attributes Kangle, Pangle, Qangle.

Note

The dynamic programming algorithm finds an optimal subset \(S'\) of angles among a set \(\Phi\) of possible angles whose tangents are rational. :math:`Phi`is a subset of

\[\{\varphi \in [-\pi/2,\pi/2], \tan(\varphi)=p/q, p \in \mathbb{Z}, q \in \mathbb{N}^\ast, p \wedge q=1\}.\]

A cost \(C(\varphi)=\vert q \vert+p\) is associated to each angle \(\varphi\).

The optimal subset \(\Phi'\) minimizes \(\sum_{\varphi \in \Phi'} C(\varphi)\) under the constraint that the difference between two successive angles are below a given precision.

Precision()

Compute the precision of the turning bands.

QuasiUniformAngles(K=100000)

Build a set of K angles which are approximately uniform on the interval \([-\frac{\pi}{2},\frac{\pi}{2}]\).

Parameters

K (int, optional) – A number of angles. The default is 100000.

Returns

Attributes Kangle, Pangle, Qangle.

SimulationCost()

Compute the computational cost associated to the turning bands.

Module contents