IRAF NOTES






General commands

Procedures for reducing ccd images.

a) Obtain a bias frame

b) Flat fields (dome- and sky-flats)

c) Eliminate flats and bias from images

d) Astrometry

e) Check astrometry by using ALADIN


General commands

DSS:  Digitalized Sky Survey

To launch IRAF:

cl> xiraf &l

To display an image:

cl> disp image            (z1 and z2 are minimum and maximum count).

To see a long header

cl> imhead image lo+

To launch ccdred:

cl> imred
cl> ccdred

To delete an image:

cl> imdelete image

To copy an image:

cl> imcopy image new_image

To check for image type:

cl> ccdlist

To make a list file containing all the flat field images:

cl> ccdlist *.imh ccdtype=flat name+ > flats

This file can be used as an @ file for processing.

To recall a previously used command:

cl> ^command

To display an image with minimum and maximum values for pixels assigned:

cl> display image zs- (authomatic scale off) zr-(authomatic range off) z1=... z2=.... fill+  zt=log (to assign a logaritmic scale)

To examine an image use imexamine:  Images  are examined using an image display, various types of plots, and text output.  Commands are given using the image display  cursor and/or  graphics  cursor.   This  task  brings  together many of the features of the IRAF image  display  and  graphics  facilities  with some simple image analysis capabilities.  To generate a radial plot (useful to align images, to find the center of a star) use r.

To put a task in login.cl (for example ccmatch.cl, or ccastrom.cl)

cl> task ccmatch=/home/valerio/IRAF/ccmatch.cl


a) Obtain a Bias frame

Why do you need to take a bias?   The bias is used to remove pre-flash illumination or any residual structure in the DC offser not removed by the overscan region.  Usually 10 bias frames would do the trick (need 25 if read error noise is a cause of concern).

eparam imcombine

input   =        lfc04*.4.fits  List of images to combine                                                      !  Use wildcarts to combine images.
output  =                 zero  List of output images                                                                  !  Name of the bias.
(rejmask=                     ) List of rejection masks (optional)
(plfile =                     ) List of pixel list files (optional)
(sigma  =                     ) List of sigma images (optional)
(logfile=               STDOUT) Log file

(combine=              median) Type of combine operation                                                ! Set to median or average.  Median is better, since eliminates outliers.
(reject =             crreject) Type of rejection                                                                      ! crreject is most used: compute median (need mclip=yes) and eliminate point that are hsigma  above the median
                                                                                                                                                      ! (ignore low pixels).
(project=                   no) Project highest dimension of input images?
(outtype=                 real) Output image pixel datatype
(offsets=                 none) Input image offsets
(masktyp=                 none) Mask type
(maskval=                   0.) Mask value
(blank  =                   0.) Value if there are no pixels

(scale  =                 none) Image scaling
(zero   =                 none) Image zero point offset
(weight =             exposure) Image weights                                                                    ! Important for images with different exposition time.
(statsec=                     ) Image section for computing statistics
(expname=              exptime) Image header exposure time keyword                     ! Set to exptime.

(lthresh=                INDEF) Lower threshold
(hthresh=                INDEF) Upper threshold                                                                    ! You can set a threshold to eliminate bad pixels.
(nlow   =                    1) minmax: Number of low pixels to reject
(nhigh  =                    1) minmax: Number of high pixels to reject
(nkeep  =                    1) Minimum to keep (pos) or maximum to reject (neg)
(mclip  =                  yes) Use median in sigma clipping algorithms?
(lsigma =                   3.) Lower sigma clipping factor
(hsigma =                   3.) Upper sigma clipping factor
(rdnoise=                   0.) ccdclip: CCD readout noise (electrons)
(gain   =                   1.) ccdclip: CCD gain (electrons/DN)
(snoise =                   0.) ccdclip: Sensitivity noise (fraction)
(sigscal=                  0.1) Tolerance for sigma clipping scaling corrections
(pclip  =                 -0.5) pclip: Percentile clipping parameter
(grow   =                   0.) Radius (pixels) for neighbor rejection
(mode   =                   ql)
 

Type:

:go                                                                                                                                             ! To execute


b) Flat field correction

First, we need to examine the flats to determine the size of the overscan region (region with no useful data).  The best way to do that is to use imexamine.
There are a series of useful commands in imexamine:

cl> imexamine image

Commands (type them on the image):

?: help (complete list of commands)
c: column plot
e: contour plot
h: histogram
l: line plot
m: statistics
q: quit (use on both xiimtool and xgterm)
r: radial plot
s: surface plot
x: coordinates
z: show table of count level

The best way to determine the extent of the overscan region is to first use imexamine and do a line plot: that gives an approximate estimate of the overscan.  Then use implot with e (twice) to better define the region.  E.g.

cl> implot
e-e:(fix the region to analyze in more detail)
r: come back to previous plot.

Next step is to obtain a flat field:  you need to combine both dome and sky flats and see "what looks best" (more flat).  Usually sky flats are better...   To combine images use imcombine.  Here there is a typical session:

                                   I R A F
                    Image Reduction and Analysis Facility
PACKAGE = immatch
   TASK = imcombine

input   =        lfc05*.4.fits ) List of images to combine                                                                           ! Images to combine
output  =                 flat ) List of output images                                                                                         ! Output image
(rejmask=                     ) List of rejection masks (optional)
(plfile =                     ) List of pixel list files (optional)
(sigma  =                     ) List of sigma images (optional)
(logfile=               STDOUT) Log file

(combine=               median) Type of combine operation                                                                    ! Use median to avoid overestimating high and low pixels
(reject =             crreject) Type of rejection                                                                                           ! See bias file
(project=                   no) Project highest dimension of input images?
(outtype=                 real) Output image pixel datatype
(offsets=                 none) Input image offsets
(masktyp=                 none) Mask type
(maskval=                   0.) Mask value
(blank  =                   0.) Value if there are no pixels

(scale  =                 mode) Image scaling                                                                                                   ! Multiply  by  the reciprocal of the mode, median, or mean of the specified statistics section
(zero   =                 none) Image zero point offset
(weight =             exposure) Image weights                                                                                             ! It checks in header about the exposure time to weight for the combining median.
(statsec=                     ) Image section for computing statistics
(expname=              exptime) Image header exposure time keyword                                               ! Image  header  keyword  to be used with the exposure scaling and weighting options.

(lthresh=                INDEF) Lower threshold
(hthresh=                INDEF) Upper threshold
(nlow   =                    0) minmax: Number of low pixels to reject                                                         ! The number of  low  and  high  pixels  to  be  rejected  by  the "minmax"  algorithm.
(nhigh  =                    1) minmax: Number of high pixels to reject
(nkeep  =                    1) Minimum to keep (pos) or maximum to reject (neg)
(mclip  =                  yes) Use median in sigma clipping algorithms?
(lsigma =                   3.) Lower sigma clipping factor
(hsigma =                   3.) Upper sigma clipping factor
(rdnoise=                   0.) ccdclip: CCD readout noise (electrons)
(gain   =                   1.) ccdclip: CCD gain (electrons/DN)
(snoise =                   0.) ccdclip: Sensitivity noise (fraction)
(sigscal=                  0.1) Tolerance for sigma clipping scaling corrections
(pclip  =                 -0.5) pclip: Percentile clipping parameter
(grow   =                   0.) Radius (pixels) for neighbor rejection
(mode   =                   ql)

Store the result of this procedure in flat.fits.


c) Eliminate flats and bias from images

To process images you need to use ccdproc, which is a part of the package ccdred in imred.  You may need to eliminate the CCDSEC parameter in the header if there is a conflict with other parameters, like DATASEC.  One way to do that is by typing:

cl> hedit *.fits CCDSEC delete+ verify- update+        (+update is very important, otherwise the parameter won't be edited in the header).

Then we need to do a first pass trough CCDPROC to eliminate bias and interactively determine the section to trim.   This is a list of the parameter to use:

PACKAGE = ccdred
   TASK = ccdproc

images  =        lfc100.4.fits ) List of CCD images to correct
(output =                  pop) List of output CCD images
(ccdtype=                     ) CCD image type to correct
(max_cac=                    0) Maximum image caching memory (in Mbytes)
(noproc =                   no) List processing steps only?

(fixpix =                   no) Fix bad CCD lines and columns?
(oversca=                  yes) Apply overscan strip correction?
(trim   =                  yes) Trim the image?
(zerocor=                  yes) Apply zero level correction?
(darkcor=                   no) Apply dark count correction?
(flatcor=                   no) Apply flat field correction?
(illumco=                   no) Apply illumination correction?
(fringec=                   no) Apply fringe correction?
(readcor=                   no) Convert zero level image to readout correction?
(scancor=                   no) Convert flat field image to scan correction?

(readaxi=                 line) Read out axis (column|line)
(fixfile=                     ) File describing the bad lines and columns
(biassec=   [1028:1040,1:2049]) Overscan strip image section
(trimsec=      [2:1022,5:2047]) Trim data section
(zero   =            zero.fits) Zero level calibration image
(dark   =                     ) Dark count calibration image
(flat   =                     ) Flat field images
(illum  =                     ) Illumination correction images
(fringe =                     ) Fringe correction images
(minrepl=                   1.) Minimum flat field value
(scantyp=            shortscan) Scan type (shortscan|longscan)
(nscan  =                    1) Number of short scan lines

(interac=                  yes) Fit overscan interactively?
(functio=            chebyshev) Fitting function
(order  =                    1) Number of polynomial terms or spline pieces
(sample =                    *) Sample points to fit
(naverag=                    1) Number of sample points to combine
(niterat=                    1) Number of rejection iterations
(low_rej=                   3.) Low sigma rejection factor
(high_re=                   3.) High sigma rejection factor
(grow   =                   1.) Rejection growing radius
(mode   =                   ql)

In the first passage usually you check the linear fit of the overscan to see if it is correct (that's usually the case).   It also help to use implot to determine the size of the overscan (BIASSEC) and that of the portion of the image to retain (TRIMSEC).  The second passage eliminate the flat.  CCDPROC "remembers" what operations have been pursued, so you don't need to edit the parameters for the bias (zero*) in the second passage.   These are typical parameters for the second passage:

PACKAGE = ccdred
   TASK = ccdproc

images  =                  pop  List of CCD images to correct
(output =         reduced_dome) List of output CCD images
(ccdtype=                     ) CCD image type to correct
(max_cac=                    0) Maximum image caching memory (in Mbytes)
(noproc =                   no) List processing steps only?

(fixpix =                   no) Fix bad CCD lines and columns?
(oversca=                  yes) Apply overscan strip correction?
(trim   =                  yes) Trim the image?
(zerocor=                  yes) Apply zero level correction?
(darkcor=                   no) Apply dark count correction?
(flatcor=                  yes) Apply flat field correction?
(illumco=                   no) Apply illumination correction?
(fringec=                   no) Apply fringe correction?
(readcor=                   no) Convert zero level image to readout correction?
(scancor=                   no) Convert flat field image to scan correction?

(readaxi=                 line) Read out axis (column|line)
(fixfile=                     ) File describing the bad lines and columns
(biassec=   [1028:1040,1:2049]) Overscan strip image section
(trimsec=      [2:1022,5:2047]) Trim data section
(zero   =            zero.fits) Zero level calibration image
(dark   =                     ) Dark count calibration image
(flat   =       flat_dome.fits) Flat field images
(illum  =                     ) Illumination correction images
(fringe =                     ) Fringe correction images
(minrepl=                   1.) Minimum flat field value
(scantyp=            shortscan) Scan type (shortscan|longscan)
(nscan  =                    1) Number of short scan lines

(interac=                  yes) Fit overscan interactively?
(functio=            chebyshev) Fitting function
(order  =                    1) Number of polynomial terms or spline pieces
(sample =                    *) Sample points to fit
(naverag=                    1) Number of sample points to combine
(niterat=                    1) Number of rejection iterations
(low_rej=                   3.) Low sigma rejection factor
(high_re=                   3.) High sigma rejection factor
(grow   =                   1.) Rejection growing radius
(mode   =                   ql)

You may need to change the scale by which you look at the images (log instead of linear, for example) if unusually bright pixels are presents.
 


To process images you may alternatively use this set of procedures (but it's better to use CCDPROC):

imstat image[1024:1056,1:2064]  ! this will give the mean value of the  pedestal, for first subtraction
imarith image - pedestal new_image ! to subtract the pedestal
imarith new_image - bias new_image1 ! eliminate bias
imstat flat[1024:1056,1:2064]  ! this will give the mean value of the  pedestal, for the flat
imarith flat - pedestal  ! to subtract the pedestal from the flat
imarith flat - bias ! eliminate bias from flat
imarith new_image1 / flat new_image2 ! eliminate flat
imcopy new_image2[2:1022,5:2047] new_image3 ! to trim the image: you need to find out what are the real section to trim: use implot or imexamine.
 

d) Astrometry

The first thing to do is to align the images by using imalign. In order to do that, you first need to generate a file with coordinates of stars in the reference image.  To find the center of a star use imexamine with the option r (you need to positione the cursor on the star first).  a will give you the column and line coordinates, the final radius used for the photometry, and fitting, magnitude, flux, mean background, peak value of the profile fit, e, pa (in degrees between -90 and +90 with 0 along the axis), the Moffat beta value if a Moffat profile is fit, and three measures of the FWHM.  You can use the coordiantes to write the coordinate file.  Here there is a typical output:

#   COL    LINE   COORDINATES
#     R    MAG    FLUX     SKY    PEAK    E   PA BETA ENCLOSED   MOFFAT DIRECT
 508.37  886.81 508.37 886.81
  50.00  12.72  81633.  10345.   357.1 0.99   -9 6.36     5.32     6.93   5.45

Then use imalign to align and trim the images.  The command looks like:

imalign x1,x2,x3 x1 x1.coords x1.out,x2.out,x3.out

You usually need 10 or more stars to have a good alignment.  Try to choose them in different regions of the image.