IDL Notes

Set NaN values:
a = !values.F_NaN
b = !values.D_NaN

Test for the existence of a file or directory:
test = FILE_TEST(filename) (returns 0 if file does not exist)

Opening files to write into:
OPENW, unit, filename
PRINTF, unit, stuff
CLOSE, unit

Open files for reading:
OPENR, unit, filename, /get_lun (/get_lun option will assign the unit)
READF, unit, var (type of 'var' must be defined first)
CLOSE, unit

Calls an external UNIX command:
SPAWN, 'command'

Execute one or more IDL statements contained in a string and returns true (1) if sucessful:
example: ret = EXECUTE('plot, indgen(100)')

Plot postscript files. The following makes a color eps file with postscript hardware fonts (useful for changing text in Latex later)
ps_open, outfile, /color, /encapsulated, /ps_fonts
ps_close (when done plotting)

Saving plot window into a PNG image file:
Use keyword true=1 to save in color
write_png, img_file, tvrd(true = 1)

Declaring functions
When functions have not been compiled, calling them with keywords will result in a syntax error. Use FORWARD_FUNCTION to declare those variables are functions:
FORWARD_FUNCTION, name1, name2, ....

Compile routines
To force IDL to compile user-written procedures even if they are already defined (use the keyword /compile_full_file to compile the whole file, not just the function given):

RESOLVE_ROUTINE, name, /compile_full_file

Find the same elements in two idl arrays.
match, a, b, suba, subb
suba contains the indices in vector 'a' with a match in 'b'.

Astronomy Related IDL

Many of these procedures require the IDL Astronomy Library available from GSFC.

Get a FITS header value:
val = SXPAR(header, 'value')

Add/modify FITS header files:
SXADDPAR, header, name, value

Find the pixel value corresponding to an ra and dec in a FITS file:
ADXY, header, ra_d, dec_d, x, y
(ra_d and dec_d should be in decimal degrees)

Returns the string for the sun symbol that is used often in astronomy:
sunsymbol()

IRAF/PyRAF notes

To output help file on a topic into postscript:
help topic device=ps > topic.ps