ENVI Classic Tutorial: Plot Functions
ENVI Classic Tutorial: Plot Functions
Functions
Introduction to Plot Functions
Files Used in this Tutorial
Plot Functions
Create a Plot Function
Add the Plot Function to the Menu
Set up ENVI Classic to Run the Plot Function
Open a Spectral Library and Plot Spectra
2
2
3
4
5
6
7
Page 1 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
Description
Plot function to take the first derivative of a spectrum
Plot function to take the second derivative of a spectrum
Modified (replacement) version of useradd.txt, which resides in
the menu directory of your ENVI Classic installation
USGS mineral spectral library
Page 2 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
Plot Functions
Plot functions are a special class of ENVI Classic user functions that modify data in an ENVI Classic
plot window, such as a Z Profile window. For example, ENVI Classics built-in plot functions (which
are listed in the Plot_Function menu in any plot window) include items such as Binary Encoding and
Continuum Removal. Define user plot functions by adding a new line to the useradd.txt file that
resides in your ENVI Classic menu directory. However, while ordinary user functions are automatically
called by XMANAGER and receive the event structure variable as a positional parameter, plot
functions are automatically called by ENVI Classic and receive several variables (as both parameters
and keywords) that are related to the data in the plot window.
When you call a user plot function, normal plot data (all the spectra in the plot window) are passed to the
user plot function. The plot function is applied to the data, and the resulting data are returned to the plot
window where they are displayed. The user plot function is applied to every spectrum placed in that
window until a different plot function is selected.
All user plot functions must have the following function definition statement:
Where:
X_DATA: Data values for the x-axis
Y_DATA: Data values for the y-axis
BBL: Vector whose values identify the band positions of the bad bands in the Z Profile data. For
example, if the Z Profile contained 224 bands, but bands 3, 4, and 5 were in marked as bad bands
in the ENVI header file, then BBL would be set to [2,3,4]. This applies only to Z Profile windows
and will be undefined for all other plot windows.
BBL_ARRAY: Vector of ones and zeros with as many elements as x-axis data points. A value of
1 indicates that the corresponding y-axis value is good, and a value of 0 means it is bad (i.e., for Z
Profiles, a value of 0 means the band is in the bad bands list).
L_POS: Indicates the index into the X_DATA array where the x-axis plot begins. If the plot
window is not zoomed-in, then L_POS is 0.
R_POS: Indicates the index into the X_DATA array where the x-axis plot ends. If the plot
window is not zoomed-in, then the value of R_POS is n_elements(X_DATA)-1.
_EXTRA: Keyword variable that must be present to receive extra variables that ENVI Classic
may need to pass into the plot function. If the plot function is defined without this keyword, then
you will likely receive errors when trying to use it in ENVI Classic.
Page 3 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
This function accepts x and y data and a list of bad bands. Excluding the bad bands, the function
takes the first derivative of the y value and returns it to the plot window.
4. Follow Steps 2-3 to open the file pf_2nd_derivative.pro. When you understand how
these functions work, close the files.
Page 4 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
3. Copy and paste useradd.txt to the menu directory of your ENVI Classic installation,
overwriting the existing file. On a Windows platform, this directory is in the following location
(where xx indicates the software version):
C:\Program Files\Exelis\ENVIxx\classic\menu
Page 5 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
2. Restart ENVI Classic+IDL. ENVI Classic looks in the save_add directory for new functions
and automatically loads them when it starts.
Page 6 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
7. From the Spectral Library Plots window menu bar, select Plot_Function > 2nd Derivative.
ENVI Classic calculates the second derivative spectra of all plots and displays the results in the
Spectral Library Plots window.
8. From the Spectral Library Plots window menu bar, select Plot_Function > Normal to return to
the standard reflectance spectrum.
9. When you are finished, select File > Exit from the ENVI Classic main menu bar.
Page 7 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
Copyright Notice:
ENVI Classic is a registered trademark of Exelis Inc.
QUAC and FLAASH are registered trademarks of Spectral Sciences, Inc.
Page 8 of 8
2014 Exelis Visual Information Solutions, Inc. All Rights Reserved. This information is not subject to the controls
of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However,
this information may be restricted from transfer to various embargoed countries under U.S. laws and regulations.