This is a brief guide to the IRAF task L.A.Cosmic which was created by Pieter van
Dokkum. This task removes cosmic rays from astronomical images via a
Laplacian algorithm. In my personal opinion, this program works REALLY
well.
Before relying on this webpage, you should first consult the
official L.A.Cosmic webpage at http://www.astro.yale.edu/dokkum/lacosmic/.
There you can download the program itself, get a copy of the original publication on
L.A.Cosmic, and view notes to users, and parameter settings.
First of all, I want to clarify that I had nothing to do with the creation of this program... the only thing I have made is this webpage, which I hope will serve as a resource for those who need an introductory guide to this process to help them along. The basic steps can be found at the L.A.Cosmic webpage, in the Notes for Users section. I am only relisting some of the steps found there, and adding my own rewording and personal notes.
The first thing you will have to do is set up an IRAF account, as L.A.Cosmic
is an IRAF (or cl) program. Go to the official L.A.Cosmic webpage (in the
'Download' section) and
download the program to your computer. If you are doing imaging, you
will need the imaging version of the program. If you are doing spectroscopy,
you will need the spectroscopy version. The 'download' will consist of
copying the text that makes up the program, and saving it as a text file to be
used as a program in IRAF... in otehr words, save the text as a file in the
form [name].cl
Label it something easy, for example: lacos_im.cl or lacos_spec.cl and put it
in your IRAF directory for safekeeping. You can technically store it
anywhere, as long as you tell IRAF where it is located, but hey, I like to
keep things organized.
At the IRAF or cl prompt, go into the stsdas package by simply typing
stsdasThen use the following command to register the task in this package in IRAF:
task lacos_spec=[location]/[filename].clOf course, [location] refers to where the file is locted, and the filename.cl is the complete filename. Also, if you are using the imaging version of L.A.cosmic, you will substitute 'lacos_im' for 'lacos_spec' after the task parameter. Here is an example of the full command:
task lacos_spec=/usr/usrs/pjcigan/iraf/lacos_spec.cl
From the stsdas package, type
lacos_[spec or im] [input scan] [output scan] [desired name of bad pixel mask]The input scan, obviously, is the name of the scan you wish to clean.
Here is an example of the all-in-one-line command:
lacos_spec scan0001.fits scan0001.clean.fits scan0001.badpix.fits
Many people like to use the all-in-one-line command way to run a task in IRAF. I, personally, always use the 'epar [task]' method. When you type
epar lacosyou will get the following list of parameters:
I R A F Image Reduction and Analysis Facility PACKAGE = stsdas TASK = lacos_spec input = scan0001.fits input spectrum output = scan0001.clean.fits cosmic ray cleaned output spectrum outmask = scan0001 output bad pixel map (.pl) (gain = 2.) gain (electrons/ADU) (readn = 6.) read noise (electrons) (xorder = 9) order of object fit (0=no fit) (yorder = 3) order of sky line fit (0=no fit) (sigclip= 4.5) detection limit for cosmic rays (sigma) (sigfrac= 0.5) fractional detection limit for neighbouring pixels (objlim = 1.) contrast limit between CR and underlying object (niter = 4) maximum number of iterations (verbose= yes) (mode = al)You can set all your parameters here, then type ':go' to run it. The task takes quite a while to finish, so don't worry if it isn't spitting out images within a few minutes.
The 'niter' parameter determines how many passes the program will make at removing cosmic rays for a single scan. The more iterations you use, the more cosmic rays will be thrown out. Each successive iteration will find fewer and fewer because of this. Three to four iterations should be plenty for most purposes. And remember: your final scan will be cleaner if you use more iterations, but it will also take a lot longer to run.
Last Updated February 23, 2005