IDL Tutorial Day 1 Dt: 1 Jun 21 By: Suman Panda email: sumanpanda81@gmail.com ----------------------------------------------------------- Introduction to IDL InteractiveDataLanguage Macintosh Proprietary software distributed by Research Systems, Inc. of Boulder, CO now a division of Kodak. Grew out of programs written for analysis of data from NASAmissions such as Mariner and the International Ultraviolet Explorer.Oriented toward use by scientists and engineers in the analysisand visualization of multi-dimensional data sets. Platform Independent: Unix, linux, Windows, To enter idl type sswidl in your working directory. Few Common IDL shortcuts: ctrl+c : abort exit/ctrl+d :exit out of IDL not case sensitive Comment character is ; (semi­colon) for longer lines use continuation character $ Session help: help To copy and paste in terminal: ctrl+shift+c,ctrl+shift+v IDL> a = 3 ; assignment statement ; semicolon is used for comments IDL> print, a + 4 ; built­in print command 7 IDL>print, a + 4. 7.00000 IDL> print, a + 4D ; double precision 7.0000000 IDL>print, a *1e­9 ; scientific notation 3.00000e­09 Array Manipulations Array indexing starts at 0. Some examples; IDL> a=[1,2,5,7,8] IDL> print,a 1 2 5 7 8 IDL> size(a) 1 5 2 5 IDL> n_elements(a) 5 IDL> a[1:3] 2 5 7 IDL> b=fltarr(4) IDL> help,b B FLOAT = Array[4] IDL> print,b 0.00000 0.00000 0.00000 0.00000 IDL> b=indgen(4) IDL> print,b 0 1 2 3 IDL> b=findgen(4) IDL> print,b 0.00000 1.00000 2.00000 3.00000 also:bindgen(), lindgen(), findgen(), dindgen(),cindgen(), dcindgen(), uindgen(), ulindgen()sindgen() IDL> print,fix(b) 0 1 2 3 IDL> c= fltarr(4,2) IDL> help,c C FLOAT = Array[4, 2] IDL> size(c) 2 4 2 4 8 ; dimensions 1st 2nd data type total elements IDL> n_elements(c[0,*]) ;number of rows 2 IDL> n_elements(c[*,0]) ;number of columns 4 IDL> print,c 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 IDL> c=findgen(4,2) IDL> print,c 0.00000 1.00000 2.00000 3.00000 4.00000 5.00000 6.00000 7.00000 IDL> min(c) 0.0000000 IDL> max(c) 7.0000000 IDL> total(c) 28.000000 IDL> mean(c) 3.5000000 IDL> mean(c,dimension=1) 1.5000000 5.5000000 IDL> help,c C FLOAT = Array[4, 2] IDL> c[2,1]=10 IDL> print,c 0.00000 1.00000 2.00000 3.00000 4.00000 5.00000 10.0000 7.00000 IDL> print,c[sort(c)] 0.00000 1.00000 2.00000 3.00000 4.00000 5.00000 7.00000 10.0000 IDL> c[2:3,0:1]=20 IDL> index=where(c eq 20) IDL> print,index 2 3 6 7 IDL> c(index) 20.000000 20.000000 20.000000 20.000000 IDL> in=where(c lt 10) IDL> c(in) 0.0000000 1.0000000 4.0000000 5.0000000 also:eq, ge, gt, lt, le Run Trial.pro