Debiassing the raw .sdf images

pamela debiases each raw image by subtracting a master bias image scaled to match the average count value on an unilluminated part of the image. We must therefore create a master bias image, and then also decide which bit of the CCD image to use to calculate the bias level for each image.

Creating a master bias image

First, identify the bias images from your set of observations. Now inspect them all to see if they look like they should do (i.e., they contain only random noise, and there are no patterns or significant gradients). There are several ways of looking at the images:

gaia: You can display an image in two dimensions using the starlink general-purpose image display tool gaia. This tool has many useful features.

pplot: You can use the pamela command pplot, which produces one-dimensional plots of the average value of the rows or columns in am image. If you type pplot then it will prompt you for the filename and image limits. Alternatively, if you want to plot of the average values of the columns of, e.g., the image r352419.sdf, type

pplot r352419 dirn=y min max min max

where the min max min max tells it to use the whole range in x and y (if you only want to look at part of an image, then specify the pixel co-ordinates instead of min max min max).

loopdisplay: You can use the pamela command loopdisplay, which displays a series of images. If you want it to pause for n sedconds between each image, then the command is

loopdisplay -h n [specify_the_file(s)]

You will first need to define a display for figaro by typing idev and putting xwindows at the prompt. Then run the figaro command image and set up the display parameters.

Creating the master bias image: Once you have identified the bias images which look good, combine them together to make a master bias image by median-stacking: taking the median of the values in different images for each pixel. This is done using the starlink package figaro command medsky, which requires a list of files (without the .sdf extension) as input:

(rm bias.lis)
foreach file ([bias images].sdf)
echo $file:r >> bias.lis


ls bias*sdf | sed -e 's/\.sdf//' > bias.lis
and then
medsky bias.lis masterbias scaled=false

This creates a median-stacked master bias frame called masterbias.sdf

Looking at and specifying certain parts of an image

You can get statistics on a particular part of an image using the starlink package figaro command istat:

istat [file] [y-low] [y-high] [x-low] [x-high]

(where you should replace the square-bracketed things with the appropriate values). This can run into problems with ESO files, as these can contain stange axis data. In this case, remove the offending bits of each image using the starlink package figaro command delobj:

foreach file (*.sdf)
delobj $file:r".axis"

Instead of istat, you could use the pamela command picstat, which requires you to first generate a file specifying the subset(s) of the image you are interested in. A good name for this file is bias.reg and it should contain the x-limits and y-limits of each region(s) you are interested in, using the format:

21 351 4145 4200

Once you've made this file you can run the picstat command:

picstat [file] bias.reg

Now you need to define a part of each image (including science frames, flat fields etc) which is not illuminated, so the counts in the pixels are due only to the bias level. Such areas can usually be found at the top or bottom (or sometimes the side, away from illumination through the slit) of an image. Look at some images and decide which bit to use, then specify this in a bias.reg file (see above). If you run picstat using this file, you will get out statistics on an image. One of the statistics is sigma, which gives the readout noise affecting the observations. This value will be used at a later point.

Debiassing (at last)

Now you have created a master bias image and defined bias regions in each image, you can debias all the images using the pamela command debias:

debias masterbias bias.reg [files*.sdf]