Fourier Transform

class surfalize.fourier.FourierTransform(surface)

Bases: CachedInstance

Represents the 2d Fourier transform of a Surface object and provides methods to calculate the spatial period, texture orientation and angular power spectrum derived from it. The transform and its derived quantities are cached on the instance, so the FFT is computed only once and shared between the period, orientation and angular power spectrum calculations.

Parameters:
surfaceSurface

Surface object on which to calculate the Fourier transform.

Methods

Std([angle_step])

Calculates the texture direction parameter Std, the angle at which the angular spectrum is the largest.

angular_power_spectrum([angle_step])

Computes the angular power spectrum (angular power density fAPD) by integrating the squared amplitude of the Fourier transform over angular bins.

clear_cache()

Clears the cache for the entire instance.

create_cache_entry(method, entry, args, kwargs)

Manually creates a cache entry for the specified method.

dominant_wavelength()

Calculates the dominant spatial wavelength (Ssw), the wavelength corresponding to the largest absolute value of the Fourier transform of the ordinate values.

orientation()

Computes the orientation angle of the dominant texture towards the vertical axis from the peaks of the Fourier transform.

period()

Calculates the 1d spatial period based on the Fourier transform.

period_x_y()

Calculates the spatial period along the x and y axes based on the Fourier transform.

plot([ax, log, hanning, subtract_mean, ...])

Plots the 2d Fourier transform of the surface.

plot_angular_power_spectrum([ax, angle_step])

Plots the angular power spectrum on a polar axis.

Std(angle_step=0.5)

Calculates the texture direction parameter Std, the angle at which the angular spectrum is the largest. It represents the lay of the surface texture.

ISO 25178-2 (4.3.4) defines Std via the angular amplitude density fAAD. In practice the angular power density fAPD (squared amplitude) is used here, which matches the behaviour of commercial software (e.g. MountainsMap). The two only differ for surfaces with several competing lays of similar strength, where the texture direction is intrinsically ambiguous; for a single dominant lay the result is identical.

Parameters:
angle_stepfloat

Angular resolution of the spectrum in degree. Defaults to 0.5

Returns:
float
angular_power_spectrum(angle_step=1)

Computes the angular power spectrum (angular power density fAPD) by integrating the squared amplitude of the Fourier transform over angular bins.

Parameters:
angle_stepfloat

Angular resolution of the power spectrum in degree.

Returns:
(angles, spectrum)tuple[ndarray, ndarray]
dominant_wavelength()

Calculates the dominant spatial wavelength (Ssw), the wavelength corresponding to the largest absolute value of the Fourier transform of the ordinate values. The mean is subtracted beforehand to avoid the zero peak.

Returns:
wavelengthfloat
orientation()

Computes the orientation angle of the dominant texture towards the vertical axis from the peaks of the Fourier transform. Note that the refined orientation estimate (which additionally samples spatial profiles) lives on the Surface class, since it is not a purely Fourier-based quantity.

Returns:
anglefloat

Angle of the dominant texture to the vertical axis

period()

Calculates the 1d spatial period based on the Fourier transform.

Returns:
periodfloat
period_x_y()

Calculates the spatial period along the x and y axes based on the Fourier transform.

Returns:
(periodx, periody)tuple[float, float]
plot(ax=None, log=True, hanning=False, subtract_mean=True, fxmax=None, fymax=None, cmap='inferno', adjust_colormap=True)

Plots the 2d Fourier transform of the surface. Optionally, a Hanning window can be applied to reduce spectral leakage effects that occur when analyzing a signal of finite sample length.

Parameters:
axmatplotlib axis, default None

If specified, the plot will be drawn on the specified axis.

logbool, Default True

Shows the logarithm of the Fourier Transform to increase peak visibility.

hanningbool, Default False

Applys a Hanning window to the data before the transform.

subtract_meanbool, Default False

Subtracts the mean of the data before the transform to avoid the zero peak.

fxmaxfloat, Default None

Maximum frequency displayed in x. The plot will be cropped to -fxmax : fxmax.

fymaxfloat, Default None

Maximum frequency displayed in y. The plot will be cropped to -fymax : fymax.

cmapstr, Default ‘inferno’

Matplotlib colormap with which to map the data.

adjust_colormapbool, Default True

If True, the colormap starts at the mean and ends at 0.7 times the maximum of the data to increase peak visibility.

Returns:
plt.Figure, plt.Axes
plot_angular_power_spectrum(ax=None, angle_step=1)

Plots the angular power spectrum on a polar axis.

Returns:
plt.Figure, plt.Axes