GMOS Long-slit Reductions: It's an ADVENTURE!
Rewritten based on experience reducing LMC173-1 February 2025
Some resources:
- The Cookbook.
- In IRAF/gemini/gmos do a "gmosexample longslit"
- But best: The turorials (which is what this is basically modeled on).
Installation
- Just use the gemini 1.16.1 package that comes with the standard NOIRLab
IRAF (or will, come Spring 2025).
Getting Sorted Out
- Download the data. (If the data are still propriatory, be sure to list the program name and enter the key/password in "My data" in the pulldown on the upper right side.)
- Put all of the cals, science, and bias frames in a subdirectory called "Raw"
- Make an observing log. The difficulty is that some header words are in [0] and others are in [1]. This gets around this. Here's a handy script:
makelogs.cl. It creates obsLog.txt and (unlike the manual) retains the keywords.
I found it handy to then write down in a notebook what the pertinent frames were.
- Make input text file lists.
- The major issue is that because of all the MEF stuff it's hard to just
make a list of file names.
- Edit script biasSelect.cl. Creates bias.txt.
- Edit script compSelect.cl Creates flats.txt, arcs.txt, etc.
- Edit script sciSelect.cl Creates science.txt
- Let us imagine that the data consistes of multiple nights of observations of a single star, taken as 3 consecutive spectra with both a flat and an arc.
One should take flats.txt, arcs.txt, and science.txt and create fn1.txt, fn2.txt, fn3.txt....,an1.txt, an2.txt, and3.txt...sn1.txt,sn2.txt,sn3.txt
- ALTERNASTIVELY you can just do a bunch of hand editing
- files S*%.fits%% > arcs.txt
- copy arcs.txt flats.txt
- copy arcs.txt science.txt
- and edit like crazy.
- Or You can also just do something like:
- gemlist "S20150503S" "275-278,280 > bias.txt
Everything all at once
Why, yes, there is a script for doing everything
It will need editing. Below is what it really should say:
- set rawdir="Raw/"
- Make master bias frame:
- gbias @bias.txt Zero rawpath=rawdir$ fl_over+ fl_trim+ fl_inter- fl_vardq+
- Do the basic processing (overscan, trim, and bias subtraction). Note that
how some of the flags interact are...subtle...and so pay attention here.
- unlearn gsreduce
- #Flat
- gsreduce @flats.txt rawpath="rawdir$" fl_bias+ fl_flat- fl_gmosaic-
fl_cut- fl_gsappwave- bias="Zero.fits"
- #Science
- gsreduce @science.txt rawpath="rawdir$" fl_bias+ fl_flat- fl_gmosaic-
fl_cut- fl_gsappwave- bias="Zero.fits"
- #Arc. Reduce AND mosaic it.
- gsreduce @arcs.txt rawpath="rawdir$" fl_bias+ fl_flat- fl_gmosaic+ fl_fixpix-
fl_gsappwave- fl_over+ bias="Zero.fits"
- Do the wavelength solution on the mosaic'd arcs and then transform the arc.
- gswavelength gs//@arcs.txt fl_inte+ fl_addf- function="spline3"
- gstransform gs//@arcs.txt wavtran=gs//@arcs.txt
- implot the resulting "t" frame and make sure everyting is nicely lined up.
For instance, implot tgsblah.fits[SCI] and then :l 150 o :l 350.
- Do the QE corrections for the flat and the science exposures. These
aren't mosaic'd yet.
At this point we need a one-to-one correspondsponce between the
science frames and the arcs. It's time to break things to use the little
text files created above.
If there are three observations and then a
flat and an arc, that works: just make sure you have corresponding lists.
- #QE the science exposure: Need the wavelength frames as reference because the QE is a function of wavelength. Note tha the gqe does take a NY minute or two.
- gqe gs//@sn1.txt ref=gs//@an1.txt
- gqe gs//@sn2.txt ref=gs//@an2.txt
- gqe gs//@sn3.txt ref=gs//@an3.txt
- etc.
- #QE the flats:
- gqe gs//@fn1.txt ref=gs//@an1.txt
- gqe gs//@fn2.txt ref=gs//@an2.txt
- gqe gs//@fn3.txt ref=gs//@an3.txt
- Actually since there's a one-to-one correspondance already, you could
just do the following as long as everything is in the correct order. It's a big if:
gqe gs//@flats.txt ref=gs//@arcs.txt
- Make the flat-field. I don't like interpolating over the chip caps so I
prefer the second of these: fl_fixpix-
Note. At least with the 1200 grating and our high S/N data I don't find that it matters.
- gmosaic qgs//@flats.txt fl_fixpix-
- gsflat mqgs//@fn1.txt FlatN1.fits order=23 fl_over+
- gsflat mqgs//@fn2.txt FlatN2.fits order=23 fl_over+
- gsflat mqgs//@fn3.txt FlatN3.fits order=23 fl_over+
- Reduce the science exposure, mosaic'ing it in the process:
- gsreduce qgs//@sn1.txt flat="FlatN1" fl_over- fl_bias- fl_trim-
- Apply the wavelength calibration. Note the extra "gs" at the start that got added abover:
- gstransform gsqgs//@sn1.txt wavtran=gs//@an1.txt
- gstransform gsqgs//@sn2.txt wavtran=gs//@an2.txt
- gstransform gsqgs//@sn3.txt wavtran=gs//@an3.txt
Extract the spectra and enjoy:
I found that I was much happier doing this within normal iraf using
apall.
- imcopy tgsqgs//@sn1.fits[sci] n1a.fits,n1b.fits,n1c.fits [do this manually]
- imcopy n1*.fits N1.fits reject=crreject
- apall N1.fits with aperture size +/-10, bsample=-50,-15,15:50, t_nsum=20, t_step=50 [otherwise it loses the 1st and 3rd chips], tfunction=spline3, t_niter=3, t_order=3.
- Or do them one by one and combine.
- Do an imreplace N*.ms.fits 0 upper=0
The "standard" gemini way to do this would have been the following. But
I would just ignore everything below this line
- gsskysub tgsqgs//@science.txt
- gsextract stgsqgs//@science.txt fl_inte+ clean+
- imcopy e*obs1.fits[sci] obs1.fits
- imcopy e*obs2.fits[sci] obs2.fits
- imcopy e*obs3.fits[sci] obs3.fits
- scombine obs1,obs2,obs3 MyStarN1.fits reject=avsigclip scale=mode
- splot MyStarN1.fits
At this point you may need to get rid of ridiculous spikes. Try:
- imcopy MyStarN1.fits MyStarN1e.fits
- imreplace MyStarN1e.fits 0 lower=50000
- imreplace MyStarN1e.fits 0 upper=0
So, that sounded good, right? And the above worked pretty well. But what if you have a faint object or only a single 20-minute long science frame?
Chances are its rotten with cosmic rays. You may even have to get rid of these
before you can even find the aperture to do extract something faint.
I'm also not that delighted with their sky subtraction algorithm.
One option if you have multiple, undithered exposures is to use gemcombine
to filter out the crs.
Another alternative is:
seems to be gemcrspec. I used it on my data after I had transformed but
not sky subtracted:
- gemcrspec tgsqgs//@science c//@science
- imcopy cS20210208S0005.fits[sci] t1 [etc]
- There are some very saturated and/or bad pixels.
- imreplace @NewList 5000 lower=5000
- imreplace @NewList 0 upper=0
- apall @NewList
- scombine @NewList//.ms.fits
- gemcombine tgsqgs//@science LMC0551a reject=ccdclip