idl examples
Here are some example commands that could be used to analyse images
and produce plots in IDL. The IDL commands that you type are in red font, Unix commands are in green font and my coments are in blue font.
You may want to work through the IDL tutorials linked on our website here:
http://www.star.bris.ac.uk/links.html#webtut
You can cut and paste from this webpage into a terminal window.
First of all, lets make a directory (folder) called
telescope_data to store our data.
mkdir telescope_data
go into this directory
cd telescope_data
copy some files to here
cp ~rahm/junk/telescope/*.FIT .
Start IDL
idl
IDL Version 6.0 (linux x86 m32). (c) 2003, Research Systems, Inc.
Installation number: 65539.
Licensed for use by: STARLINK: University of Bristol
Read the contents of the image star1b.FIT in an
array called a
IDL> a=readfits("star1b.FIT")
% Compiled module: READFITS.
% Compiled module: SXPAR.
% Compiled module: GETTOK.
% Compiled module: VALID_NUM.
% READFITS: Now reading 765 by 510 array
% Compiled module: SXADDPAR.
display a as an image
IDL> tvscl,a
print information about the array a
IDL> help,a
A UINT = Array[765, 510]
Display the array a as a surface plot.
IDL> shade_surf,a
Bring up the IDL help manual
IDL> ?
% Unable to determine the version of Acrobat Reader in use on this system.
One
reason for this would be if your acroread command (/usr/bin/acroread) is
a
locally supplied wrapper in front of the Adobe supplied script. IDL will
therefore assume Acrobat Reader version 8. If this assumption is wrong,
you will get an error 30 seconds after Acrobat Reader starts. To
eliminate
this message, and/or to explicitly specify the version of Acrobat Reader
in use, please consult the file
/usr/local/rsi/idl/help/idl_acrobat_plugin.
config.
Fit a two dimensional gaussian to the array a
IDL> z=gauss2dfit(a,params)
% Compiled module: GAUSS2DFIT.
% Compiled module: GAUSSFIT.
% Compiled module: POLY_FIT.
% Compiled module: CURVEFIT.
% Program caused arithmetic error: Floating underflow
Print fit parameters,
A[0] = A0= constant term
A[1] = A1= scale factor
A[2] = a = width of Gaussian in the X direction
A[3] = b = width of Gaussian in the Y direction
A[4] = h = center X location
A[5] = k = center Y location.
A[6] = T = Theta, the rotation of the ellipse from the X axis in
radians, counterclockwise.
IDL> print, params
110.833 1805.78 20.4058 19.2199 214.416
412.040 0.00000
Look at gauss2dfit manual page for full info on what
each number is, but the 3rd and 4th numbers are the Full Width Half
Maximum (FWHM) of the gaussian that is the best fit to the data.
Calculating mean and standard deviations
Calculate the mean of array "a" and store it in a
variable called "b".
IDL> b=mean(a)
% Compiled module: MEAN.
% Compiled module: MOMENT.
print the mean value
IDL> print,b
122.245
You can combine IDL commands into one line. Eg, to
calculate and print the standard deviation of array "a"
IDL print, stdev(a)
123.504
Note, for this image, which contains an object, then the standard deviation is
bigger than the mean! This should not be the case for dark frames. If it is,
something is badly wrong!
Plotting
First of all, in Linux (outside of IDL) use an
editor to put the data into a two column file, eg
gedit temperature_vs_darkcurrent.dat
and the file should look like this:
15 300
10 200
5 100
0 90
Then when you are done, you can read it into idl.
IDL> iplot, temperature_vs_darkcurrent.dat
% Compiled module: FILEPATH.
% Compiled module: PATH_SEP.
% Loaded DLM: PNG.
% Compiled module: XMANAGER.
% Loaded DLM: IPTOOL.
% Compiled module: GET_SCREEN_SIZE.
% Compiled module: REVERSE.
% Compiled module: CVTTOBM.
% Compiled module: IDENTITY.
% Compiled module: STRSPLIT.
% Compiled module: UNIQ.
The plot appears in a window. You can now edit the plot, label the
axes and, using the "export" item in the file menu, save it as a
jpeg.
You can also use the command
IDL> isurface,a
to look at a two dimensional array, from lots of
directions.
Quit out of IDL
IDL> exit
Remember, by default, idl does not save variable
between sessions. so you will need to open and read the image in again
if you have closed idl.
If you are doing something very hard, with dozens of variables, idl
can "save state" so you can start again where you left off. Let me
know if you will need to do this.
Rhys Morris
Last modified: Wed Nov 4 15:37:11 GMT 2009