Triplespec

WARNING: as of 9/29/09, I have discovered a number of inadequacies / holes in the pipeline. You can't really follow these directions straightforwardly towards a final reduced product. I'm working on fixing that.


Update 2/2/2012: I fixed a bunch of it! The example should be a little more straightforward to follow than my directions, which really didn't make clear what was a variable and what was a name

Below is code using IRAF to create a full 2D wavelength solution for TripleSpec data. It also rectifies spectral lines to be vertical.

Caveats:
  • The calibration step does not account for atmospheric absorption dips, e.g. those around 2-2.1 microns (this is a limitation of IRAF - the sensitivity funciton has to be a functional fit, and even very high-order spline fits fail on those)
  • Telluric correction is not done carefully. To really do it right, you need a high-resolution absorption spectrum and you need to deconvolve narrow lines to see where they fall on the absorption spectrum. This might not be possible at all; the closest we can get is probably taking the TSPEC spectrum of the A0 calibrator and using that as our transmission spectrum.
  • This code has only been tested for one set of data.
  • I'm a beginner at writing IRAF scripts so the code may not be fully robust
  • I'm not sure how to get accurate error estimation. In particular, I don't know how well poisson statistics are conserved when pixels are resized.
  • The pipeline currently only extracts JHK orders. It is certainly possible to add in an extraction of the other orders; if there's enough demand / incentive I'll do it.
  • Unless you understand IRAF, there are probably parts of this 'manual' that are thoroughly inadequate. Again, with adequate demand/incentive, I can produce a better set of instructions with a few days of work.


Description of pipeline process:
  1. Copy each order of a reference star exposure into an individual image
  2. Copy each order of the target observations into individual images
  3. Use a (prefereably starless) image to extract the wavelength calibration with identify (INTERACTIVE)
  4. Use a star image to extract the slit curvature with identify (INTERACTIVE)
  5. Use fitcoords to create a transformation to apply to the image to rectify the lines and slit curvature (INTERACTIVE)
  6. Apply rectification to data
  7. Use standard to compute the calibration to convert data units to flux density units (INTERACTIVE)
  8. Compute sensitivity function with sensfunc (INTERACTIVE)
  9. Apply sensitivity function

Example position-velocity diagram extracted from pipeline-reduced product:
Example "poor-man's IFU" data cube: W51 Data Cube
Slices look like this:

Instructions for use:
  1. pour yourself some triplesec
  2. Download these files:
  3. cp /path/to/bpm.fits . (bad pixel mask)
  4. task pipeline_jhk=/full/path/to/pipeline_jhk.cl (load pipeline code)
  5. !ls reference_star_filename* | sed 's/\.fits//' > refstarlist
  6. pipeline_jhk refstarlist refstarOUTname justcrop=yes background=no combine=no rawdir='raw/' procdir='proc/' darksub=no
  7. !ls starless_image_filename* | sed 's/\.fits//' > starless_imagelist
  8. pipeline_jhk starless_imagelist starless_imageOUTname justcrop=yes background=no combine=no rawdir='raw/' procdir='proc/' darksub=no
  9. reidentify sample_id_[JHK] [starless image[JHK]] coordlist=linelists$ohlines.dat nlost=10 ver+ shift=INDEF search=10.0 trace=yes *
  10. identify [reference star image[JHK]] section="middle column" coordlist="" units="" **
  11. reidentify [reference star image[JHK]] [reference star image[JHK]] section="middle column" coordlist="" nlost=10 ver+
  12. fitcoords [starless image[JHK]] fitname="skylines[JHK]" combine=yes xo=6 yo=2 interactive +
  13. fitcoords [reference star image[JHK]] fitname="stars[JHK]" combine=yes xo=6 yo=2 interactive +
  14. pipeline_jhk refstarlist_A refstarOUTname_A procdir='proc/' rawdir='raw/' calibrator=yes magJ=NNN magH=NNN magK=NNN
  15. pipeline_jhk refstarlist_B refstarOUTname_B procdir='proc/' rawdir='raw/' calibrator=yes magJ=NNN magH=NNN magK=NNN
  16. pipeline_jhk objectlist_A objectOUTname_A calibrate=yes (repeat for each object)
  17. pipeline_jhk objectlist_B objectOUTname_B calibrate=yes (repeat for each object)
  18. extract your spectrum with apall and/or continue analysis some other way

*: You may have to play with these parameters, but given the files I've provided, you should be able to automatically identify the OH lines without difficulty. interactive is set to yes so that you can make sure the solution is reasonable before moving on.

**: in this step, make sure to identify stars at DIFFERENT positions on the slit. When you identify them, assign them numbers in the range 0-100. If you've nodded the slit in the standard ABBA pattern, 25 and 75 are good numbers to assign. Make sure you assign the same numbers to the star in each order (i.e. the star lower in the slit should be 25 in J, H, and K). This information is used to remap the curved orders to be linear. If you know the distance between the objects in arcseconds, it would be sensible to make the difference in their positions equal to the difference in arcseconds (or sensible fractions of an arcsecond) so that your spatial units are sky-based units.

Also, you may have to directly edit the database/idstars[JHK] files to change the units to be BLANK (i.e. a line should read "units" with nothing after it). It's not essential, but I find it annoying to have programs try to read out a spatial direction as "angstroms"

To do:
  • Measure curvature across the slit more precisely. This requires observations of a bright source at more positions along the slit.
  • Create general-use calibration files to reduce interactivity above
  • add orders


A real example:
!ls HD182761* | sed 's/\.fits//' > refstarlist
task pipeline_jhk=pipeline_jhk.cl
# I had to specify darksub=no because I didn't have darks for this observation!
pipeline_jhk refstarlist HD182761proc justcrop=yes background=no combine=no rawdir='raw/' procdir='proc/' darksub=no

# Extract a starless spectrum and find & identify the night sky lines
!ls PelQua4*fits | sed 's/\.fits//' > starless_imagelist
pipeline_jhk starless_imagelist PelQua4_proc justcrop=yes background=no combine=no rawdir='raw/' procdir='proc/' darksub=no
!ln proc/PelQua4.0072*fits .
reidentify sample_id_J PelQua4.0072_J.fits coordlist=linelists$ohlines.dat nlost=10 verbose=yes shift=INDEF search=10.0 trace=yes 
reidentify sample_id_H PelQua4.0072_H.fits coordlist=linelists$ohlines.dat nlost=10 verbose=yes shift=INDEF search=10.0 trace=yes 
reidentify sample_id_K PelQua4.0072_K.fits coordlist=linelists$ohlines.dat nlost=10 verbose=yes shift=INDEF search=10.0 trace=yes 

# Identify the stars in the images ("A" position = 25, "B" position = 75)
!ln proc/HD182761.001[89]*fits .
identify HD182761.0018_J.fits,HD182761.0019_J.fits section="middle column" coordlist="" units=""
reidentify HD182761.0018_J.fits HD182761.0018_J.fits  section="middle column" coordlist="" nlost=10 ver+
reidentify HD182761.0019_J.fits HD182761.0019_J.fits  section="middle column" coordlist="" nlost=10 ver+
identify HD182761.0018_H.fits,HD182761.0019_H.fits section="middle column" coordlist="" units=""
reidentify HD182761.0019_H.fits HD182761.0019_H.fits  section="middle column" coordlist="" nlost=10 ver+
reidentify HD182761.0018_H.fits HD182761.0018_H.fits  section="middle column" coordlist="" nlost=10 ver+
identify HD182761.0018_K.fits,HD182761.0019_K.fits section="middle column" coordlist="" units=""
reidentify HD182761.0018_K.fits HD182761.0018_K.fits  section="middle column" coordlist="" nlost=10 ver+
reidentify HD182761.0019_K.fits HD182761.0019_K.fits  section="middle column" coordlist="" nlost=10 ver+

fitcoords PelQua4.0072_K fitname="skylinesK" combine=yes xo=6 yo=2 interactive+
fitcoords HD182761.0018_K,HD182761.0019_K fitname="starsK" combine=yes xo=6 yo=2 interactive+
fitcoords PelQua4.0072_J fitname="skylinesJ" combine=yes xo=6 yo=2 interactive+
fitcoords PelQua4.0072_H fitname="skylinesH" combine=yes xo=6 yo=2 interactive+
fitcoords HD182761.0018_H,HD182761.0019_H fitname="starsH" combine=yes xo=6 yo=2 interactive+
fitcoords HD182761.0018_J,HD182761.0019_J fitname="starsJ" combine=yes xo=6 yo=2 interactive+

# create refstarlist_A by hand (Select out A's by hand.  There's a better way to do this, but I didn't use it)
pipeline_jhk refstarlist_A refstarlistout_A procdir='proc/' rawdir='raw/' calibrator=yes magJ=6.242 magH=6.318 magK=6.287 darksub=no 
ls W51* > objectlistA
# Create objectlistOUTA by hand too
!vim objectlistA
pipeline_jhk objectlistA w51coaddA calibrate=yes darksub=no background=yes

# now calibrate / combine each observation individually
pipeline_jhk W51NSmaplist W51NSmapoutlist caleach=yes background=yes interactive_background=yes recrop=no darksub=no combine=no procdir='proc/' rawdir='raw/'

# better to do it non-interactively
pipeline_jhk W51NSmaplist W51NSmapoutlist caleach=yes background=yes interactive_background=no sample="5:12,90:98" recrop=no darksub=no combine=no procdir='proc/' rawdir='raw/' clobber=yes 



DOWNLOAD LINK: tspec pipeline
REPOSITORY LINK: aposoftware at googlecode

CODE:
readfile("apo/pipeline_jhk.cl"); ?>