11071
How to Run ENVI Classic in Batch Mode
If you have a full version of ENVI that allows access to IDL (the Interactive Data Language), you can run ENVI in a command line mode called Batch Mode. Batch Mode allows you to perform extensive ENVI processing with no user interaction (i.e., 'batch processing'), or customize your IDL procedures with some of ENVI's functionality. The ENVI functions are executed from IDL by calling ENVI library routines, which are a special set of IDL procedures and functions. However, in order to access these library routines in IDL you must initiate ENVI batch mode by restoring several of ENVI's binary save files and then calling an ENVI command called ENVI_BATCH_INIT. This tip discusses in detail the procedures required to initiate Batch Mode.
NOTE: There are hundreds of ENVI programming routines. For a complete reference guide for these routines please refer to the ENVI Programmer's Guide in the ENVI Help system.
To initiate Batch Mode:
- Start an IDL session
- Restore the 'core' ENVI save files
IDL> ENVI, /restore_base_save_files
- Call ENVI_BATCH_INIT
IDL> ENVI_BATCH_INIT
Note that you can add the NO_STATUS_WINDOW keyword to your call to ENVI_BATCH_INIT to prevent ENVI processing status windows from displaying while in batch mode. Additional control of the status windows can be achieved using ENVI_BATCH_STATUS_WINDOW.
Use a Log File for Extensive ENVI Batch Processing
If you wish to do extensive ENVI processing in Batch Mode without any user interaction, it is recommended that you use a Batch Log file to collect any error or warning messages that may be produced, reducing the risk that the processing could halt while waiting for the user to respond to such a message. To create a Batch Log file, you can use the keyword LOG_FILE to the ENVI_BATCH_INIT routine:
ENVI_BATCH_INIT, log_file='batch.txt'
Accessing ENVI Routines from the Command Line
If you have ENVI+IDL, you have the option of using the IDL command line while you are working interactively in ENVI (see the ENVI Configuration File setting under Misc. System Preferences --> Command Line Blocking). If the IDL command line is active during your ENVI session, then the of your command line processes communicate directly with the concurrent ENVI session. This can be both convenient and problematic. For example, if the IDL procedure you’re running results in a new image band, you could enter this new data directly into the Available Bands List for use in the interactive ENVI session by using the ENVI Batch Mode routine
ENVI_ENTER_DATA. However, if the IDL program you’re executing crashes, then you’ve also crashed the concurrent ENVI session! Generally speaking, we recommend that ENVI Batch Mode processes run in a separate IDL session.
Using IDL Routines in ENVI Batch Mode
When using IDL routines within an ENVI Batch script, an additional compilation command will need to be added:
compile_opt IDL2
Making a Shortcut for Initiating Batch Mode
If you frequently work in Batch Mode, you may find it convenient to put the commands that initiate Batch Mode into an IDL file so that you can initiate Batch Mode with a single command. Here is a simple example:
pro ENVI_BATCH
ENVI, /restore_base_save_files
envi_batch_init, log_file='batch.txt'
end
You could then initiate batch mode by simply calling your shortcut at the IDL command line:
IDL> envi_batch