pygmi.rsense.hyperspec#

Hyperspectral interpretation routines.

Classes#

Graph

Graph Map widget.

Map

Graph Map widget.

AnalSpec

Analyse spectra GUI.

ProcFeatures

GUI to process hyperspectral features.

Functions#

calcfeatures(dat, mineral, feature, ratio, product, *)

Calculate feature dataset.

indexcalc(formula, dat)

Calculate an index using numexpr.

fproc(fdat, ptmp, dtmp, i1a, i2a, xdat, mtmp)

Feature process.

cubic_calc(xdat, crem, imin)

Find minimum of function using an analytic cubic calculation for speed.

phulljit(sample1)

Hull Calculation.

phull(y)

Calculate Continuum/hull.

readsli(ifile)

Read an ENVI sli file.

Module Contents#

class pygmi.rsense.hyperspec.Graph#

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

Graph Map widget.

compute_spectra()#

Compute the spectra.

class pygmi.rsense.hyperspec.Map#

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

Graph Map widget.

compute_initial_figure()#

Compute initial figure.

class pygmi.rsense.hyperspec.AnalSpec(parent=None)#

Bases: pygmi.misc.BasicModule

Analyse spectra GUI.

Parameters:

parent – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

button_press_callback(event)#

Button press callback.

Parameters:

event (matplotlib.backend_bases.MouseEvent) – Mouse Event.

disp_splib()#

Change library spectra for display.

export()#

Export displayed spectra.

feature_change()#

Change depth marker combo.

hull()#

Change whether hull is removed or not.

load_splib(checked=False, nofile=True)#

Load ENVI spectral library data.

Parameters:
  • checked (bool) – Set check state of button. Default is False.

  • nofile (bool) – No input filename. The default is True.

on_combo()#

On combo.

toggle_rgb_view()#

Toggle RGB view and single band view.

overlay()#

Change whether to display extra spectrum.

settings(nodialog=False)#

Entry point into item.

Parameters:

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

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

showtext()#

Show spectrum description in browser.

class pygmi.rsense.hyperspec.ProcFeatures(parent=None)#

Bases: pygmi.misc.BasicModule

GUI to process hyperspectral features.

Parameters:

parent – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

product_change()#

Change product combo.

settings(nodialog=False)#

Entry point into item.

Parameters:

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

Returns:

True if successful, False otherwise.

Return type:

bool

saveproj()#

Save project data from class.

acceptall()#

Accept option.

Updates self.outdata, which is used as input to other modules.

Returns:

True if successful, False otherwise.

Return type:

bool

pygmi.rsense.hyperspec.calcfeatures(dat, mineral, feature, ratio, product, *, cryst=None, rfilt=True, piter=iter, showlog=print)#

Calculate feature dataset.

Parameters:
  • dat (list[pygmi.raster.datatypes.Data]) – Input PyGMI data.

  • mineral (str) – Mineral description.

  • feature (dict[str, list[int]]) – Dictionary containing the hyperspectral features.

  • ratio (dict[str, str]) – Dictionary containing string definitions of ratios.

  • product (dict[str, list[str]]) – Final hyperspectral products. Each dictionary value, is a list of features or ratios with thresholds to be combined.

  • cryst (list | None) – Crystallinity of the product, if available

  • rfilt (bool) – Flag to decide whether to filter final ratio products less than 1.0

  • piter (collections.abc.Iterable) – Progress bar iterable. The default is iter.

  • showlog (collections.abc.Callable[..., None]) – Routine to show text messages. The default is print.

Returns:

Output datasets.

Return type:

list of Data

pygmi.rsense.hyperspec.indexcalc(formula, dat)#

Calculate an index using numexpr.

Parameters:
  • formula (str) – string expression containing index formula.

  • dat (dict[str, numpy.typing.NDArray | numpy.ma.MaskedArray]) – Dictionary of variables to be used in calculation.

Returns:

out – This can be a masked array.

Return type:

ndarray or MaskedArray

pygmi.rsense.hyperspec.fproc(fdat, ptmp, dtmp, i1a, i2a, xdat, mtmp)#

Feature process.

This function finds the minimum value of a feature.

Parameters:
  • fdat (numpy.typing.NDArray) – Feature data

  • ptmp (numpy.typing.NDArray) – Feature wavelengths.

  • dtmp (numpy.typing.NDArray) – Feature depths.

  • i1a (int) – Start index of feature definition.

  • i2a (int) – End Index of feature definition.

  • xdat (numpy.typing.NDArray) – Wavelengths of feature definition.

  • mtmp (numpy.typing.NDArray) – Used in crystallinity calculation.

Returns:

  • ptmp (ndarray) – Feature wavelengths.

  • dtmp (ndarray) – Feature depths.

  • mtmp (ndarray) – Used in crystallinity calculation.

Return type:

tuple[numpy.typing.NDArray, numpy.typing.NDArray, numpy.typing.NDArray]

pygmi.rsense.hyperspec.cubic_calc(xdat, crem, imin)#

Find minimum of function using an analytic cubic calculation for speed.

Parameters:
  • xdat (numpy.typing.NDArray) – wavelengths - x data.

  • crem (numpy.typing.NDArray) – continuum removed data - y data.

  • imin (int) – Index for estimated minimum.

Returns:

  • x (float) – wavelength at minimum.

  • y (float) – y value at minimum.

Return type:

tuple[float, float]

pygmi.rsense.hyperspec.phulljit(sample1)#

Hull Calculation.

This is only here to be called from the jit routines

Parameters:

sample1 (numpy.typing.NDArray) – Sample to create a hull for.

Returns:

Output hull.

Return type:

ndarray

pygmi.rsense.hyperspec.phull(y)#

Calculate Continuum/hull.

Based on: https://stackoverflow.com/questions/73382974/how-to-apply-continuum-removal-in-spectral-graph

Parameters:

y (numpy.typing.NDArray) – Sample to create a hull for.

Returns:

Output hull.

Return type:

ndarray

pygmi.rsense.hyperspec.readsli(ifile)#

Read an ENVI sli file.

Parameters:

ifile (str) – Input sli spectra file.

Returns:

Dictionary of spectra with wavelengths and reflectances.

Return type:

dict