Spectro function and classes
This module supports the functions convex_hull_removal and the
classes SpectrumConvexHullQuotient, FeaturesConvexHullQuotient and USGS06SpecLib.
See the file test_hull.py
for a SpectrumConvexHullQuotient and FeaturesConvexHullQuotient example. The file test_spectro.py is the example for the USGS06SpecLib class.
Warning
This module is not ported to Python 3.3.
FeaturesConvexHullQuotient
-
class spectro.FeaturesConvexHullQuotient(spectrum, wvl, startContinuum=None, stopContinuum=None, baseline=0)
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')
Plot the hull quotient graph of the feature
for the IPython Notebook using matplotlib.
- Parameters:
- plot_name: string
- File name.
- suffix: string
- Add a suffix to the title.
-
display_convex_hull_quotient(plot_name, suffix=None)
Plot the hull quotient graph for the IPython
Notebook using matplotlib.
- Parameters:
- plot_name: string
- File name.
- suffix: string
- Add a suffix to the title.
-
get_absorbtion_depth(feat_no)
- Returns: float
- The absorbtion value at the feature minimum.
-
get_absorbtion_wavelength(feat_no)
- Returns: float
- The wavelength at the feature minimum.
-
get_area(feat_no)
- Returns: float
- The feature area.
-
get_continuum_removed_spectrum(feat_no)
- Returns: list
- Feature spectrum with convex hull removed (p).
-
get_continuum_slope(feat_no)
- Returns: float
- The feature continuum slope.
-
get_continuum_start_wavelength(feat_no)
- Returns: float
- The continuum left start wavelength value.
-
get_continuum_stop_wavelength(feat_no)
- Returns: float
- The continuum right end wavelength value.
-
get_full_width_at_half_maximum(feat_no)
- Returns: float
- Width at half maximum.
-
get_number_of_kept_features()
- 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.
-
plot_convex_hull_quotient(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.
-
print_stats(feat_no)
Print a statistic summary for a kept feature.
- Parameters:
- feat_no: int or ‘all’
- The feature number, if feat_no=’all’, print
stats for all the kept features.
SpectrumConvexHullQuotient
-
class spectro.SpectrumConvexHullQuotient(spectrum, wvl, normalize=False)
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)
Plot the hull quotient graph for the IPython
Notebook using matplotlib.
- Parameters:
- plot_name: string
- File name.
- suffix: string
- Add a suffix to the title.
-
get_continuum_removed_spectrum()
- Returns: list
- Spectrum with convex hull removed (p).
-
get_hull_x()
- Returns: list
- Convex hull x values (p).
-
get_hull_y()
- Returns: list
- Convex hull y values (p).
-
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.
convex_hull_removal
-
spectro.convex_hull_removal(pixel, wvl)
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.
USGS06SpecLib
-
class spectro.USGS06SpecLib(fname)
Load the library and add get and search functionnality.
-
distance_match(s, distfn='SAM')
Scan the library and return the index of the signal that
have the smallest distance to ‘s’.
- Parameters:
- s: list
- A signal.
- distfn: function [default ‘SAM’]
- One of the function: SAM, SID, chebyshev, NormXCorr.
- Returns: tuple
- Signal, index.
-
get(idx)
Return the signal at index idx.
Indexing start at zero.
- Parameters:
- idx: int
- The index of the signal to fetch.
- Returns: list
- Signal (p).
-
get_next()
Iterator, scan the library and return at each step:
signal, mineral, sample_id, description and index.
- Return: tuple
- Signal, mineral, sample_id, description and index.
-
get_substance(substance, sample=None)
Iterator, scan the library, verify the conditions ‘substance’
and/or ‘sample’ and if true return:
signal, sample_id, description and index.
- Parameters:
- substance: string
- A substance name.
- sample: string [default None]
- A sample.
- Returns: tuple
- Signal, mineral, sample_id, description and index.