IRAF paso a paso: 6 - Important tasks


There are some IRAF tasks that are particularly important, as they allow to do a quick assessment of the nature and quality of the data, or to do a variety of operations. Here is a list of the main tasks (Some, such as display and imheader, have already been described in a previous chapter).


Imexamine

The task imexamine allows to do quite a lot of different measurements on an image.
It is one of the more complex tasks, as it has a big number of command keystrokes and task parameters, grouped in psets.
The following table lists just a few of its possibilites:


Keystroke Action
m Statistic of a region around the cursor
r radial profile of the star under the cursor; measures center, FWHM. etc.
h histogram of a region around the cursor
s / e surface / contour plot
c / l column / line plot

Parameters are grouped into 9 pset, which can be edited to change parameter values.
Parameters can also be set interactively using the so called column commands, of the form :ncstat 10 (number of columns used in statistics is set to 10).
imexamine allows to print logical, physical and world coordinates. In the latter case, xformat=%H and yformat=%h return the correct sexigesimal notation for RA and Dec (if the image contains the relevant and correct WCS keywords).

You can also load directly the image in the DS9 display, and the use imexamine. This what they say in the DS9 website:
"Due to the unique relationship between DS9 and IRAF, if you use the imexamine task, you can take advantage of a special feature of DS9. Instead of loading the image from IRAF with the display task, load the image directly into DS9. Then, from the cl prompt, invoke imexamine without a filename. IRAF will ask DS9 for the current filename and use it for analysis. This approach provides serveral advantages over previous methods. First, it will work with compound fits images such as mosaics, data cubes, and rgb images. Second, the image diplays includes true image data and WCS information, not the approximated data from IRAF."


Imedit

The task imedit provides a way to interactively editing pixels values in a image.
A few examples:

It is a useful task for removing interactively cosmic ray events, if the automated tasks fails or produce unsatisfactory results. For instance:

cl> imedit image.fits c_image.fits logfile="imed.log"
edit "image.fits", output is "c_image.fits", all cursor commands are stored into file "imed.log".

cl> imedit image.imh "" cursor="imex.cur" xord=1 yord=1
edit "image.fits" in place (output image will have same name, old image is lost), commands are read from file "imex.cur", set polynomial order to 1,1 when interpolating across bad regions.


Imexpr

The task imexpr is a powerful image calculator.
It accepts complicated operations, with built-in functions and logical expressions. Also values of image keywords may be used.
A few examples are in order:

  1. cl> imexpr " a * (a.photflam/1.0E-18) / (a.exptime/1000) " testu a=mosaic_f336w
    Pixel values are rescaled taking exposure time and the HST photometric keyword into account. Notice the syntax: a.photflam is the values of keyword photflam of image "a". a=mosaic_f336w assigns image mosaic_f336w to variable a.
  2. cl> imexpr " (a > 4000) ? 4000 : a / b " result a=image1 b=image2
    If a > 4000, set pixel value in resulting image to 4000, otherwise output is image1 divided by image2.
  3. cl> imexpr "I+J" plane dims=400,400
    The 500x500 image plane is created, whose pixel values are function of their coordinate.
    Notice: I, J are variables representing the pixel coordinates.
  4. cl> imexpr gauss.fits "1000.*exp(-((I-256.)**2+(J-256.)**2)/(2*50.0**2))" dims=512,512
    Create a gaussian
 
Quiz 1:
A user has created image "llog" with the following operation:
cl> imexpr "100-100*log10(abs((I-256)/20))" llog dim=512,512
However, plotting line #256 ( cl> prow llog 256 ) he sees something strange: the profile is not smooth, but presents marked and regularly-spaced steps. Why?
 
Quiz 2:
A user wants to know whether integer coordinates apply to the pixel center, or to one of its corners. Using the tasks imexpr and display, how can he find it out?

Splot

The task splot is, in a sense, the analogue of imexam for spectral data. It allows to do various types of measurements and processing on a spectrum. Some of the most important cursor keystrokes are:

Keystroke Action
k fit a gaussian to a line profile
d deblend a group or blend of lines into single components; several functional forms are allowed.
f perform arithmetic operations on the spectrum
t fit a function to the spectrum. Might be used to normalize by or subtract the continuum
# select new line or aperture

Sections

Task sections (and the similar but less powerful task files) is very useful to check or produce file and image lists.
It can handle also image sections, as well as the Unix-like notation to restrict the list to a given alphabetical range.
Its typical use is to produce a @file which in turn is passed as input or output to another task.
As usual, a few examples are in order to clarify:

  1. cl> sections *.fits[200,400,200:400]
    Generate a list of images with the image section appended
  2. cl> sections noche![3-9]*.fits[1:10,*] > noche.txt
    Generate a list of images whose name start with noche3 ... noche9, dump list on file "noche.txt". Character "!" tells the task that the [..] string is part of a file name, not an image section.
    Other tasks are able to use this sintax.
  3. cl> sections objs*.fits[100:200,300:400] > objslist
    cl> sections skys*.fits[100:200,300:400] > skyslist
    cl> sections %objs%bck%* > bcklist
    cl> imarith @objslist - @skyslist @bcklist
    Subtract two set of images, ouput images will be 101 x 101 pixels. Notice the use of the substitution character "%".

The task files is similar, but can't use image sections, nor the "![..]" range notation.

In general, it is preferable to use "@files" than image templates (i.e. wildcards) as input to IRAF tasks, as there is no guarantee that image templates are expanded in the same order. For instance:
cl> imarith gal*.fits - back*.fits sub//gal*.fits
"gal*.fits" and "back*.fits" might be expanded in a different order, thus losing the correct pairing between the two images lists.


Hselect

Task hselect can be used to select a subset of images satisfying specific criteria. For instance, we may want to get a list of all images taken in the V filter, or those with exposure time = 0 (biases), or whose title contains the string "NGC 5555". We can also decide which keywords from the header we want to appear in the output list.

As usual, a few examples can better illustrate its usage:

  1. cl> hselect*.fits $I,title * 'FILTER = "V"'
    Generate a list of all images whose keyword "FILTER" is V. The output includes the image file name $I, and its title. Notice that alphanumeric variables must go within quotes.
  2. cl> hselect*.fits $I,title,exptime,filter 'exptime > 59.0' > long.txt
    Generate a list of images whose eposure time is equal or longer than a minute. The output contains the image file name, the image title, exposure time and the filter, and it is saved in the file "long.txt". Before using this task, it is a good idea to inspect the exact name of the keywords (for instance by using imhead l+); for instance in some cases you can find "filt" instead of filter, or "exp-time" instead of "exptime", etc.
  3. cl> hselect*.fits $I 'exptime> 59.0 && filter = "V #57"'
    Both conditions, on exposure time and filter, must be satisfied.
  4. cl> hselect*.fits $I,title 'title ?= "flat"'
    The task looks for all files whose title includes the string "flat" (the ?= operator means contains). This is different from looking for images whose title is exactly "flat". Notice that we put the string "flat" within quotes not to get the task confused.

Other operators are  != not equal,  || or,  >= greater or equal, etc. Type help hedit for more info on conditional expressions, functions and image keywords in general.