[ENVI secondary development] About the use of Batch mode and ENVI_DOIT


1. What is batch processing?Good at

        Batch processing (Batch), as the name implies, is to process an object in batches. When learning Windows, you may come across a file with a .bat extension. This file contains a series of DOS commands. When running this bat file, these dos commands will be carried out in sequence, and there is no need to manually enter them in the command window over and over again. This is the advantage of batch processing.

        In ENVI, we often need to use a series of commands repeatedly, we can combine these commands and save them as an IDL batch file for our future use

2. IDL batch file

        A batch file is a file ending in .pro that includes a series of IDL commands. Running this type of file is exactly the same as the command typed in by the user in the IDL command line.

For example, when drawing a sine curve graph in the IDL command line, you can use the following commands to achieve:

IDL>arr = findgen(200)
IDL>data = sin(arr/20)
IDL>window,2,xsize = 400,ysize = 300,title = 'Plot Sin'
IDL>plot,data

If you need to call the above code multiple times, you can use batch processing mode, and save the following lines of code in a batch file (note: no keywords such as PRO and END are needed in the batch file )

 

data = sin(arr/20)
window,2,xsize = 400,ysize = 300,title = 'Plot Sin'
plot,data

Assuming that the batch file is in the C:\temp directory and the name is batch_plot.pro, we can call it from the command line by the following method

IDL>cd,'C:\temp'
IDL>arr = findgen(400)
IDL>@batch_plot

3. ENVI batch mode

Running ENVI in batch mode allows users to use ENVI in command mode . This ability is very useful in the following situations:

(1) The user mainly uses IDL for work but occasionally needs to use ENVI functions;
(2) The user wants to create a customized application that mixes IDL code and ENVI functions;
(3) The user wants to perform a large amount of ENVI processing without manual intervention .

        There is no difference between ENVI in batch mode and normal mode, except that ENVI functions are executed through a series of specific function libraries. In order to use these functions, you must first restore them to IDL memory. Therefore, in order to obtain the ENVI library functions correctly, it is necessary to understand the structure of the ENVI program:

        ENVI functions are scattered in about 50 small IDL save files. These binary files include data and compiled programs. These save files are stored in the Save directory under the ENVI installation path. The ENVI core save file includes the basic functions of ENVI, dynamic operation functions and internal variables required for ENVI operation. These files are stored in the C:\rsi\idlxx\products\envixx\save directory on a typical Windows PC.

(1) ENVI batch initialization:

      ENVI batch initialization generally includes the following steps:

  1. Set File ->Preferences->Miscellaneous->Exit IDL on Exit from ENVI->No on the main menu bar of ENVI
  2. compile_opt idl2; strict compiler requirements
  3. ENVI, /restore_base_save_files; Load core save files
  4. ENVI_batch_init; Initialize batch

(2) Leave ENVI batch mode:

        Just use the ENVI_BATCH_EXIT command. The way ENVI_BATCH_EXIT exits batch processing is the same as that of exiting ENVI by selecting File-> Exit on the ENVI main menu. Similarly, after exiting ENVI with this command, the license used during ENVI period is also released.

4. Mixed batch processing mode

ENVI is always an IDL program. If the user uses the IDL period of running ENVI, the user will be able to access all ENVI programs and functions. This state is usually called mixed batch mode .

advantage:

Users can use ENVI-specific library functions without initializing batch mode

Simulate the final environment of code execution

Disadvantages:
If the IDL program crashes, then the current ENVI environment will crash completely

5. About ENVI_Doit

When calling the ENVI space processing function, there are the following differences : (This is the key point struggle)

If you are in batch mode, you need to use envi_doit,'envi_stats_doit' when calling

In the mixed batch mode, envi_stats_doit is used directly when calling
=================================== ======

 Reference article:

 http://blog.sina.com.cn/s/blog_701286210100u95t.html

 

Please indicate that the reprint is from http://blog.csdn.net/dongyu1009/article/details/9149085

 

 

Guess you like

Origin blog.csdn.net/dongyu1009/article/details/9149085