Introduction To IDL PDF
Introduction To IDL PDF
Introduction to IDL
8.287J-12.410J: Observational Techniques of
Optical Astronomy
Fall 2001
Getting Started
IDL (RSI's Interactive Data Language) has been installed on Athena for student use with this course. This
document explains how to access IDL from any Athena (Sun) workstation and outlines the basic commands
to be used in IDL. This short tutorial only scratches the surface of the capabilities of IDL, but will give you
enough background to run the tasks for this class.
Start IDL
To load IDL, the following commands need to be given (we suggest doing this in a separate xterm):
athena% idl
resulting prompt:
IDL>
Commands in IDL
In IDL single quotes are used to denote strings.
To access a Sun command outside of IDL, for example, to find out what directory you are located in type:
IDL> $pwd
The $ tells the computer that the command is to be run outside of the IDL interface.
http://web.mit.edu/12.410/idl_libs/old/Sources/IntroIDL1.0.html 1/3
25/08/2017 Introduction to IDL
Ctrl-q returns the cursor to normal function if you accidently hit Ctrl-s
Ctrl-c will essentially kill the process you are running, however, after using Ctrl-c you want to make sure
IDL is not stuck in the middle of a procedure. You do this by resetting IDL to the main level:
IDL> retall
This means "return all". Whenever things look weird in IDL, type retall.
Displaying an image
IDL has a bunch of really useful tools for image display and processing. We are going to start with simply
displaying an image and playing with the display scale. We have written tools to help you with the data
analysis for your projects which will be covered in more detail later.
Fits files have at least two pieces of information in them, (1) the image itself and (2) supporting information
about the file, called the header. This command, readfits, tells IDL to read the fits file into a floating point
array called "image" and to read the header of the file into a string array called "header".
slide_image displays the image with a double window, the window on the left shows the full image at low
resolution while the image on the right shows the full resolution of the image with scroll bars so you can
move around on the image.
You may also want to know what the minimum and maximum values of pixels in the image. To do this you
can use a few handy functions called min and max which gets this information out of the image array.
IDL> minvalue=min(image)
IDL> maxvalue=max(image)
In this case, max is called a keyword for the function "min" and allows you to get both values you want with
one command. This says, get the minimum value of the array "image" and put that value into a variable
http://web.mit.edu/12.410/idl_libs/old/Sources/IntroIDL1.0.html 2/3
25/08/2017 Introduction to IDL
called minvalue. Also, put the maximum value of the array into a variable called maxvalue.
Example:
Another useful thing to know is what type (integer, float, string etc) the variable you are interested in is. You
can find this out by typing help and the variable name:
You can display the image with different parameters, such as from the minimum to maximum values by
doing the following:
Put the image into another array so you can use the original again if you want to play around with different
scaling parameters (min and max are the minimum and maximum of the display, not by definition the min
and max values themselves). Then redisplay the image.
If you have want to clear a window you can either close the window to get rid of it or type IDL> wdelete
There are a few ways to read a file into IDL, the simplest is described here, other ways will be described as
needed. This method assumes the file is column delimited. This is a handy tool called readcol which will
read information from a file based on the information you define and ask for. readcol assumes all the values
in your file are floating point unless you tell it otherwise.
If you want to read a string you need to define the array first:
IDL> array1=''
This tells IDL to open the file called filename and to read all the lines that have three columns, where the
first is a string and the second two are floating point numbers.
Help menu
If you want to know more about a command or want to see if a command exists to do something type a
question mark at the prompt.
IDL> ?
This will bring up an interactive help window which will allow you to search in either the index or contents
of IDL's online help book.
http://web.mit.edu/12.410/idl_libs/old/Sources/IntroIDL1.0.html 3/3