pygmi.raster.cooper#

A collection of routines by Gordon Cooper for filtering raster data.

School of Geosciences, University of the Witwatersrand
Johannesburg, South Africa

Classes#

Gradients

Class used to gather information via a GUI, for function gradients.

Visibility2d

Class used to gather information via a GUI, for function visibility2d.

AGC

Class used to gather information via a GUI, for function AGC.

Functions#

gradients(data, azi, xint, yint)

Gradients.

thgrad(data, xint, yint)

Gradients.

derivative_ratio(data, azi, order)

Compute derivative ratio of image data. Based on code by Gordon Cooper.

visibility2d(data, wsize, dh[, piter])

Compute visibility as a textural measure.

visibilitytot(data, wsize, dh)

Compute visibility as a textural measure.

nextpow2(n)

Next power of 2.

vertical(data[, npts, xint, order])

Vertical derivative.

agc(data, wsize[, atype, nodata, piter])

AGC for map data, based on code by Gordon Cooper.

Module Contents#

class pygmi.raster.cooper.Gradients(parent=None)#

Bases: pygmi.misc.BasicModule

Class used to gather information via a GUI, for function gradients.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

azi#

Azimuth/filter direction (degrees)

Type:

float

elev#

Elevation (for sunshading, degrees from horizontal)

Type:

float

order#

Order of DR filter - see paper. Try 1 first.

Type:

int

setupui()#

Set up UI.

Return type:

None.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

Return type:

None.

radiochange()#

Check radio button state.

Return type:

None.

pygmi.raster.cooper.gradients(data, azi, xint, yint)#

Gradients.

Compute directional derivative of image data. Based on code by Gordon Cooper.

Parameters:
  • data (numpy array) – input numpy data array

  • azi (float) – Filter direction (degrees)

  • xint (float) – X interval/distance.

  • yint (float) – Y interval/distance.

Returns:

dt1 – returns directional derivative

Return type:

float

pygmi.raster.cooper.thgrad(data, xint, yint)#

Gradients.

Compute total horizontal gradient.

Parameters:
  • data (numpy array) – input numpy data array

  • xint (float) – X interval/distance.

  • yint (float) – Y interval/distance.

Returns:

dt1 – returns gradient.

Return type:

float

pygmi.raster.cooper.derivative_ratio(data, azi, order)#

Compute derivative ratio of image data. Based on code by Gordon Cooper.

Parameters:
  • data (numpy array) – input numpy data array

  • azi (float) – Filter direction (degrees)

  • order (float) – Order of DR filter - see paper. Try 1 first.

Returns:

dr – returns derivative ratio

Return type:

float

class pygmi.raster.cooper.Visibility2d(parent=None)#

Bases: pygmi.misc.BasicModule

Class used to gather information via a GUI, for function visibility2d.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

wsize#

window size, must be odd

Type:

int

dh#

height of observer above surface

Type:

float

setupui()#

Set up UI.

Return type:

None.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

Return type:

None.

pygmi.raster.cooper.visibility2d(data, wsize, dh, piter=iter)#

Compute visibility as a textural measure.

Compute vertical derivatives by calculating the visibility at different heights above the surface (see paper)

Parameters:
  • data (numpy array) – input dataset - numpy MxN array

  • wsize (int) – window size, must be odd

  • dh (float) – height of observer above surface

  • piter (function, optional) – Progress bar iterable. The default is iter.

Returns:

  • vtot (numpy array) – Total visibility.

  • vstd (numpy array) – Visibility variation.

  • vsum (numpy array) – Visibility vector resultant.

pygmi.raster.cooper.visibilitytot(data, wsize, dh)#

Compute visibility as a textural measure.

Compute vertical derivatives by calculating the visibility at different heights above the surface (see paper)

Parameters:
  • data (numpy array) – input dataset - numpy MxN array

  • wsize (int) – window size, must be odd

  • dh (float) – height of observer above surface

Returns:

  • vtot (numpy array) – Total visibility.

  • vstd (numpy array) – Visibility variation.

  • vsum (numpy array) – Visibility vector resultant.

pygmi.raster.cooper.nextpow2(n)#

Next power of 2.

Parameters:

n (float or numpy array) – Current value.

Returns:

m_i – Output.

Return type:

float or numpy array

pygmi.raster.cooper.vertical(data, npts=None, xint=1, order=1)#

Vertical derivative.

Parameters:
  • data (numpy array) – Input data.

  • npts (int, optional) – Number of points. The default is None.

  • xint (float, optional) – X interval. The default is 1.

  • order (int, optional) – Order. The default is 1.

Returns:

dz – Output data

Return type:

numpy array

class pygmi.raster.cooper.AGC(parent=None)#

Bases: pygmi.misc.BasicModule

Class used to gather information via a GUI, for function AGC.

Parameters:

parent (parent, optional) – Reference to the parent routine. The default is None.

wsize#

window size, must be odd

Type:

int

setupui()#

Set up UI.

Return type:

None.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool, optional) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

Return type:

None.

pygmi.raster.cooper.agc(data, wsize, atype='mean', nodata=0.0, piter=iter)#

AGC for map data, based on code by Gordon Cooper.

Parameters:
  • data (numpy array) – Raster data.

  • wsize (int) – Window size, must be odd.

  • atype (str, optional) – AGC type - can be median, rms or mean, default is ‘mean’.

  • nodata (float, optional) – no data value, default is 0.

  • piter (function, optional) – Progress bar iterable. The default is iter.

Returns:

agcdata – Output AGC data

Return type:

numpy array