Dealing with FITS files

It is easy to I/O FITS files into IDL, MIDAS, C programs or other packages. See here a few commands on how to deal with them in IDL:

Read fits table into a variable, which automatically becomes an array of structures:

IDL>   x = mrdfits('mytable.fits',1)
The array x has as many elements as the table has rows (e.g. 300, see below). Every array element x[i] is now a structure variable with tag names equal to the column names in the FITS table. You can see the structure by invoking e.g.
IDL>   help, x
X   STRUCT  = ->  Array[300]

IDL>   help, x, /structure
** Strcuture <82fe1dc>, 19 tags, length=136, data length=136, refs=1:
  NR               LONG
  R_A              DOUBLE
  DEC              DOUBLE
  MC_Z             FLOAT
  ...        
You can access every individual element in your IDL program as usual, e.g. print out the R_A value for object #154 in the table:
IDL>   print, x[154].r_a

In MIDAS just use INDISK/FITS and OUTDISK/FITS to convert between FITS and MIDAS tables, and then have all MIDAS tools available.


Back to COMBO-17 index page


Last update Feb 25, 2003, CW