ENVISpectralLibrary

This is a reference to an ENVISpectralLibrary object. You can create one from a .sli file on disk, or you can create an empty one and add spectra to it.

When creating an empty ENVISpectralLibrary object, set the following properties on the object:

Finally, use the AddSpectra method to add spectra to the library. See the second code example below.

Example

This example creates an ENVISpectralLibrary object from a spectral library file (.sli) on disk.

; Start the application

e = ENVI(/HEADLESS)

 

; Open a spectral library from the distribution

specLibFile = FILEPATH('veg_1dry.sli', ROOT_DIR=e.ROOT_DIR, $

  SUBDIR=['resource', 'speclib', 'veg_lib'])

specLib = ENVISpectralLibrary(specLibFile)

 

; print the spectra names

Print, specLib.SPECTRA_NAMES

The next example creates a new, empty ENVISpectralLibrary object and adds spectra to it. Follow these steps to run the example:

  1. Copy and paste the code into a new window in the IDL Editor.
  2. Save the file as NewSpectralLibrary.pro.
  3. Compile and run the program.
  4. When the Spectral Library Viewer appears, click each spectrum name to plot it.

PRO NewSpectralLibrary

COMPILE_OPT IDL2

; Start the application

e = ENVI()

 

; Create a new spectral library

specLibName = e.GetTemporaryFilename('sli')

specLib = EnviSpectralLibrary(specLibName)

 

; Set the WL (wavelength) property

specLib->SetProperty, WL=.4 + FINDGEN(25) * .1

 

; Add spectra

FOR i=1,5 DO BEGIN

  name = 'Spectra #' + STRTRIM(i,2)

  specLib.AddSpectra, name, Randomu(seed,25)

ENDFOR

 

; Smooth the spectra

FOR i=1,5 DO BEGIN

  name = 'Spectra #' + STRTRIM(i,2)

  spectra = specLib->GetSpectrum(name)

  specLib.AddSpectra, name + ' (Smooth)', SMOOTH(spectra.Spectrum,5)

ENDFOR

 

; Plot the spectral library

specLib = ENVISpectralLibrary(specLibName, /LOAD)

END

Syntax

Result = ENVISpectralLibrary(URI [, ERROR=variable] [, Properties=value])

Return Value

This function returns a reference to an ENVISpectralLibrary object.

Arguments

URI

Specify a fully qualified path and filename to a spectral library file (.sli).

Or, use the ENVI::GetTemporaryFilename method to create an empty ENVISpectralLibrary object. See the second code example above.

Methods

AddSpectra

Dehydrate

GetSpectrum

Hydrate

RemoveSpectra

Keywords

ERROR (optional)

Set this keyword to a named variable that will contain any error message issued during execution of this routine. If no error occurs, the ERROR variable will be set to a null string (''). If an error occurs and the routine is a function, then the function result will be undefined.

When this keyword is not set and an error occurs, ENVI returns to the caller and execution halts. In this case, the error message is contained within !ERROR_STATE and can be caught using IDL's CATCH routine. See IDL Help for more information on !ERROR_STATE and CATCH.

See Manage Errors for more information on error handling in ENVI programming.

LOAD (optional)

Set this keyword to plot the spectral library in the ENVI Spectral Library Viewer.

Properties

Properties marked as (Get) can be retrieved, but not set.

DESCRIPTION (Get)

A description of the library.

SPECTRA_NAMES (Get)

A string array containing the spectra names in the library.

Version History

ENVI 5.3

Introduced

ENVI 5.3.1

Added Dehydrate method

ENVI 5.4

Added Hydrate method

ENVI 5.5.3

Added AddSpectra and RemoveSpectra methods; Added LOAD keyword

API Version

4.2

See Also

ENVISpectralLibrary::GetSpectrum, GetSpectrumFromLibrary Task, QuerySpectralLibrary Task, ResampleSpectrum Task