Masking pixels with ARDMASK

CCDs often have dodgy columns or pixels which are usually immediately apparent when you look at the images they produce. A lot of the time these will not cause any problems because the algorithms decribed in these pages are tuned to avoid bad values (due primarily to cosmic rays). However, sometimes you need to mask out pixels which fall in a particularly important place or whose values are untrustworthy but similar to those around them.

The starlink way of defining which pixels are bad is the ARD language, in which regions of pixels are defined using simple text files and then masked using the ardmask command. This is mentioned in my instructions for creating flat field images here.

The datafile needed for the pamela reduce command (see the section on automatic extraction) includes a line where a one-dimensional ardmask text file can be specified to apply to the sky regions. If you have a dodgy column in the extraction region then you'll have to put up with it or try to change the spectrum extraction region so it no longer has bad columns in. If you mask the whole column then the summing of each row will probably fail, leaving you with no extracted spectrum.

Creating text files defining masks

Parts of a one-dimensional image (i.e. a spectrum) can be masked using a text file like this:


where two masks are defined: one between pixels [pixel-1] and [pixel-2] and one between pixels [pixel-3] and [pixel-4]. An equivalent syntax is:

LINE([pixel-1],[pixel-2]) .OR. LINE([pixel-3],[pixel-4])

Parts of a two-dimensional image can be masked in many ways. Here you must have a DIMENSION(2) line and then one or several of the lower lines in which the arguments are given in pixels:

RECT ( [x-low] , [y-low] , [x-high] , [y-high] )
CIRCLE ( [x-centre] , [y-centre] , [radius] )
PIXEL ( [x-value] , [y-value] )
ROW ( [y-value] )
COLUMN ( [x-value] )

There are also logical operators such as .AND. and .OR. and .NOT. If you give several commands on new lines then it is asssumed that they should be connected with an .OR. The .NOT. operator is useful if you want to define a good region and mask everything else, in which case you could make a text file like this:

.NOT. RECT(100,250,300,800)

The ARD language and the ardmask command can do many more things than this, including masking images in right ascension and declination etc. These functions are covered in the documentation (SUN/183).