Items | Start | End |
---|---|---|
Prepare 4 tables from the FITS header | FITS header | Object list Pair table Redshift table Magnitude table |
Prepare exposure list | --- | Exposure list |
Primary reduction
|
||
Check the position error of the spines | FITS header | |
Combine sets of images | ||
Secondary background subtraction | ||
Final bad pixels interpolation | ||
Correct the shape of the mask edge | ||
Invert, rearrange & combine two positions into one | ||
Check the positions of the expected emission lines | Redshift table | |
Make objest masks & reduction again | ||
Square noise image | ||
Wavelength and Flux Calibration | ||
#################################### ### Reduction Procedure for IRS1 ### #################################### ##### Prepare files ##### ### Edit s2o file to make pair-table and mag table ### !../picktable FMSA00004039.fits > tmp1 !cut -d"|" -f12 tmp1 > tmp2 !paste tmp2 tmp1 > tmp3 !sort -n tmp3 > tmp4 !../listcomb ../irs1_spine_slit.tbl tmp4 | cut -f2,4 > tmp5 !sort -n tmp5 | sed -e 's/Dummy BS target for/Dummy:/g' > irs1_sample1.tbl cat irs1_sample1.tbl #irs1_sample1.tbl #column 1: IRS1 spectrum No. (1-200 from bottom to top) #column 2: Corresponding lines of the s2o file ### Create pair table for combine ### !grep "Dummy:" irs1_sample1.tbl | cut -f1 > tmp1a !grep "Dummy:" irs1_sample1.tbl | cut -d"|" -f2 | sed -e 's/Dummy: //g' > tmp1b !paste tmp1b tmp1a > tmp1 !grep -v "Dummy:" irs1_sample1.tbl | cut -f1 > tmp2a !grep -v "Dummy:" irs1_sample1.tbl | cut -d"|" -f2 | cut -c-20 > tmp2b !paste tmp2b tmp2a > tmp2 !../listcomb tmp1 tmp2 | cut -f2,4 > tmp3 !../listcomb tmp1 tmp2 - | cut -f2 > tmp4 !paste tmp4 tmp4 >> tmp3 !mv tmp3 irs1_sample1_pair.tbl cat irs1_sample1_pair.tbl #irs1_sample1_pair.tbl #column 1: IRS1 spectrum No. of the objects in Pos.2. #column 2: IRS1 spectrum No. of the correspoinding objects in Pos.1. #Object only in Pos.2 => column 1 = column 2 #Object only in Pos.1 => not listed in this file ### Create redshift table for linepos ### !grep -v "Dummy:" irs1_sample1.tbl | cut -f1 > tmp0 !cut -f2 irs1_sample1_pair.tbl > tmp1 !../listcomb tmp1 tmp0 - >> tmp0 !cut -f1 irs1_sample1.tbl > tmp2 #!less irs1_sample1.tbl #search keyword "zp=" and "zs=" in the s2o file #9.999 indicates "No data" in this case !../readarg irs1_sample1.tbl zp= -1 | sed -e 's/9\.999/-1/g' > tmp3 !../readarg irs1_sample1.tbl zs= -1 | sed -e 's/9\.999/-1/g' > tmp4 !paste tmp2 tmp3 | grep -v "\-1" | sed -e 's/$/ 0.01/g' > tmp5 !paste tmp2 tmp3 | grep "\-1" >> tmp5 !paste tmp2 tmp4 | grep -v "\-1" > tmp6 !../listcomb tmp5 tmp6 - >> tmp6 !../listcomb tmp0 tmp6 | cut -f2- | sort -n > irs1_sample1_fib_z.tbl cat irs1_sample1_fib_z.tbl #column 1: IRS1 spectrum No. #column 2: Expected redshifts (-1: No data) #column 3: Typical error of the estimated redshifts (e.g. nothing for spec-z and 0.01 for phot-z) ### Create magnitude table for mag_fnu plot ### !grep -v "Dummy:" irs1_sample1.tbl | cut -f1 > tmp1 !grep -v "Dummy:" irs1_sample1.tbl > tmp2 #!less tmp2 #if column 12 shows Jmag #!cut -d"|" -f12 tmp2 > tmp3 #else search keyword "J=" in the s2o file !../readarg tmp2 J= 99.99 > tmp3 !../readarg tmp2 H= 99.99 > tmp4 !../readarg tmp2 K= 99.99 > tmp5 #if they are Vega magnitudes... #!../readarg tmp2 J= 99.99 | awk '{if($1>90) print $1;else print $1+0.870}' > tmp3 #!../readarg tmp2 H= 99.99 | awk '{if($1>90) print $1;else print $1+1.348}' > tmp4 #!../readarg tmp2 K= 99.99 | awk '{if($1>90) print $1;else print $1+1.858}' > tmp5 !paste -d" " tmp3 tmp4 tmp5 | awk '{if($1<90 && $2>90 && $3<90) print $1,($1+$3)/2;else print $1,$2}' > tmp6 #or #!paste -d" " tmp3 tmp4 tmp5 | awk '{if($1<90 && $2>90 && $3<90) print $1,(($1-0.870)*0.2+($3-1.858)*0.8)+1.348;else print $1,$2}' > tmp6 !paste tmp1 tmp6 | grep -v "99\.99 99\.99" > irs1_sample1_mag.tbl cat irs1_sample1_mag.tbl #column 1: IRS1 spectrum No. of Pos.1 fibers. #column 2: J-mag (AB) (No Data => 99.99) #column 3: H-mag (AB) (No Data => 99.99) ##### Object Image ##### ### Make the exposure list ### !echo "a FMSA00004039 FMSA00004041" > irs1_sample1_lr.tbl !echo "b FMSA00004043 FMSA00004045" >> irs1_sample1_lr.tbl !echo "c FMSA00004047 FMSA00004049" >> irs1_sample1_lr.tbl !echo "d FMSA00004051 FMSA00004053" >> irs1_sample1_lr.tbl #Delimiter must be " ". #No ".fits" should be attached. #Use "NONE" if the correnponding exposure was not taken. #The middle column should be object frames in the BS mode, and use #"NONE" for the first image when the first frame is the sky image. #For quick look during the observation, # * Prepare this list to the end of the expected exposure. # * Do "!../mkscr...", "!sed ...", and "cl < mkscr.cl" lines in the # next section after every pos.1 of pair exposure is taken. # * Do the completed part in "redproc_irs1_TARGET_NAME_MODEA" script # using cut & paste by mouse. ### Check sky frame (BS mode only) ### ##If you want to recheck all the sky images, delete *sub*.fits files first. #!../mkscr2 irs1_sample1_lr.tbl lr #cl < mkscr2.cl ### Primary reduction ### #Replace 'CBS' with 'BS' (or 'BS+') for BS (BS for bright object) mode #If you restart all from here... #imdel irs1_sample1*_lr.fits !../mkscr irs1_sample1_lr.tbl CBS > redproc_irs1_sample1_lrB !sed -e 's/imcopy/#imcopy/g' redproc_irs1_sample1_lrB | sed -e 's/#cl/cl/g' > redproc_irs1_sample1_lrA cl < mkscr.cl cl < redproc_irs1_sample1_lrA #If you have the object mask, send this line instead of above one. #(This line is used for the 2ndary reduction...) cl < redproc_irs1_sample1_lrB ### Check Spine Allocation ### imdel irs1_sample1_lr_spineerror #CBS mode !../spineerror irs1_sample1_lr.tbl irs1_sample1_pair.tbl #BS mode #!../spineerror irs1_sample1_lr.tbl displ irs1_sample1_lr_spineerror 1 ### Combine ### !ls irs1_sample1?_lrxpb.fits > irs1_sample1_lrxpb.tbl mdisp @irs1_sample1_lrxpb.tbl 0 #Make sure the bright object in each subset has the same y-position. #Remove imcomplete pair from the list #emacs irs1_M38_lrxpb.tbl & !sed -e 's/b\.fits/_bpm\.fits/g' irs1_sample1_lrxpb.tbl > irs1_sample1_lryp_bpm.tbl imdel irs1_sample1_lryp_bpm.fits imcomb @irs1_sample1_lryp_bpm.tbl irs1_sample1_lryp_bpm.fits displ irs1_sample1_lryp_bpm 2 zs- zr- z1=1 z2=0 imdel irs1_sample1_lrxpb.fits imcomb @irs1_sample1_lrxpb.tbl irs1_sample1_lrxpb.fits displ irs1_sample1_lrxpb 1 ### Secondary Residual Sky Subtraction ### #For CBS mode or BS mode (faint objects) !sed -e 's/FMSAfileno/irs1_sample1_lr/g' ../redscr3 | sed -e 's/BAND/lr/g' > tmpscr #For BS mode (bright objects) #!sed -e 's/FMSAfileno/irs1_sample1_lr/g' ../redscr3 | sed -e 's/BAND/lr/g' | sed -e 's/high_r=2 low_r=2/high_r=1.5 low_r=3/g' > tmpscr cl < tmpscr #If you don't want to accept this result, #imdel irs1_sample1_lryp #imcopy irs1_sample1_lrxpb irs1_sample1_lryp.fits ### Final Bad pix Correction ### !sed -e 's/FMSAfileno/irs1_sample1_lryp/g' ../redscrb | sed -e 's/\/ 10/\/ 1/g' | sed -e 's/convolve/#convolve/g' > tmpscr cl < tmpscr imdel irs1_sample1_lrypb0,irs1_cont_sample1_lra,irs1_sample1_lryp_bpm0.fits imcopy irs1_sample1_lrypb.fits irs1_sample1_lrypb0.fits imcopy irs1_cont_lra.fits irs1_cont_sample1_lra.fits imcopy irs1_sample1_lryp_bpm.fits irs1_sample1_lryp_bpm0.fits displ irs1_sample1_lryp_bpm 4 zs- zr- z1=1 z2=0 ### Mask edge correction ### imdel irs1_flat_sample1_lra.fits !../adjflat irs1_sample1_lrypb0.fits irs1_flat_lra.fits irs1_flat_sample1_lra.fits imrepl irs1_flat_sample1_lra.fits 0.5 upper=0.5 imrepl irs1_flat_sample1_lra.fits 2 lower=2 imdel irs1_sample1_lrypb magnify irs1_flat_sample1_lra.fits irs1_flat_sample1_lra.fits 1. 9. y1=0.5 y2=200.4999 interpo=nearest boundar=nearest fluxcon- imarith irs1_sample1_lrypb0.fits / irs1_flat_sample1_lra.fits irs1_sample1_lrypb.fits ### CBS Combine (CBS mode only) ### imdel tmp1,tmp2,irs1_cont_sample1_lra imcopy irs1_cont_lra tmp1 !../matchpair tmp1.fits irs1_sample1_pair.tbl tmp2.fits irs1_cont_lra.dat imcomb tmp1,tmp2 irs1_cont_sample1_lra.fits lthresh=-99990. imdel irs1_sample1_lrypb1,irs1_sample1_lrypb2,irs1_sample1_lrypb imarith irs1_sample1_lrypb0.fits / irs1_flat_sample1_lra.fits irs1_sample1_lrypb1.fits !../matchpair irs1_sample1_lrypb1.fits irs1_sample1_pair.tbl irs1_sample1_lrypb2.fits irs1_cont_lra.dat displ irs1_sample1_lrypb1 1 zs- zr- z1=-20 z2=20 displ irs1_sample1_lrypb2 2 zs- zr- z1=-20 z2=20 imcomb irs1_sample1_lrypb1,irs1_sample1_lrypb2 irs1_sample1_lrypb.fits lthresh=-99990. ##If you have one more image to join...(replace "X" to the name of the extra set) #imcopy irs1_sample1_lr_mask.fits irs1_sample1X_lr_mask.fits #!sed -e 's/FMSAfileno/irs1_sample1X_lr/g' ../redscr3 | sed -e 's/BAND/lr/g' > tmpscr #cl < tmpscr #!sed -e 's/FMSAfileno/irs1_sample1X_lryp/g' ../redscrb | sed -e 's/\/ 10/\/ 1/g' > tmpscr #cl < tmpscr #imdel irs1_sample1X_lrypb1.fits,irs1_sample1X_lrypb2.fits,irs1_sample1X_lr_mask.fits #imarith irs1_sample1X_lrypb.fits / irs1_flat_sample1_lra.fits irs1_sample1X_lrypb1.fits #!../matchpair irs1_sample1X_lrypb1.fits irs1_sample1_pair.tbl irs1_sample1X_lrypb2.fits irs1_cont_lra.dat #imdel tmp1 #imrename irs1_sample1_lrypb tmp1 ## If you have 3 complete pair... #!echo -e 3"\n"1 > tmp1 ##If you want to add pos.A (lrypb1)... #imcomb tmp1,irs1_sample1X_lrypb1 irs1_sample1_lrypb weight=@tmp1 lthresh=-99990. displ irs1_sample1_lrypb 3 zs- zr- z1=-20 z2=20 imdel irs1_sample1_lryp_bpm1,irs1_sample1_lryp_bpm2,irs1_sample1_lryp_bpm imcopy irs1_sample1_lryp_bpm0 irs1_sample1_lryp_bpm1 !../matchpair irs1_sample1_lryp_bpm1.fits irs1_sample1_pair.tbl irs1_sample1_lryp_bpm2.fits irs1_cont_lra.dat imarith irs1_sample1_lryp_bpm2.fits * -1 irs1_sample1_lryp_bpm2.fits imrepl irs1_sample1_lryp_bpm2.fits -99999. lower=99990 imcomb irs1_sample1_lryp_bpm1,irs1_sample1_lryp_bpm2 irs1_sample1_lryp_bpm.fits lthresh=-99990. displ irs1_sample1_lryp_bpm 4 zs- zr- z1=1 z2=0 ### Position of the Expected Emission Lines ### imdel irs1_sample1_linepos_lr.fits !../linepos irs1_sample1_fib_z.tbl ../linepos.dat irs1_ar_lrw.fits irs1_sample1_linepos_lr.fits displ irs1_sample1_lrypb 1 zs- zr- z1=-20 z2=20 displ irs1_sample1_linepos_lr 2 zs- zr- z1=0 z2=10 ### Object Mask ### imdel tmp1,tmp2 magnify irs1_sample1_lr_mask tmp1 1. 9. y1=0.5 y2=200.4999 interpo=nearest boundar=nearest fluxcon- imarith irs1_sample1_lrypb * tmp1 tmp1 imedit tmp1 tmp2 aperture=square radius=1 value=-99999. #press "e" where you want to put mask (undo: "u") and press "q" to quit. #To remove mask, press "e" at the mask position. !../maskrepl irs1_sample1_lr_mask.fits tmp2.fits irs1_sample1_pair.tbl #Repeat this section (red lines) until all the masks are fixed. #If more than half spectra are automatically masked, reduce the order of fit1d commands in ../redscr2, ../redscr2s, # and ../redscr3 to surpress the background rolling. #If you want to apply this object mask, make reduction again from "cl < redproc_irs1_sample1_lrB" ### Noise^2 Frame (for faint object ONLY!) ### #Output file: irs1_sample1_lrypb0_nosq.fits #CBS mode !../mknoise irs1_sample1_lrypb0.fits irs1_flat_sample1_lra.fits irs1_sample1_pair.tbl irs1_cont_lra.dat #BS mode #!../mknoise irs1_sample1_lrypb0.fits irs1_flat_sample1_lra.fits ### Wavelength and Flux Calibration (Absorption Correction) ### #Set aperture mask for each spectra !echo "0.5 1 1 1 1 1 1 1 0.5" > extract.dat minmax irs1_sample1_lrypb displ irs1_sample1_lrypb 1 zs- zr+ cat irs1_sample1_mag.tbl #Choose a bright star for the spectrum reference and put the number (int(y/9)+1) for the last argument of the next command (replace "XX"). #You can use an extra argument of the airmass value to improve the accuracy of automatic type-judgement, such as "...ypbw.fits 15 108 1.95". #Or, if you know the spectral type of this reference star, you can use the argument as the spectral type like "...ypbw.fits 15 108 K2III". #When you run it with this mode, the parameters for automatic type-judgement are recalibrated and dumped to "conv_w_fnu.dat". #If you want to reset the parameters, please delete "conv_w_fnu.dat". #Note that #26,#95,#102,#115,#119,#128,#135,#143,#147,#152,#156,#174 fibers are unstable. imdel irs1_sample1_lrypbw,check,irs1_sample1_lrypw_bpm !../conv_w_fnu irs1_sample1_lrypb.fits irs1_ar_lrw.fits irs1_cont_sample1_lra.fits irs1_sample1_lrypbw.fits 15 163 !../conv_w_fnu irs1_sample1_lryp_bpm.fits irs1_ar_lrw.fits irs1_cont_sample1_lra.fits irs1_sample1_lrypw_bpm.fits #Reddening correction (XX is the same vlue of above, and MAG is the expected extinction calue.) #imdel irs1_sample1_lrypbw,check,tmp1 #!../extinc irs1_ar_lrw.fits XX MAG tmp1.fits #imarith irs1_sample1_lrypb / tmp1 tmp1 #!../conv_w_fnu tmp1.fits irs1_ar_lrw.fits irs1_cont_sample1_lra.fits irs1_sample1_lrypbw.fits 15 XX ##If you want more, compare "check.fits" to the typical thruoughput "../checksum.fits". displ irs1_sample1_lrypbw 1 displ irs1_sample1_lrypw_bpm 2 zs- zr- z1=1 z2=0 #0.9um(x=1), 5A/pix, 1count=1uJy (within the fiber aperture) in this image. imdel irs1_sample1_lrypbwx.fits,irs1_sample1_lrypbwx_no.fits !../extract2 irs1_sample1_lrypbw.fits irs1_sample1_lrypbwx.fits !../extract2 irs1_sample1_lrypbw_nosq.fits irs1_sample1_lrypbwx_no.fits imfunc irs1_sample1_lrypbwx_no.fits irs1_sample1_lrypbwx_no.fits sqrt displ irs1_sample1_lrypbwx 3 #0.9um(x=1), 5A/pix, 1count=1uJy (within the fiber aperture) in this image. imdel tmp1 #Mask the data where the relative throughput is less than 5% with +2 pix growing #!../fillmask irs1_sample1_lrypbwx.fits 0.05 check.fits tmp1.fits 2 #or noise level larger than 3*(typical noise level) with +2 pix growing !../fillmask irs1_sample1_lrypbwx.fits 3 irs1_sample1_lrypbwx_no.fits tmp1.fits 2 #noao #onedspec #splot tmp1 box tmp1.fits tmp1.fits 5 1 !../fits2txt irs1_sample1_lrypbwx_no.fits > plot2.tbl #Mask the data where the relative throughput is less than 5% with +2 pix growing #!../fits2txt tmp1.fits 0.05 check.fits 2 > plot.tbl #or noise level larger than 3*(typical noise level) with +2 pix growing !../fits2txt tmp1.fits 3 irs1_sample1_lrypbwx_no.fits 2 > plot.tbl !grep -v "\-1" irs1_sample1_fib_z.tbl > plot_z.tbl !../listcomb irs1_sample1_mag.tbl check.txt | cut -f1,2,4 > mag_fnu.tbl #Make sure the J-H colors of the objects are consistent with the catalog by the following plot. ##### Plot by gnuplot ##### !gnuplot < ../mag_fnu.gnuplot | evince mag_fnu.ps & !cp mag_fnu.tbl irs1_sample1_lr_mag_fnu.tbl !grep 59 plot_z.tbl !sed -e 's/NUM/59/g' ../plot_ind2.gnuplot| sed -e 's/REDSHIFT/0.0/g' > tmp.gnuplot !gnuplot < tmp.gnuplot !evince plot_59.ps & #multi-plots (10 spectrum from specified) #In this case, 51 -- 60 !sed -e 's/NUM/51/g' ../plot_ind3.gnuplot| sed -e 's/REDSHIFT/0.0/g' > tmp.gnuplot !gnuplot < tmp.gnuplot !evince plot_all_51.ps & ##### Plot by SuperMongo ##### !sm < ../mag_fnu.sm !cp mag_fnu.tbl irs1_sample1_lr_mag_fnu.tbl !sed -e 's/NUM/163/g' ../plot_ind2.sm | sed -e 's/SCALE/-1/g' > tmp.sm !sm < tmp.sm !sed -e 's/NUM/102/g' ../plot_ind2.sm | sed -e 's/SCALE/-1/g' > tmp.sm !sm < tmp.sm !sed -e 's/NUM/183/g' ../plot_ind2.sm | sed -e 's/SCALE/-1/g' > tmp.sm !sm < tmp.sm #Plot by object flux (>100uJy) !sed -e 's/FROM/1/g' ../plot_multi.sm | sed -e 's/TO/200/g' | sed -e 's/THRE/100/g' > tmp.sm !sm < tmp.sm ##### END #####