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, 13]).

  • 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.

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, Hmax, 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.

ComputeFeatures_Hurst()

Compute several features of the field related to the Hurst index. :returns: Attributes H, Hmax, hurst_argmin_lenght, hurst_argmin_center.

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.

Save(filename)

Save a field model.

Parameters:

filename (str.) – address of the file.

Note

The field can be rebuilt using the function LoadField.

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: 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.

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.

Save(filename)

Load the tbfield model.

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