API: main classes

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

AFBF (field)

class afbf.Classes.Field.field(fname='fbf', topo=None, hurst=None)

Bases: object

This class handles Anisotropic Fractional Brownian Fields (AFBF).

An AFBF is a Gaussian random field with stationary increments whose probabibility distribution is characterized by a density of the form [1, 2, 3, 4, 5, 6, 7]

\[v(x) = \frac{1}{2} \int_{-\pi/2}^{\pi/2} \tau(\theta) \left\vert \langle x, (\cos(\theta), \sin(\theta)) \rangle \right\vert^{2\beta(\theta)} d\theta\]

where \(\tau\) and \(\beta\) are non-negative \(\pi\)-periodic functions depending both on the direction \(\arg(w)\) of the frequency \(w\).

Functions \(\tau\) and \(\beta\) are called the topothesy function and the Hurst function, respectively.

Parameters
  • fname (str) – Name of the field.

  • topo (perfunction) – The topothesy function \(\tau\) of the field.

  • hurst (perfunction) – The Hurst function \(\beta\) of the field.

  • order (int) – The order of the field (used for the extension to intrinsic field [3, 4, 5, 6, 7, 12]).

  • H (scalar) – The Hurst index of the field.

  • hurst_argmin_len (scalar) – The lenght of the argmin set of the Hurst function.

  • Hmax (scalar) – The maximum of the Hurst function.

  • hurst_aniso_index (scalar) – An anisotropy index derived from the lenght of the argmin set of the Hurst function.

  • aniso_indices_topo (:ref:`ndarray) – Measures of deviation of the topothesy function.

  • aniso_indices_hurst (ndarray) – Measures of deviation of the Hurst function.

  • aniso_sharpness_topo (ndarray) – Measures of sharpness of the topothesy function.

  • aniso_sharpness_hurst (ndarray) – Measures of sharpness of the Hurst function.

  • aniso_indices_mixed_1 (ndarray) – Measures of deviations of a function combining the topothesy and Hurst functions.

  • aniso_indices_mixed_2 – Measures of deviations of another function combining the topothesy and Hurst functions.

  • aniso_sharpness_mixed_2 (ndarray) – Measures of sharpness of another function combining the topothesy and Hurst functions.

Constructor method.

Set the random field model either in a predefined or a customized mode.

In customized mode, the field is defined with topothesy and Hurst functions given in arguments as objects of the class perfunction.

In predefined mode, the topothesy and Hurst functions are generated at random according to the type of field indicated in fname. Available predefined fields are:

  • ‘fbf’:

    standard fractional Brownian field (default).

  • ‘efbf’:

    elementary fractional Brownian field.

  • ‘afbf’:

    Normalized afbf with a step Hurst function.

  • ‘afbf-smooth’:

    Normalized afbf with a smooth step Hurst function.

  • ‘afbf-Fourier’:

    afbf with a Fourier topothesy and a step Hurst function.

  • ‘afbf-smooth-Fourier’:

    afbf with a Fourier topothesy and a smooth step Hurst function.

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

  • topo (perfunction, optional) – Topothesy function. Default is None.

  • hurst (perfunction, optional) – Topothesy function. Default is None.

Returns

Attributes fname, order, topo, hurst.

ChangeOrder(neworder)

Change the order of the intrinsic field.

Parameters

neworder (int) – The new order of the field.

Returns

Attributes order, hurst.

Warning

This function is only available when the Hurst function is a step function.

CheckValidity()

Check the validity of field.

Returns

True if attributes are properly defined, and false otherwise.

Return type

boolean

ComputeFeatures()

Compute several features of the field.

Returns

Attributes H, hurst_argmin_length, hurst_index_aniso, aniso_indices_topo, aniso_indices_hurst, aniso_sharpness_topo, aniso_sharpness_hurst, aniso_indices_mixed1, aniso_indices_mixed2, aniso_sharpness_mixed1, aniso_sharpness_mixed2.

ComputeSemiVariogram(lags)

Compute values of the semi-variogram of the field at points given by lags.

Parameters

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

Returns

Attribute vario.

DisplayParameters(nfig=1)

Plot the graph of the topothesy and Hurst functions of the field, and the semi-variogram (if available).

Parameters

nfig (int, optional) – The index of the figure. Default to 1.

FindOrder()

Find the order of the intrinsic field.

Returns

Attribute order.

Return type

int.

Warning

This function is only available when the Hurst function is a step function.

NormalizeModel()

Normalize the model.

Note

This function can only be applied if the Hurst function is a step function.

SetModel(fname='fbf', topo=None, hurst=None)

See Constructor method.

Turning band field (tbfield)

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