Skip to content. | Skip to navigation

Personal tools
You are here: Home Telescopes Magellan Instruments MIKE IDL Tools Readme

Readme

This README file describes a package of IRAF tasks written by Jack Baldwin (MSU) for dealing with the tilted slit in MIKE spectra, and also a simple cosmic-ray zapper that works on the MIKE 2D images, before you extract the spectra.

Some of the IRAF scripts call fortran programs, which you will need to compile in advance.

Problems in installing or running these scripts should be addressed to either Nidia Morrell (nmorrell at lco.cl) or Mark Phillips (mphillips at lco.cl).

 

A. TO SET UP THE SOFTWARE PACKAGE:


Copy the "mtools.tar" file to your IRAF home directory and type

 

  • tar xvf mtools.tar

 

This will create a directory called "mike_tools/iraf/" into which the program files will be copied. There are files called "mikecrx.mak", "mikesumx.mak", and "tiltpars.mak" which contain the compile and link commands to generate the fortran executables. Edit the .mak files so that they have the correct path names to your IRAF imfort packages, etc.


Then chmod +x *.mak. Then execute each .mak file by typing

./mikecrx.mak
./mikesumx.mak
./tiltpars.mak


To load the iraf scripts, copy and paste the following into the IRAF cl command line, or install them in your IRAF loginuser.cl file:

This loads the iraf scripts:

mikeproc
mzap
mtilt
mtfit
msum


These tasks all have parameter files, which you should take a look at.

B: USE ccdproc or mikeproc to do the bias overscan, trim, and flatfield corrections.

  

C: REMOVE COSMIC RAYS from the 2D images, using the script "mzap".

 

I R A F

 

Image Reduction and Analysis Facility

 

PACKAGE = clpackage
TASK = mzap

datafile= input file
(thresh = 2.) threshold for cr rejection
(crmin = 50.) min cts for a cosmic ray
(nwx = 5) max width in x to be counted as a cr
(nwy = 2) max width in y to be counted as a cr
(flist = )
(mode = ql)

 

  • This task calls the fortran routine mikecrx.
 
  • Searches for cr splotches that are up to nwy pixels wide in the y direction and < nwx+1 wide in x direction (the x restriction is to make sure they aren't real emission lines). Potential cr's are defined as having data values > crmin, and sticking up by more than thresh times the average of the pixels on either side of the search pattern, checking first in the x direction, and then in the y direction. The cr's are replaced by the average of the pixels to either side in the y direction.
 
  • The logic used in mzapx is very simple (14 lines of code). You can easily modify it if you wish, using the current version as the template for how to get images in and out of memory.
 
  • The input images must be in .imh format by this point. (Sorry... this routine uses imfort, which doesn't seem to work on fits images. You can convert a fits image to .imh format by doing an imcopy --e.g. "imcopy test.fits test.imh")
 
  • Note that this and the other imfort programs in this package work only on images which are of "real" format (i.e., they will not work on raw images which are in "short" format) which should be the case if you have used ccdproc or mikeproc first to do bias overscan, trim, and flatfield corrections.
 

 

D. CALIBRATE THE SLIT TILT


  • Do these steps once per grating setup (separately for the blue and red images).
  • At each point when you are asked for a Th-AR image name, give the name of the 2D arc spectrum (e.g. mb0108)
  • Run "mtilt"

 

PACKAGE = clpackage
TASK = mtilt

image = mr0196 Th-Ar image
(dxmin = 10.) minimum spacing in x
(dymax = 10.) maximum spacing in y
(mode = ql)

  

  • mtilt has you interactively mark the two ends of emission lines using the "k" option of imexam.
 
  • The measurements are written into a file called "imexam.image", where image is the name of the Th-Ar image. If the file already exists, you are given the option of deleting it. If you don't delete it, the program will append new measures to it.
 
  • For a given line, you can start marking at either end in x.
 
  • Do this for arc lines that are scattered over the face of the image... working your way up about every 5th order seems to work pretty well.
 
  • It is good to keep an eye on the graphics window, which shows the fit each time you hit the "k" key. I shrink the graphics window to be a small square in the corner of the screen, and expand ximtool to fill most of the screen so that I can see the whole image at once.
 
  • If you don't like the first fit to a particular line, just don't mark the second point on the line and instead go to some new line a reasonable distance away. The program does not return tilt values unless the new point is within 40 pixels in x of the previous point, and within dymax (default=10.) pixels in y. It also does not return a tilt if the two points are less tha dxmin (default=10) pixels apart.
 
  • Hit "q" to exit imexam.
 
 

 

  • "mtilt" then converts the imexam output to a table of (x,y,tilt), using the fortran program tiltpars.
  • In the mtilt parameter file, the variable dxmin is the minimum x spacing that will be accepted between the the two points you measure on the same arc line. This is to keep you from accidentally measuring the tilts over an unreasonably short baseline in x. Default = 10.
  • In the mtilt parameter file, the variable dymax is the maximum spacing in y for a pair of measurements to be accepted as two measurements of the same line. Default = 10.
  • The output tilt values are given as 40*dy/dx, so that they show the shift in y along the 40-pixel slit length.
  • This is to make it easier to judge whether or not you care about the residuals to the fit.
  • At the end of "mtilt", the lines used and their measured tilts are marked on the image display, and the (x,y,tilt) values are written out in the iraf window.
  • The x,y,tilt) values are also written into an output file called "tilt.image", for example "tilt.mb0108".
  • Now use a texteditor to delete bad points from the "tilt.image" file, if you wish. But sometimes you can more easily weed them out using the maxtilt and mintilt parameters in the "mtfit" task.
  • Now run "mtfit"

 

  

PACKAGE = clpackage
TASK = mtfit

image = mr0196 Th-Ar image
(mintilt= INDEF) minimum tilt
(maxtilt= INDEF) maximum tilt
(mode = ql)

 

  • This calls the non-interactive IRAF fitting routine "surfit", and feeds it the output file of (x,y,tilt) values that was created by mtilt.
  • You must either weed out bad points beforehand, using a text editor, or set the mtfilt parameters maxtilt and mintilt so as to exclude the bad points.
  • The fit coefficients are written to the database directory, for later use by msum.
  • The output file (in the database directory) has a name starting with "tfit", e.g. "tfitmb0108").

 

E. EXTRACT THE SPECTRA

 

  • The actual extraction is done with "msum", which is non-interactive.

 

PACKAGE = clpackage

TASK = msum


datafile= data file

(ref = ) reference image for ap trace

(tfit = ) reference image for tilt fit

(skysub = fit) sky subtraction: none, fit, average

(varianc= no) Generate .var file?

(ron = 3.7) readout noise (in e-)

(eadu = 1.) electrons/ADU

(flist = )

(mode = ql)

 

 

 
  • Set up the aptraces and aperture windows using the usual iraf tasks "aptrace" and "apedit".
 
  • You ***MUST MUST MUST*** use CHEBYSHEV polynomials when you use aptrace. Otherwise, apsum will give crazy answers.
  • BEWARE: If you screw up and use legendre polynomials by mistake, the aptrace output file still claims they are chebyshevs.
  • msum uses the fit to the slit tilts (from step D). In the msum parameter file, for "tfit", enter the name of the arc spectrum that was used to calibrate the slit tile (e.g. mb0108).
  • For "ref", enter the name of the file for which you have previously set up the desired aptraces and apertures windows, using aptrace and apedit. i.e. this does the same thing as "ref" in apsum. If "ref" is blank, the name of the image being processed will be used.
  • msum will handle 0, 1 or 2 sky windows. It may do something crazy if you have more than 2 sky windows...I haven't tried it.
  • The sky subtraction options are "none", "fit" or "average" (same names as used in apsum). However, "fit" actually just does an interpolation from the average of sky window A to the average of sky window B. If you specify fit but give only one sky window, then just the average is used. There are probably lots of ways to enter sky windows that will screw things up... I did not test it very extensively.
  • Each echelle order can have its own set of sky and star windows.
  • The output file is then called "image.ec", for example "mb0108.ec".
  • msum can also produce a variance file (giving the variance in each pixel in the extracted spectrum). The extracted spectrum has a filename in the format "file.ec", and the variance file name is "file.var", for example "mb0108.var".
  • To convert the variance to the 1 sigma noise for a S:N calculation, just take its square root. (The STSDAS task imcalc can do this).
  • To calculate the variance, you must provide approximate values of the readout noise (in ADU) and the electrons per ADU (the default values ron=3.7 and eadu = 1 are probably close enough).
Document Actions