bruges.filters.filters module

Smoothers.

copyright:2015 Agile Geoscience
license:Apache 2.0
bruges.filters.filters.conservative(arr, size=5, supercon=False)[source]

Conservative, a nonlinear n-D despiking filter. Very conservative! Only changes centre value if it is outside the range of all the other values in the kernel. Read http://subsurfwiki.org/wiki/Conservative_filter

Parameters:
  • arr (ndarray) – an n-dimensional array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5 (in a 2D arr). Should be odd, rounded up if not.
  • supercon (bool) – whether to be superconservative. If True, replaces pixel with min or max of kernel. If False (default), replaces pixel with mean of kernel.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.kuwahara(arr, size=5)[source]

Kuwahara, a nonlinear 2D smoothing filter. http://subsurfwiki.org/wiki/Kuwahara_filter

Parameters:
  • arr (ndarray) – a 2D array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.mean(arr, size=5)[source]

A linear n-D smoothing filter. Can be used as a moving average on 1D data.

Parameters:
  • arr (ndarray) – an n-dimensional array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.median(arr, size=5)[source]

A nonlinear n-D edge-preserving smoothing filter.

Parameters:
  • arr (ndarray) – an n-dimensional array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.mode(arr, size=5, tie='smallest')[source]

A nonlinear n-D categorical smoothing filter. Use this to filter non- continuous variables, such as categorical integers, e.g. to label facies.

Parameters:
  • arr (ndarray) – an n-dimensional array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
  • tie (str) – ‘smallest’ or ‘largest’. In the event of a tie (i.e. two or more values having the same count in the kernel), whether to give back the smallest of the tying values, or the largest.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.rms(arr, size=5)[source]

A linear n-D smoothing filter. Can be used as a moving average on 1D data.

Parameters:
  • arr (ndarray) – an n-dimensional array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
Returns:

the resulting smoothed array.

Return type:

ndarray

bruges.filters.filters.rotate_phase(s, phi, degrees=False)[source]

Performs a phase rotation of wavelet or wavelet bank using:

\[A = w(t)\cos(\phi) - h(t)\sin(\phi)\]

where w(t) is the wavelet and h(t) is its Hilbert transform.

The analytic signal can be written in the form S(t) = A(t)exp(j*theta(t)) where A(t) = magnitude(hilbert(w(t))) and theta(t) = angle(hilbert(w(t)) then a constant phase rotation phi would produce the analytic signal S(t) = A(t)exp(j*(theta(t) + phi)). To get the non analytic signal we take real(S(t)) == A(t)cos(theta(t) + phi) == A(t)(cos(theta(t))cos(phi) - sin(theta(t))sin(phi)) <= trig identity == w(t)cos(phi) - h(t)sin(phi)

Parameters:
  • w (ndarray) – The wavelet vector, can be a 2D wavelet bank.
  • phi (float) – The phase rotation angle (in radians) to apply.
  • degrees (bool) – If phi is in degrees not radians.
Returns:

The phase rotated signal (or bank of signals).

bruges.filters.filters.snn(arr, size=5, include=True)[source]

Symmetric nearest neighbour, a nonlinear 2D smoothing filter. http://subsurfwiki.org/wiki/Symmetric_nearest_neighbour_filter

Parameters:
  • arr (ndarray) – a 2D array, such as a seismic horizon.
  • size (int) – the kernel size, e.g. 5 for 5x5. Should be odd, rounded up if not.
  • include (bool) – whether to include the central pixel itself.
Returns:

the resulting smoothed array.

Return type:

ndarray