[2] 实验编程 · 2021年8月9日

IDL command line

pros and cons of IDL command line and workbench

There are two primary ways of using IDL: the command line (CLI*) and the Workbench (WB). The CLI allows direct access to the IDL interpreter. The WB is a separate program that sits on top of IDL and provides a slew of organizing, editing and debugging tools for working with IDL.

两种使用 IDL 的主流方法:命令行 CLI 和 GUI。命令行可以直接访问 IDL 编译器,GUI 是架构在 IDL 之上提供一系列组织,编辑调试工具。

CLI 和 GUI 的优缺点如下:

CLI Pros:

  1. Lightweight. 轻量级
  2. Fast. The CLI provides direct access to the IDL interpreter. 速度快

CLI Cons:

  1. Limited shell-like support; e.g., no color syntaxing, command completion or keybinding definition. (However, see rIDL.)
  2. An external editor is needed to develop and debug code. (For many, this may not be a negative.)

WB Pros:

  1. Integrated editor with command completion, color syntaxing, code formatting and code templates.
  2. Projects for organizing files and controlling IDL’s path.
  3. A consistent interface across platforms supported by IDL (Windows, Mac OS X, Linux).

WB Cons:

  1. The WB is built on Eclipse, which is a big, complex Java application. As the size and complexity of an application grows, the likelihood of bugs grows, as well.
  2. the Outline view for jumping between programs in a file, and
  3. the Open Resource dialog for opening files.

参考文献

IDL 批处理

Batch processing with IDL

$ nohup nice $IDL_DIR/bin/idl < in.pro > out.txt 2> err.txt &

in.pro

print, 'Job started'
n = 100
task1, n
;task2
;task3
print, 'Job complete'

task1.pro

pro task1, n
   compile_opt idl2

   if n eq !null then n = 100

   x = findgen(n)
   p = plot(x, /buffer, title='Plot #000')
   p.save, 'plot000.png', resolution=96

   for i=1, n-1 do begin
      si = string(i, format='(i3.3)')
      p.title = 'Plot #' + si
      p.setdata, x + i
      p.save, 'plot' + si + '.png', resolution=96
   endfor

   p.close
end

参考文献论坛参考

mixed batch without window

$ idl <in.pro >out.txt 2>err.txt

in.pro

print, 'job started'
example_envi_batch_status_window
print, 'job complete'

example_envi_batch_status_window.pro

pro example_envi_batch_status_window

compile_opt IDL2

; First restore all the base save files.
envi, /restore_base_save_files

; Initialize ENVI and send all errors
; and warnings to the file batch.txt
envi_batch_init, log_file='batch.txt'

; Open the input file
envi_open_file, 'bhtmref.img', r_fid=fid

if (fid eq -1) then begin
   envi_batch_exit
   return
endif

; Get the dimensions and # bands
; for the input file.
envi_file_query, fid, dims=dims, nb=nb

; Set the pos to calculate
; statistics for all data (spectrally)
; in the file.
pos = lindgen(nb)

; Calculate the basic statistics and
; print the mean.

envi_batch_status_window, /off
envi_doit, 'envi_stats_doit', fid=fid, pos=pos, $
   dims=dims, comp_flag=1, mean=mean

print, 'Mean', mean

; Turn off the status window and do the same

envi_batch_status_window, /off

; Calculate the basic statistics and
; print the mean.
envi_doit, 'envi_stats_doit', fid=fid, pos=pos, $

   dims=dims, comp_flag=1, mean=mean

print, 'Mean', mean

;

; Exit ENVI

;

envi_batch_exit

end

参考文献Executive Commands

A list of other resource

  1. 剑桥大学 Vasily BelokurovIDL教程
  2. Developer of rIDL & IDLdocMichael Galloy
  3. Coyote’s guide to IDL