#!/usr/bin/perl # # Lisa Germany # 16th June 2002 # Updated: # #################################################################### # # INPUT: # Needs 3 files containing - list of bias images # - list of flats with high counts # - list of flats with low counts # # DESCRIPTION: # - Processes raw images to make 8 badpix files - one for each chip # - Gzips images ready for saving on tape # - Tars and Gzips badpix files ready to go onto the web # ##################################################################### if ( $#ARGV <3 ) { die "\n\nUsage: mkBADPIX.pl biaslist lowflatlist highflatlist tarfilename\n\n"} $biaslist = $ARGV[0]; $flatlowlist = $ARGV[1]; $flathighlist = $ARGV[2]; $tarfile = $ARGV[3]; ############################################################################## #### #### #### (1) Run esowfi on all images #### #### #### ############################################################################## unlink "login.cl" if -e "login.cl"; unlink "logfile" if -e "logfile"; unlink "loginuser.cl" if -e "loginuser.cl"; system( "cp source\/login.cl \.\/login.cl" ); system( "cp source\/loginuser.cl \.\/loginuser.cl" ); open ( F1, ">>login.cl" ) || die "Could not open login.cl\n"; print( F1 "esowfi\n"); print( F1 "unlearn esohdr\n"); print( F1 "esohdr \@$biaslist queryty=no obstype=zero\n"); print( F1 "esohdr \@$flathighlist queryty=no obstype=flat\n"); print( F1 "esohdr \@$flatlowlist queryty=no obstype=flat\n"); print( F1 "logout\n" ); close ( F1 ); system( "cl" ); ############################################################################## #### #### #### (2) Overscan and Trim all images #### #### Make the master BIAS frame #### #### Bias subtract FLAT images #### #### Make FLATHIGH and FLATLOW combined images #### #### Divide FLATLOW/FLATHIGH to make master frame #### #### #### ############################################################################## unlink "login.cl" if -e "login.cl"; unlink "loginuser.cl" if -e "loginuser.cl"; system( "cp source\/login.cl \.\/login.cl" ); system( "cp source\/loginuser.cl \.\/loginuser.cl" ); open ( F1, ">>login.cl" ) || die "Could not open login.cl\n"; print( F1 "mscred verbose=yes backup=once bkuproo=ORIG\n"); print( F1 "ccdproc *.fits output=\"\" ccdtype=\"\" noproc=no oversca=yes trim=yes fixpix=no zerocor=no darkcor=no flatcor=no sflatcor=no biassec=\!biassec trimsec=\!trimsec fixfile=badpix zero=BIAS flat=SKYFLAT minrepl=1. interac=no functio=legendre order=1 sample=* naverag=1 niterat=1 low_rej=3. high_re=3. grow=0. \n"); print( F1 "zerocombine \@$biaslist output=BIAS.fits ccdtype=\"\" process=no\n"); print( F1 "ccdproc \@$flathighlist output=\"\" ccdtype=\"\" noproc=no oversca=yes trim=yes fixpix=no zerocor=yes darkcor=no flatcor=no sflatcor=no biassec=\!biassec trimsec=\!trimsec fixfile=badpix zero=BIAS flat=SKYFLAT minrepl=1. interac=no functio=legendre order=1 sample=* naverag=1 niterat=1 low_rej=3. high_re=3. grow=0. \n"); print( F1 "ccdproc \@$flatlowlist output=\"\" ccdtype=\"\" noproc=no oversca=yes trim=yes fixpix=no zerocor=yes darkcor=no flatcor=no sflatcor=no biassec=\!biassec trimsec=\!trimsec fixfile=badpix zero=BIAS flat=SKYFLAT minrepl=1. interac=no functio=legendre order=1 sample=* naverag=1 niterat=1 low_rej=3. high_re=3. grow=0. \n"); print( F1 "flatcombine \@$flathighlist output=FLATHIGH ccdtype=\"\" process=no subsets=no \n"); print( F1 "flatcombine \@$flatlowlist output=FLATLOW ccdtype=\"\" process=no subsets=no \n"); print( F1 "mscarith FLATLOW.fits / FLATHIGH.fits FLATLHRATIO.fits \n"); print( F1 "mscsplit FLATLHRATIO.fits output=FLATLHRATIO verbose+ \n"); print( F1 "noao \n"); print( F1 "imred \n"); print( F1 "ccdred verbose=yes\n"); print( F1 "unlearn ccdmask \n"); for ($i=1;$i<=8;$i++) { print( F1 "ccdmask FLATLHRATIO\_$i.fits BADPIX5$i.pl lsigma=5 hsigma=5 \n"); } print( F1 "logout\n" ); close ( F1 ); system( "cl" ); ############################################################################## #### #### #### (3) Backup and Cleanup #### #### #### ############################################################################## #unlink "login.cl" if -e "login.cl"; #unlink "loginuser.cl" if -e "loginuser.cl"; #unlink "logfile" if -e "logfile"; #unlink "WFI*.fits"; #print "Tarring up the BADPIX files...\n"; #system "tar cvf ${tarfile}.tar BADPIX*.pl\n"; #print "Gzipping ${tarfile}.tar...\n"; #system "gzip ${tarfile}.tar \n"; #print "\n Gzipping original images to save to tape.\n"; #print "This is going to take a while!!\n"; #system "gzip ORIG*.fits\n"; #system "gzip BIAS.fits\n"; #system "gzip FLATHIGH.fits\n"; #system "gzip FLATLOW.fits\n";