Spectro Function and Classes

This module supports the functions convex_hull_removal and the classes SpectrumConvexHullQuotient, FeaturesConvexHullQuotient and USGS06SpecLib.

See also

See the file test_hull.py for a SpectrumConvexHullQuotient and FeaturesConvexHullQuotient example. The file test_spectro.py is the example for the USGS06SpecLib class.

Convex Hull Removal

pysptools.spectro.convex_hull_removal(pixel, wvl)[source]

Remove the convex-hull of the signal by hull quotient.

Parameters:
  • pixellist 1D HSI data (p), a pixel.
  • wvllist Wavelength of each band (p x 1).
Results: list
Data with convex hull removed (p).
Reference:
Clark, R.N. and T.L. Roush (1984) Reflectance Spectroscopy: Quantitative Analysis Techniques for Remote Sensing Applications, J. Geophys. Res., 89, 6329-6340.

FeaturesConvexHullQuotient

class pysptools.spectro.FeaturesConvexHullQuotient(spectrum, wvl, startContinuum=None, stopContinuum=None, baseline=0, normalize=False)[source]

Remove the convex-hull of the signal by hull quotient. Auto-extract the features and calculate their associated statistics. A baseline can be applied to avoid non-significant features. If you want to restrict the analysis to one continuum, just set the intervale with the startContinuum and stopContinuum parameters. It is up to you to ascertain that the continuum interval defined by startContinuum and stopContinuum do not cross the spectrum. The bilateral function can be use to remove small spectrum noises before extracting the features.

Parameters:
  • spectrumlist 1D HSI data (p), a spectrum.
  • wvllist Wavelength of each band (p x 1).
  • startContinuumfloat The wavelength value of the starting left continuum.
  • stopContinuumfloat The wavelength value of the ending right continuum.
  • baselinefloat Features extracted above the baseline are rejected, features extracted below the baseline are kept.
Reference:
Kokaly F. Raymond, PRISM: Processing Routines in IDL for Spectroscopic Measurements (Installation Manual and User’s Guide, Version 1.0), U.S. Geological Survey,Reston, Virginia: 2011.
display(plot_name, feature='all')

Display the hull quotient graph of the feature to the IPython Notebook using matplotlib.

Parameters:
  • plot_namestring Title name.
  • suffixstring Add a suffix to the title.
display_convex_hull_quotient(plot_name, suffix=None)[source]

Display the hull quotient graph to the IPython Notebook using matplotlib.

Parameters:
  • plot_namestring Title name.
  • suffixstring Add a suffix to the title.
get_absorbtion_depth(feat_no)[source]
Returns: float
The absorbtion value at the feature minimum.
get_absorbtion_wavelength(feat_no)[source]
Returns: float
The wavelength at the feature minimum.
get_area(feat_no)[source]
Returns: float
The feature area.
get_continuum_removed_spectrum(feat_no)[source]
Returns: list
Feature spectrum with convex hull removed (p).
get_continuum_slope(feat_no)[source]
Returns: float
The feature continuum slope.
get_continuum_start_wavelength(feat_no)[source]
Returns: float
The continuum left start wavelength value.
get_continuum_stop_wavelength(feat_no)[source]
Returns: float
The continuum right end wavelength value.
get_full_width_at_half_maximum(feat_no)[source]
Returns: float
Width at half maximum.
get_number_of_kept_features()[source]
Returns: int
The number of features that are kept (below the baseline). Only theses features have a statistic report.
plot(path, plot_name, feature='all')

Plot the hull quotient graph of the feature using matplotlib.

Parameters:
  • pathstring The path where to put the plot.
  • plot_namestring File name.
  • suffixstring Add a suffix to the file name.
plot_convex_hull_quotient(path, plot_name, suffix=None)[source]

Plot the hull quotient graph using matplotlib.

Parameters:
  • pathstring The path where to put the plot.
  • plot_namestring File name.
  • suffixstring Add a suffix to the file name.
print_stats(feat_no)[source]

Print a statistic summary for a kept feature.

Parameters:feat_noint or ‘all’ The feature number, if feat_no=’all’, print stats for all the kept features.

SpectrumConvexHullQuotient

class pysptools.spectro.SpectrumConvexHullQuotient(spectrum, wvl, normalize=False)[source]

Remove the convex-hull of the signal by hull quotient.

Parameters:
  • spectrumlist 1D HSI data (p), a spectrum.
  • wvllist Wavelength of each band (p x 1).
Reference:
Clark, R.N. and T.L. Roush (1984) Reflectance Spectroscopy: Quantitative Analysis Techniques for Remote Sensing Applications, J. Geophys. Res., 89, 6329-6340.
display(plot_name, suffix=None)

Display the hull quotient graph to the IPython Notebook using matplotlib.

Parameters:
  • plot_namestring File name.
  • suffixstring Add a suffix to the title.
get_continuum_removed_spectrum()[source]
Returns: list
Spectrum with convex hull removed (p).
get_hull_x()[source]
Returns: list
Convex hull x values (p).
get_hull_y()[source]
Returns: list
Convex hull y values (p).
plot(path, plot_name, suffix=None)

Plot the hull quotient graph using matplotlib.

Parameters:
  • pathstring The path where to put the plot.
  • plot_namestring File name.
  • suffixstring Add a suffix to the file name.

USGS06SpecLib

class pysptools.spectro.EnviReader(fname)[source]

Open a ENVI version of the USGS library and return the data and the header.

The ENVI version is made of two files:
  • s06av95a_envi.hdr
  • s06av95a_envi.sli
You create the reader this way (on Windows):
rd = EnviReader(r’c:\somepath\s06av95a_envi.hdr’)
And pass it to the SpecLib class this way:
lib = SpecLib(rd)
class pysptools.spectro.JSONReader(fname)[source]

Open a JSON version of the USGS library and return the data and the header.

The JSON version is made of two files:
  • s06av95a_envi.jdata
  • s06av95a_envi.jhead
You create the reader this way (on Windows):
rd = JSONReader(r’c:\somepath\s06av95a_envi’)
And pass it to the SpecLib class this way:
lib = SpecLib(rd)
class pysptools.spectro.USGS06SpecLib(reader)[source]

Load the library and add get and search functionnality.

Parameters:reader – EnviReader or JSONReader instance
distance_match(s, distfn='SAM')[source]

Scan the library and return the index of the spectrum that have the smallest distance to ‘s’.

Parameters:
  • slist A spectrum.
  • distfnfunction [default ‘SAM’] One of the function: SAM, SID, chebyshev, NormXCorr.
Returns: tuple
Spectrum, index.
get(idx)[source]

Return the spectrum at index idx. Indexing start at zero.

Parameters:idxint The index of the spectrum to fetch.
Returns: list
Spectrum (p).
get_next()[source]

Iterator, scan the library and return at each step: spectrum, mineral, sample_id, description and index.

Return: tuple
Spectrum, mineral, sample_id, description and index.
get_substance(substance, sample=None)[source]

Iterator, scan the library, verify the conditions ‘substance’ and/or ‘sample’ and if true return: spectrum, sample_id, description and index.

Parameters:
  • substancestring A substance name.
  • samplestring [default None] A sample.
Returns: tuple
Spectrum, mineral, sample_id, description and index.