############################################################ # Master reduction notes for OB Runaways project ############################################################ # It might be best to start with the iraf tutorial on slit reductions before proceeding to actual datasets. # Use scp as observer to copy over a good night of data cd /crow1/grants/nsf10/reu/2015/spectral_reductions/ cp -r /d/hamlet2/Data.claudius/20150601/* . # make a list of all data files in this subdirectory using IRAF FILES task files a*.fit > rawfiles.list ccdlist @rawfiles.list # overscan and trim all images # use unix shell editor sed command to replace .fit with .fits # spit out new file containing the list of output files !sed -e "s/.fit/_OT.fits/" rawfiles.list > trimout.list # delete any existing images in case this step is a re-do imdel @trimout.list ver- # run ccdproc to do the overscan subtraction and trimming # pay attention to make sure that the overscan region is correct for this night! # only save 290 columns for trimsec to avoid too many CRs; we're collapsing to 1D anyway implot a001.fit :l 1000 1100 # (for x-axis determinations) :c 100 200 # (for y-axis determinations) # For 2015 vintage data (the grating was rotated by 90 degrees since 2013): ccdproc @rawfiles.list outp=@trimout.list biassec=[305:395,*] trimsec=[5:294,*] interact- ccdtype="" fixpix- overscan+ trim+ zeroco- darkco- flatcor- illumc- fringec- readcor- scancor- order=2 ccdlist @trimout.list # add dispaxis keyword to header of all fits files for later when we extract spectra # For 2015 vintage data (the grating was rotated by 90 degrees since 2013): hedit @trimout.list field=DISPAXIS value=2 add+ verif- show+ update+ # Create files containing the list of science images (OT.list; spectra and CuAr arcs) and a file with the list of flat field exposures (flats.list) # You can do this manually with an editor or with a clever use of the unix "head" and "tail" commands. # Make sure you edit these files to list only the actual flats and science images. !head -n 6 trimout.list > flats.list !tail -n 76 trimout.list > OT.list hedit @flats.list IMAGETYPE flat add+ ver- hedit @OT.list IMAGETYPE object add+ ver- ccdlist @flats.list ccdlist @OT.list # combine flats using IRAF IMCOMBINE # first delete masterflat.fits if it exists in case this is a re-do imdel masterflat.fits ver- # For 2015 vintage data (the grating was rotated by 90 degrees since 2013): imcomb @flats.list outp=masterflat.fits comb=average rejec=avsigclip weight=median scale=mode statsec=[100:200,150:2200] display masterflat 1 # run the iraf task RESPONSE on masterflat; delete masterflat_response.fits if it exists in case this is a re-do imdel masterflat_response.fits ver- twodspec longslit response calib=masterflat[0] normal=masterflat[0] respons=masterflat_response.fits interac+ func=leg order=31 high=3 low=3 niter=1 display masterflat_response 1 # apply the master flat (i.e., response image) !sed -e "s/OT/OTF/" OT.list > OTF.list mkdir OTF #imarith masterflat_response_original.fits * mean_value result=masterflat_response.fits #imarith @OT.list / masterflat_response.fits @OTF.list ccdproc @OT.list output=@OTF.list ccdtype="" fixpix- overscan- trim- zeroco- darkco- flatcor+ illumc- fringec- readcor- scancor- flat=masterflat_response.fits ccdlist @OTF.list # in preparation for extracting star spectra and CuAr spectra for each star-arc pair # create a list of files containing star spectra (stars.list), a list of corresponding CuAr spectra (arcs.list) # and a list of output fits files using the names from the log file (stars_ex.list) # Only assign a single lamp observation (the nearest one in time) to each star observation. cat OTF.list > stars.list cat OTF.list > arcs.list !nedit stars.list stars_ex.list arcs.list & # check that there are same # of lines in each of these three files using the unix word count utility !wc stars.list stars_ex.list arcs.list # delete output extracted 1D spectra of arcs or stars, if they exist and this is a re-do del @stars_ex.list verify- del @arcs_ex.list ver- # run APALL to extract 1D spectrum for each star from 2D spectral files # ':up N' to put r.h.s. of aperture N pixels from center # ':low -M' to put l.h.s. of aperture M pixels from center # ':cen Z' to place aperture center at pixel Z # 'c' to re-center aperture center (do when already close to center) # 'q' to quit # 'd' to remove some of the bad data in the 'retrace' portion # Typically only need to re-size when the focus is bad and the stellar profile becomes distorted. Sometimes # Chip manually assigns :up 4 :low -4 if the star is weak and the program can't guess a good aperture size. twodspec apextract apall @stars.list outp=@stars_ex.list format=oned referen="" interac+ find+ recent+ resize+ trace+ fittr+ backgr=fit b_sampl='-35:-15,15:35' b_order=4 t_order=5 # extract arc spectra for each star using same apertures as for the stars apall @arcs.list outp=@arcs.list format=oned referen=@stars.list interac- edit- find- recent- resize- trace- fittr+ backgr=none skybox=1 # identify CuAr lines in first arc for the night using a finder chart: /d/zem1/hak/chip/iraf/CUAR1022.pdf # use chebychev 5th order fit; start with 2nd order fit and slowly work upward as lines are identified # use at least 25 lines # 'm' to initially ID 4-5 lines; 'f' to fit ('q' to return to main plot); 'w' then 'e e' box corners for x-axis increasing to the right; 'z' to zoom in on previously-idenfied line # rms should be ~ 0.012 to 0.020 identify a008_OTF.0001.fits func=cheb o=2 coordl=linelists$cuar.dat # now use solution from first arc to fit the wavelength solution for other arcs taken with the same setup # the rms should be rms=0.012 to 0.020 typically...otherwise, STOP, something is wrong!! !sed -e "s/.fits/.0001.fits/" arcs.list > arcs_ex.list reidentify a008_OTF.0001.fits @arcs_ex.list coord=linelists$cuar.dat interac+ # assign reference spectra; edit stars_ex2.list to include ".001" !sed -e "s/.fits/.0001.fits/" stars_ex.list > stars_ex2.list !nedit stars_ex2.list & # run REFSPECTRA on 1D spectra to assign a matching CuAr spectrum # input is listing of star-1D-spectra and reference is list-of-corresponding-arcs # Typically done in one fell swoop, if the assignments were done well. # use unix shell editor to make a list of extracted arc images; edit arcs_ex2.list to include ".001" refspectra @stars_ex2.list refer=@arcs_ex.list select=match verb+ # ******************************************************************************************* # Clean spectra before transforming; manually look for cosmic rays (single-pixel features) and remove strong ones. # Na will have narrow interstellar absoprtion (near Column 600?). If in doubt, check against neighboring spectra # to see if the feature repeats. Be conservative. H-alpha is prominent absorption near column 110. # 'j' to fudge in splot; 'w' then 'e e' to zoom in; 'r' redraw; 'c' redraw in its entirety; 'i' to save as foo.fits (then rename/overwrite foo.fits as original filename) splot K9832227a.0001.fits # (etc. everything in @stars_ex2.list) # apply wavelength solutions to 1D files !sed -e "s/.0001/_w.0001/" stars_ex2.list > stars_disp.list imdel @stars_disp.list ver- dispcor @stars_ex2.list @stars_disp.list verbos+ linear+ # average spectra if multiple spectra were obtained for the same star scomb HIP96514a_w.0001,HIP96514b_w.0001,HIP96514c_w.0001 HIP96514_w.fits reject=none comb=average first+ scale=median weight=median sample='5700:6500' scomb HIP95446a_w.0001,HIP95446b_w.0001,HIP95446c_w.0001 HIP95446_w.fits reject=none comb=average first+ scale=median weight=median sample='5700:6500' scomb G49.7115a_w.0001,G49.7115b_w.0001,G49.7115d_w.0001 G49.7115_w.fits reject=none comb=average first+ scale=median weight=median sample='5700:6500' scomb G50.3547a_w.0001,G50.3547b_w.0001,G50.3547c_w.0001 G50.3547_w.fits reject=none comb=average first+ scale=median weight=median sample='5700:6500' scomb G51.4152a_w.0001,G51.4152b_w.0001,G51.4152c_w.0001 G51.4152_w.fits reject=none comb=average first+ scale=median weight=median sample='5700:6500' cp K9832227a_w.0001.fits K9832227a_w.fits cp K9832227b_w.0001.fits K9832227b_w.fits cp K9832227c_w.0001.fits K9832227c_w.fits cp K9832227d_w.0001.fits K9832227d_w.fits cp K9832227e_w.0001.fits K9832227e_w.fits cp K9832227f_w.0001.fits K9832227f_w.fits cp K9832227g_w.0001.fits K9832227g_w.fits cp K9832227h_w.0001.fits K9832227h_w.fits cp K9832227i_w.0001.fits K9832227i_w.fits cp K9832227j_w.0001.fits K9832227j_w.fits cp K9832227k_w.0001.fits K9832227k_w.fits cp K9832227l_w.0001.fits K9832227l_w.fits cp K9832227m_w.0001.fits K9832227m_w.fits cp K9832227n_w.0001.fits K9832227n_w.fits cp K9832227o_w.0001.fits K9832227o_w.fits # gather up _w spectra to be doppler corrected into one file; delete them first if this is a re-do del dopcor.list ver- files *_w.fits > dopcor.list # put time and data and position in header with SETJD setjd @dopcor.list observa='wiro' date=DATE-OBS time=DATE-OBS utdate+ uttime+ observat=OBSERVAT ra=TELRA dec=TELDEC epoch=EPOCH # run RVCOR to add VEHLIO to headers epar keywpars # (change UT to UTC, RA to TELRA, DEC to TELDEC; then 'wq' to write & quit) rvcor images=@dopcor.list header+ input+ imupd+ observa='wiro' # multiply vhelio by -1 hedit @dopcor.list VHELIO '(-1*(VHELIO))' show+ update+ verify- # run dopcor imdel *wv.fits ver- !sed -e "s/_w/_wv/" dopcor.list > dopcor_out.list dopcor @dopcor.list @dopcor_out.list vhelio isvel+ add- disper+ flux- #continuum normalize !\rm contin_out.list files *_wv.*fits > contin.list !sed -e "s/_wv.fits/_wvc.fits/" contin.list > contin_out.list del @contin_out.list ver- continuum @contin.list @contin_out.list type=ratio replace- interac+ order=15 func=cheb high_re=2.2 low_rej=2 # put in std naming format !\rm names_out.list namesNC_out.list # ** CAREFUL TO CHANGE DATES BELOW TO MATCH YOUR OBSERVING DATE!! !sed -e "s/_wvc/_WIRO_2015_06_01_vc/" contin_out.list > names_out.list !sed -e "s/_wv/_WIRO_2015_06_01_vNC/" contin.list > namesNC_out.list imdel @names_out.list,@namesNC_out.list ver- imcopy @contin_out.list @names_out.list imcopy @contin.list @namesNC_out.list cp *2015* /d/zem1/hak/chip/research/Bowshocks/2015spec/ ## Done! ###