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.

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:

Instructions for use:
  1. pour yourself some triplesec
  2. Download these files:
  3. load IRAF and start entering commands as follows...
  4. onedspec
  5. twodspec
  6. longslit
  7. cp /path/to/bpm.fits . (bad pixel mask)
  8. task pipeline_jhk=/full/path/to/pipeline_jhk.cl (load pipeline code)
  9. ls reference_star_filename* | sed 's/\.fits//' > refstarlist
  10. pipeline_jhk refstarlist refstarOUTname justcrop=yes background=no combine=no
  11. ls starless_image_filename* | sed 's/\.fits//' > starless_imagelist
  12. pipeline_jhk starless_imagelist starless_imageOUTname justcrop=yes background=no combine=no
  13. reidentify [starless image[JHK]] sample_id_[JHK] coordlist=linelists$ohlines.dat nlost=10 ver+ shift=INDEF search=10.0 trace=yes *
  14. identify [reference star image[JHK]] section="middle column" coordlist="" units="" **
  15. reidentify [reference star image[JHK]] [reference star image[JHK]] section="middle column" coordlist="" nlost=10 ver+
  16. fitcoords [starless image[JHK]] fitname="skylines[JHK]" combine=yes xo=6 yo=2 interactive +
  17. fitcoords [reference star image[JHK]] fitname="stars[JHK]" combine=yes xo=6 yo=2 interactive +
  18. pipeline_jhk refstarlist refstarOUTname
  19. standard refstarOUTname_[JHK]_combine output="std[JHK]" star_name="[JHK]" caldir="onedstds$blackbody/"
  20. sensfunc std[JHK] sens[JHK]
  21. pipeline_jhk objectlist_A objectOUTname_A calibrate=yes (repeat for each object)
  22. pipeline_jhk objectlist_B objectOUTname_B calibrate=yes (repeat for each object)
  23. 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


DOWNLOAD LINK: pipeline_jhk.cl

CODE:
procedure pipeline_jhk (filename,outname) string filename string outname bool recrop=yes {prompt="Redo cropping / transforming?"} bool justcrop=no {prompt="Just crop (no transform?)"} bool combine=yes {prompt="Combine images?"} bool background=yes {prompt="Run background subtraction?"} bool calibrate=no {prompt="Calibrate?"} bool interactive_background=no {prompt="Do background subtraction interactively?"} struct *flist begin struct line string filenameJ string filenameH string filenameK real KdeltaL,HdeltaL,JdeltaL,KdeltaP,HdeltaP,JdeltaP flist=filename delete ( filename+"J" ) delete ( filename+"H" ) delete ( filename+"K" ) print ( "", > filename+"J" ) print ( "", > filename+"H" ) print ( "", > filename+"K" ) if (recrop) { while(fscan(flist,line)!=EOF) { # imarith (line ,'*', "bmask", line ) fixpix ( line , "bpm.fits" ) hedit (line,"DISPAXIS",1,add+,ver-) # separate out the individual orders imcopy (line+"[*,722:833]", line+"_K.fits", verbose="yes") imcopy (line+"[*,533:666]", line+"_H.fits", verbose="yes") imcopy (line+"[*,352:537]", line+"_J.fits", verbose="yes") filenameJ = line+"_J" filenameH = line+"_H" filenameK = line+"_K" # apply pre-calculated coordinate transforms if (justcrop==no) { transform ( input=filenameJ , output=filenameJ+"t", fitnames="skylinesJ,starsJ" ) transform ( input=filenameH , output=filenameH+"t", fitnames="skylinesH,starsH" ) transform ( input=filenameK , output=filenameK+"t", fitnames="skylinesK,starsK" ) imcopy (filenameJ+"t[*,53:137]", filenameJ+"tc.fits", verbose="yes") imcopy (filenameH+"t[*,18:118]", filenameH+"tc.fits", verbose="yes") imcopy (filenameK+"t[*,7:99]", filenameK+"tc.fits", verbose="yes") print ( filenameJ+"tc", >> filename+"J" ) print ( filenameH+"tc", >> filename+"H" ) print ( filenameK+"tc", >> filename+"K" ) } } } # combine J/H/K spectra if (combine) { imcombine ( "@"+filename+"J" , outname+"_J_combine" , combine="median" , scale="mode" ) imcombine ( "@"+filename+"H" , outname+"_H_combine" , combine="median" , scale="mode" ) imcombine ( "@"+filename+"K" , outname+"_K_combine" , combine="median" , scale="mode" ) } # calibrate using some sort of standard/sensfunc (I used blackbodies) if (calibrate) { calibrate ( outname+"_J_combine" , outname+"_J_cal" , sens="sensJ" , ignoreaps+) calibrate ( outname+"_H_combine" , outname+"_H_cal" , sens="sensH" , ignoreaps+) calibrate ( outname+"_K_combine" , outname+"_K_cal" , sens="sensK" , ignoreaps+) imgets ( outname+"_K_cal" , "CD1_1") KdeltaL = imgets.value imgets ( outname+"_J_cal" , "CD1_1") JdeltaL = imgets.value imgets ( outname+"_H_cal" , "CD1_1") HdeltaL = imgets.value imgets ( outname+"_K_cal" , "CD2_2") KdeltaP = imgets.value imgets ( outname+"_J_cal" , "CD2_2") JdeltaP = imgets.value imgets ( outname+"_H_cal" , "CD2_2") HdeltaP = imgets.value magnify ( outname+"_J_cal" , outname+"_J_cal_m" , JdeltaL/KdeltaL , JdeltaP/KdeltaP ) magnify ( outname+"_H_cal" , outname+"_H_cal_m" , HdeltaL/KdeltaL , HdeltaP/KdeltaP ) imcombine ( outname+"_K_cal,"+outname+"_H_cal_m,"+outname+"_J_cal_m" , outname+"_JHK_cal" , combine="sum" , offset="wcs" ) if (background) { background ( outname+"_JHK_cal" , outname+"_JHK_cal_backsub" , axis=2 , naverage=2 , order=2 , high=2 , low=2 , niter=3 , interactive=interactive_background ) } } # background subtract to remove night sky lines else { if (background) { imgets ( outname+"_K_combine" , "CD1_1") KdeltaL = imgets.value imgets ( outname+"_J_combine" , "CD1_1") JdeltaL = imgets.value imgets ( outname+"_H_combine" , "CD1_1") HdeltaL = imgets.value imgets ( outname+"_K_combine" , "CD2_2") KdeltaP = imgets.value imgets ( outname+"_J_combine" , "CD2_2") JdeltaP = imgets.value imgets ( outname+"_H_combine" , "CD2_2") HdeltaP = imgets.value magnify ( outname+"_J_combine" , outname+"_J_combine_m" , JdeltaL/KdeltaL , JdeltaP/KdeltaP ) magnify ( outname+"_H_combine" , outname+"_H_combine_m" , HdeltaL/KdeltaL , HdeltaP/KdeltaP ) # background ( outname+"_J_combine" , outname+"_J_backsub" , axis=2 , naverage=2 , order=2 , high=2 , low=2 , niter=3 , interactive=interactive_background ) # background ( outname+"_H_combine" , outname+"_H_backsub" , axis=2 , naverage=2 , order=2 , high=2 , low=2 , niter=3 , interactive=interactive_background ) # background ( outname+"_K_combine" , outname+"_K_backsub" , axis=2 , naverage=2 , order=2 , high=2 , low=2 , niter=3 , interactive=interactive_background ) imcombine ( outname+"_K_combine,"+outname+"_H_combine_m,"+outname+"_J_combine_m" , outname+"_JHK_combine" , combine="sum" , offset="wcs" ) background ( outname+"_JHK_combine" , outname+"_JHK_backsub" , axis=2 , naverage=2 , order=2 , high=2 , low=2 , niter=3 , interactive=interactive_background ) } } end




Home ]Astronomy ]Teaching ]Outreach ]Software ]Contact Me ]About Me ]CV ]Site Map ]