#!/bin/csh -x

efits flat.fits "VTKLaplace(i1,numret=1)" laplace.fits

getrect -ydist laplace.fits -nx 12 -dy 11 -x 2 -y 4 -peakwin 3 -dump
copyrect -ydist laplace.fits flatb.fits lampb.fits spec1b.fits spec2b.fits spec3b.fits

findslits -ydist flatb.fits -th 0.2 -sw 10 -fwhm 2
copyslit flatb.fits lampb.fits spec1b.fits spec2b.fits spec3b.fits \
	-fft -ydist

makeflat -ydist flatb.fits
flat1d flatbslt.fits lampb.fits -fft -ydist
flat1d flatbslt.fits spec1b.fits -fft -ydist
flat1d flatbslt.fits spec2b.fits -fft -ydist
flat1d flatbslt.fits spec3b.fits -fft -ydist
flat2d flatbflt.fits lampbs.fits spec1bs.fits spec2bs.fits spec3bs.fits
flat2d flatbblz.fits lampbsf.fits spec1bsf.fits spec2bsf.fits spec3bsf.fits 

efits flatbblz.fits lampbsff.fits "i2*greater(i1,0.1)" xuse.fits

getrect -xdist -ydist xuse.fits -nx 16 -dy 3 -b 5 -x 2 -y 1 $*
copyrect -xdist xuse.fits lampbsff.fits spec1b*.fits spec2b*.fits spec3b*.fits lampbsf.fits $*

waverect -xdist -ydist lampbsf.fits -o 4 -w1 7370 -w2 9700 -d0 1.1 \
	-ll forsll.dat -arcamp -fwhm 5

unrect -wdist -xdist -ydist lampbsf.fits -w1 7500 -w2 10500 -dw 1

copyrect -wdist lampbsf.fits spec?b*.fits
waverect -wdist -ydist spec1b.fits -ll shortsky.dat -zero 1
waverect -wdist -ydist spec2b.fits -ll shortsky.dat -zero 1
waverect -wdist -ydist spec3b.fits -ll shortsky.dat -zero 1

unrect -wdist -xdist -ydist spec1b.fits -w1 7500 -w2 10500 -dw 1
unrect -wdist -xdist -ydist spec2b.fits -w1 7500 -w2 10500 -dw 1
unrect -wdist -xdist -ydist spec3b.fits -w1 7500 -w2 10500 -dw 1

easysky spec1br.fits spec2br.fits spec3br.fits -i 3

