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: - pixel – list 1D HSI data (p), a pixel.
- wvl – list 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: - spectrum – list 1D HSI data (p), a spectrum.
- wvl – list Wavelength of each band (p x 1).
- startContinuum – float The wavelength value of the starting left continuum.
- stopContinuum – float The wavelength value of the ending right continuum.
- baseline – float 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_name – string Title name.
- suffix – string 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_name – string Title name.
- suffix – string Add a suffix to the title.
-
get_continuum_removed_spectrum
(feat_no)[source]¶ - Returns: list
- Feature spectrum with convex hull removed (p).
-
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_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: - path – string The path where to put the plot.
- plot_name – string File name.
- suffix – string Add a suffix to the file name.
SpectrumConvexHullQuotient¶
-
class
pysptools.spectro.
SpectrumConvexHullQuotient
(spectrum, wvl, normalize=False)[source]¶ Remove the convex-hull of the signal by hull quotient.
Parameters: - spectrum – list 1D HSI data (p), a spectrum.
- wvl – list 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_name – string File name.
- suffix – string Add a suffix to the title.
-
plot
(path, plot_name, suffix=None)¶ Plot the hull quotient graph using matplotlib.
Parameters: - path – string The path where to put the plot.
- plot_name – string File name.
- suffix – string 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: - s – list A spectrum.
- distfn – function [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: idx – int 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: - substance – string A substance name.
- sample – string [default None] A sample.
- Returns: tuple
- Spectrum, mineral, sample_id, description and index.
-