# Pipeline for Target cs22898-047 GAIN := $(shell python -c 'import FITS;f=FITS.FITS("flatred.fits");print f["newgain"];f.close()') all: stage-overscan stage-flatten stage-ydist-copy stage-orders-copy stage-deslitfn stage-xdist stage-xdist-copy stage-wdist stage-wdist-copy stage-skyaps stage-skyrect stage-skysub stage-objaps stage-mkmask stage-extractall stage-finalize stage-reporting stage-overscan: # Overscan Subtraction, Trimming, and Image Reorientation. echo Stage: Overscan Subtraction, Trimming, and Image Reorientation. mikebias -c 3 /data1/hidari/gwalth/MIKE/test/sept06/RAW/r0186.fits cs22898-047red_spec0186.fits -linebias mikebias -c 3 /data1/hidari/gwalth/MIKE/test/sept06/RAW/r0187.fits cs22898-047red_lamp0187.fits -linebias mikebias -c 3 /data1/hidari/gwalth/MIKE/test/sept06/RAW/r0188.fits cs22898-047red_spec0188.fits -linebias touch stage-overscan stage-flatten: stage-overscan # Flattening. echo Stage: Flattening. flat2d flatred.fits cs22898-047red_spec0186.fits flat2d flatred.fits cs22898-047red_lamp0187.fits flat2d flatred.fits cs22898-047red_spec0188.fits touch stage-flatten stage-ydist-copy: stage-flatten # Copying the Y Distortion. echo Stage: Copying the Y Distortion. cp ../slitred.fits slitred.fits maprect -ydist slitred.fits copyrect -ydist slitred.fits cs22898-047red_spec0186f.fits copyrect -ydist slitred.fits cs22898-047red_lamp0187f.fits copyrect -ydist slitred.fits cs22898-047red_spec0188f.fits touch stage-ydist-copy stage-orders-copy: stage-ydist-copy # Copy the Order Edges. echo Stage: Copy the Order Edges. copyslit -fwhm 10.000000 -ydist -fft slitred.fits cs22898-047red_lamp0187f.fits copyslit cs22898-047red_lamp0187f.fits cs22898-047red_spec0186f.fits copyslit cs22898-047red_lamp0187f.fits cs22898-047red_spec0188f.fits touch stage-orders-copy stage-deslitfn: stage-orders-copy # Dividing out the 2D Image of the Slit Function. echo Stage: Dividing out the 2D Image of the Slit Function. mikeflat1d -fft slitred.fits cs22898-047red_lamp0187f.fits cs22898-047red_spec0186f.fits mikeflat1d -fft slitred.fits cs22898-047red_lamp0187f.fits cs22898-047red_spec0188f.fits mikeflat1d -fft slitred.fits cs22898-047red_lamp0187f.fits touch stage-deslitfn stage-xdist: stage-deslitfn # Get X Distortion. echo Stage: Get X Distortion. efits cs22898-047red_lamp0187fs.fits 'i1-VTKMedian(i1,1,51,numret=1)' cs22898-047red_lamp0187fsb.fits efits cs22898-047red_lamp0187fsb.fits 'i1-VTKMedian(i1,11,3,numret=1)' cs22898-047red_lamp0187fsb.fits efits cs22898-047red_lamp0187fsb.fits '1.49*median(abs(i1))' cs22898-047red_lamp0187fsb_scat.fits efits -r cs22898-047red_lamp0187fsb.fits cs22898-047red_lamp0187fsb_scat.fits 'bl,bs=bwt(i2);bw=less(i2,bl+100*bs)*ones(i1.shape,Float32);smo=divz(VTKGauss(i1*bw,sigmax=1,sigmay=0,numret=1),VTKGauss(1.*bw,sigmax=1,sigmay=0,numret=1));result=where(bw,i1,smo)' cs22898-047red_lamp0187fsb.fits efits cs22898-047red_lamp0187fsb.fits 'i1*between(i1,-5*1.49*median(transpose(abs(i1)))[::,NewAxis],65e3)' cs22898-047red_lamp0187fsb.fits getrect -xdist -ydist cs22898-047red_lamp0187fsb.fits -nx 1 -dy 3 -x 0 -nsub2 1 -y 1 -b 2 -normwt 100.000000 niter 1 globalrect cs22898-047red_lamp0187fsb.fits -maxo 2 -go -s 11.000000 -d cs22898-047red_lamp0187fsbglob.ps/vcps maprect -xdist cs22898-047red_lamp0187fsb.fits touch stage-xdist stage-xdist-copy: stage-xdist # Copying X Distortion. echo Stage: Copying X Distortion. copyrect -xdist cs22898-047red_lamp0187fsb.fits cs22898-047red_spec0186fs.fits copyrect -xdist cs22898-047red_lamp0187fsb.fits cs22898-047red_lamp0187fs.fits copyrect -xdist cs22898-047red_lamp0187fsb.fits cs22898-047red_spec0188fs.fits touch stage-xdist-copy stage-wdist: stage-xdist-copy # Do the Wavelength Calibration. echo Stage: Do the Wavelength Calibration. mikeMatchOrders cs22898-047red_lamp0187fsb.fits mikeFindLines cs22898-047red_lamp0187fsbspecs.fits -fwhm 2.500000 -th 10.000000 mikeMatchLamps cs22898-047red_lamp0187fsbspecs.fits -m lampred.fits touch stage-wdist stage-wdist-copy: stage-wdist copyecords cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fs.fits copyecords cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fsb.fits copyecords cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0186fs.fits copyecords cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0188fs.fits copyrect -wdist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0186fs.fits copyrect -wdist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fs.fits copyrect -wdist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fs.fits copyrect -wdist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0188fs.fits copyrect -edist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0186fs.fits copyrect -edist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fs.fits copyrect -edist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_lamp0187fs.fits copyrect -edist cs22898-047red_lamp0187fsbspecs.fits cs22898-047red_spec0188fs.fits touch stage-wdist-copy stage-skyaps: stage-wdist-copy # Generate Sky Apertures. echo Stage: Generate Sky Apertures. mkorderaps -ydist -nsig 2.000000 -oo 5 cs22898-047red_spec0186fs.fits cs22898-047red_spec0188fs.fits touch stage-skyaps stage-skyrect: stage-skyaps # Determine the Sky Background. echo Stage: Determine the Sky Background. skyrect cs22898-047red_spec0186fs.fits -xdist -ydist -rn 3.500000 -g ${GAIN} -skyint 2048 -kx 3 -ky 0 -skysuf sky -b 0 -dkx 0.850000 -pct 40.000000 -check 5 -lowcut 4.000000 -skycut 4.000000 -spass -5 skyrect cs22898-047red_spec0188fs.fits -xdist -ydist -rn 3.500000 -g ${GAIN} -skyint 2048 -kx 3 -ky 0 -skysuf sky -b 0 -dkx 0.850000 -pct 40.000000 -check 5 -lowcut 4.000000 -skycut 4.000000 -spass -5 touch stage-skyrect stage-skysub: stage-skyrect # Subtract the Sky Background. echo Stage: Subtract the Sky Background. efits cs22898-047red_spec0186fs.fits cs22898-047red_spec0186fsm.fits '(i1-i2)' cs22898-047red_spec0186fso.fits efits cs22898-047red_spec0188fs.fits cs22898-047red_spec0188fsm.fits '(i1-i2)' cs22898-047red_spec0188fso.fits touch stage-skysub stage-objaps: stage-skysub # Generate Object Positions. echo Stage: Generate Object Positions. mkorderaps -root cs22898-047red- -ydist -bigsky -oo 5 -ex -nsig 1.762500 cs22898-047red_spec0186fso.fits cs22898-047red_spec0188fso.fits cat cs22898-047red_spec0186fso.aps cs22898-047red_spec0188fso.aps > cs22898-047red.aps touch stage-objaps stage-mkmask: stage-objaps # Make a quick mask image of bad pixels echo Stage: Make a quick mask image of bad pixels efits flatred.fits "1.0*greater(i1,0.25)" maskred.fits touch stage-mkmask stage-extractall: stage-mkmask # Gauss-Hermite-Legendre-BSpline Extractions echo Stage: Gauss-Hermite-Legendre-BSpline Extractions time GHLBExtract -p -npass 3 -nfactor 5 -rn 3.500000 -g ${GAIN} -kx 5 -ky 0 -yx 6 -ya 5 -sx 2 -sa 1 -hy 5 -hx 2 -ha 1 -lamp cs22898-047red_lamp0187fs.fits -flat blazered.fits -mask maskred.fits -o cs22898-047red_multi.fits -header cs22898-047red_spec0186.fits cs22898-047red_spec0186fso.aps cs22898-047red_spec0188fso.aps touch stage-extractall stage-finalize: stage-extractall # Copy Final Products. echo Stage: Copy Final Products. cp cs22898-047red_multi.fits ../Final-Products touch stage-finalize stage-reporting: stage-finalize # Generate html and pdf reports. echo Stage: Generate html and pdf reports. /data1/chiaki/gwalth/python.linux/dev/mikeReport.py cp cs22898-047red_reportShort.pdf ../Final-Products touch stage-reporting clean: rm -f flatred_flat0001.fits flatred_slit0134.fits flatred_flat0002.fits flatred_flat0003.fits flatred_flat0004.fits flatred_flat0005.fits flatred_flat0006.fits flatred_flat0007.fits flatred_flat0008.fits flatred_flat0009.fits flatred_flat0010.fits flatred_flat0011.fits flatred_flat0012.fits flatred_flat0013.fits flatred_flat0014.fits flatred_flat0015.fits flatred_flat0016.fits flatred_flat0017.fits flatred_flat0018.fits flatred_flat0019.fits flatred_flat0020.fits flatred_flat0021.fits flatred_flat0022.fits flatred_flat0023.fits flatred_flat0024.fits flatred_flat0025.fits flatred_flat0026.fits flatred_flat0027.fits flatred_flat0028.fits flatred_flat0029.fits flatred_flat0030.fits flatred_flat0031.fits flatred_flat0032.fits flatred_flat0033.fits flatred_flat0034.fits flatred_flat0035.fits flatred_flat0036.fits flatred_flat0037.fits flatred_flat0038.fits flatred_flat0039.fits flatred_flat0040.fits flatred_flat0041.fits flatred_flat0042.fits flatred_flat0043.fits flatred_flat0044.fits flatred_flat0045.fits flatred_flat0046.fits flatred_flat0087.fits flatred_flat0088.fits flatred_flat0135.fits flatred_flat0136.fits flatred_flat0137.fits flatred_flat0138.fits flatred_flat0139.fits flatred_flat0140.fits flatred_flat0141.fits flatred_flat0142.fits flatred_flat0143.fits flatred_flat0144.fits flatred_flat0145.fits flatred_flat0146.fits flatred_flat0147.fits flatred_flat0148.fits flatred_flat0149.fits flatred_flat0150.fits flatred_flat0151.fits flatred_flat0152.fits flatred_flat0153.fits flatred_flat0154.fits flatred_flat0155.fits flatred_flat0001flt.fits flatred_flat0002flt.fits flatred_flat0003flt.fits flatred_flat0004flt.fits flatred_flat0005flt.fits flatred_flat0006flt.fits flatred_flat0007flt.fits flatred_flat0008flt.fits flatred_flat0009flt.fits flatred_flat0010flt.fits flatred_flat0011flt.fits flatred_flat0012flt.fits flatred_flat0013flt.fits flatred_flat0014flt.fits flatred_flat0015flt.fits flatred_flat0016flt.fits flatred_flat0017flt.fits flatred_flat0018flt.fits flatred_flat0019flt.fits flatred_flat0020flt.fits flatred_flat0021flt.fits flatred_flat0022flt.fits flatred_flat0023flt.fits flatred_flat0024flt.fits flatred_flat0025flt.fits flatred_flat0026flt.fits flatred_flat0027flt.fits flatred_flat0028flt.fits flatred_flat0029flt.fits flatred_flat0030flt.fits flatred_flat0031flt.fits flatred_flat0032flt.fits flatred_flat0033flt.fits flatred_flat0034flt.fits flatred_flat0035flt.fits flatred_flat0036flt.fits flatred_flat0037flt.fits flatred_flat0038flt.fits flatred_flat0039flt.fits flatred_flat0040flt.fits flatred_flat0041flt.fits flatred_flat0042flt.fits flatred_flat0043flt.fits flatred_flat0044flt.fits flatred_flat0045flt.fits flatred_flat0046flt.fits flatred_flat0087flt.fits flatred_flat0088flt.fits flatred_flat0135flt.fits flatred_flat0136flt.fits flatred_flat0137flt.fits flatred_flat0138flt.fits flatred_flat0139flt.fits flatred_flat0140flt.fits flatred_flat0141flt.fits flatred_flat0142flt.fits flatred_flat0143flt.fits flatred_flat0144flt.fits flatred_flat0145flt.fits flatred_flat0146flt.fits flatred_flat0147flt.fits flatred_flat0148flt.fits flatred_flat0149flt.fits flatred_flat0150flt.fits flatred_flat0151flt.fits flatred_flat0152flt.fits flatred_flat0153flt.fits flatred_flat0154flt.fits flatred_flat0155flt.fits slitred_slit0134.fits slitred_slit0156.fits slitred_slit0157.fits slitred_slit0158.fits slitred_slit0159.fits slitred_slit0160.fits slitred_slit0161.fits slitred_slit0162.fits slitred_slit0163.fits slitred_slit0164.fits slitred_slit0165.fits slitred_slit0166.fits slitred_slit0167.fits slitred_slit0168.fits slitred_slit0169.fits slitred_slit0170.fits slitred_slit0171.fits slitred_slit0172.fits slitred_slit0173.fits slitred_slit0174.fits slitred_slit0175.fits slitred_slit0176.fits medianred.fits medianredff.fits lampred_lamp0050.fits lampred_lamp0050f.fits cs22898-047red_spec0186.fits cs22898-047red_lamp0187.fits cs22898-047red_spec0188.fits cs22898-047red_spec0186f.fits cs22898-047red_lamp0187f.fits cs22898-047red_spec0188f.fits cs22898-047red_spec0186fs.fits cs22898-047red_lamp0187fs.fits cs22898-047red_spec0188fs.fits cs22898-047red_spec0186fsm.fits cs22898-047red_spec0188fsm.fits cs22898-047red_spec0186fso.fits cs22898-047red_spec0188fso.fits veryclean: rm -f stage-overscan stage-flatten stage-ydist-copy stage-orders-copy stage-deslitfn stage-xdist stage-xdist-copy stage-wdist stage-wdist-copy stage-skyaps stage-skyrect stage-skysub stage-objaps stage-mkmask stage-extractall stage-finalize stage-reporting