Next: 3.2.3 DX
Up: 3.2 Data visualisation
Previous: 3.2.1 gnuplot
[ID index][Keyword index]

### 3.2.2 IDL

IDL is much more powerful and flexible than gnuplot, and has a correspondingly longer learning curve. It's never been accused of being elegant, but with only a bit of headbanging, I've always managed to get it to do what I wanted (I've always seen it as reminiscent of Fortran in this respect).

Several missions have used IDL as the language in which they have written their data-analysis software, and Starlink is currently experimenting with providing IDL interfaces to important Starlink applications, which is possible because IDL can link to codes written in languages such as Fortran or C. IDL is moving towards being a core facility at Starlink sites.

IDL displays data in arrays as part of a generic set of array manipulations. For example, the data in the file `gausssine.dat` was produced by the following sequence of IDL commands:

```x=(findgen(64)-32)^2
d=fltarr(64,64)
for i=0,63 do d(i,*)=sqrt(x+(i-32)^2)
a3=exp(-(d/15)^2)
s=sin(findgen(64)/63*5*3.141592657)
s2=s#s
m=s2*a3```
The function `findgen(N)` returns a float array (indexed from 0 to ) in which the value of each element is the same as its index; performing an arithmetic operation such as subtraction or exponentiation on an array performs it on each element of the array; `fltarr` declares an array of floats of the specified dimensions; the array reference `d(i,*)` refers to the entire `i`'th row of `d`; the operator `#` forms the direct product of the two vectors. The result of this is to set `d` to be an array where each element is the euclidean distance from element `(32,32)`[Note 11].

Once we have the data in the array `m`, we can produce a surface plot with `surface,m`, and then go on to annotate it, rotate it, shade it, contour it, with the large collection of options and parameters to the `surface` command. We can produce PostScript output with the following sequence of commands:

```  !p.font=0             ; use postscript fonts rather than IDL outlines
set_plot, 'ps'        ; use the postscript output driver
device, /encap, filename='gausssine-idl.eps'
; produce encapsulated postscript
surface, m
device, /close        ; close the file
```
This produces the EPS file shown in Figure 2. A minor, but persistent, irritation with IDL is that, although its input and output facilities are as flexible as, say, Fortran's (which they closely resemble), it doesn't come with a function for dealing with the common case of data printed out in columns (the only case gnuplot naturally deals with). Fortunately, such a function is not only easy to write, but a useful example, too. See Appendix A.8.

 Figure 2: File gausssine.dat, displayed with IDL

IDL comes with rather good manuals, the reference parts of which are available on-line by typing `?` at the IDL prompt.

See appendix B of SUN/55 for a description of how to import data in the Starlink NDF format into IDL.

Next: 3.2.3 DX
Up: 3.2 Data visualisation
Previous: 3.2.1 gnuplot
[ID index][Keyword index]
Theory and Modelling Resources Cookbook