#! /star/local/bin/tcsh # # AMR 17/03/03 # allowance for no-DBG set version=2.2 nice +19 cat < 0) then set rout = `echo $dbgr $dbgw | awk '{print $1+$2}'` set rout = `echo $rout 20 | awk '{print $1*$2}'` set dbgr = `echo $dbgr 20 | awk '{print $1*$2}'` echo "Analysing annulus..." evselect -w 0 -V 0 table=$bg imageset=tempimB2 expression='ANNULUS(0,0,'$dbgr','$rout',DETX,DETY)' $parimages evselect -w 0 -V 0 table=$ev imageset=tempimE2 expression='ANNULUS(0,0,'$dbgr','$rout',DETX,DETY)' $parimages farith tempimB2 tempimE2 tempimE3 ADD fcarith tempimE3 1E-20 tempimE4 ADD farith tempimE3 tempimE4 tempEXP1 DIV set totegap = `echo $dbgsecut $elo | awk '{print $1-$2}'` set egap = `echo $totegap $dbgi | awk '{print $1/$2}'` echo "Double subtraction: "$dbgi" iterations of E-width: "$egap while ($i != $dbgi) set pi1=`echo $i $egap | awk '{print $1*$2}'` set pi1=`echo $elo $pi1 | awk '{print $1+$2}'` set pi1=`echo $pi1 | awk '{print int($1+0.5)}'` set pi2=`echo $pi1 $egap | awk '{print $1+$2}'` set pi2=`echo $pi2 | awk '{print int($1+0.5)}'` echo "Double subtraction: "$pi1" eV to "$pi2" eV" @ i = $i + 1 echo 'Creating DBG source annulus...iteration '$i evselect -w 0 -V 0 table=$ev imageset=tempimE1 expression='ANNULUS(0,0,'$dbgr','$rout',DETX,DETY) && PI>='$pi1'&&PI<='$pi2' && PATTERN<='$pat'' $parimages echo 'Creating DBG particle annulus...iteration '$i evselect -w 0 -V 0 table=$closed imageset=tempimP1 expression='ANNULUS(0,0,'$dbgr','$rout',DETX,DETY) && PI>='$pi1'&&PI<='$pi2' && PATTERN<='$pat'' $parimages echo 'Creating DBG full background annulus...iteration '$i evselect -w 0 -V 0 table=$bg imageset=tempimB1 expression='ANNULUS(0,0,'$dbgr','$rout',DETX,DETY) && PI>='$pi1'&&PI<='$pi2' && PATTERN<='$pat'' $parimages set Ects = `fimgstat tempimE1 0 99999999 | grep sum | awk '{print $8}'` set Pcts = `fimgstat tempimP1 0 99999999 | grep sum | awk '{print $8}'` set Bcts = `fimgstat tempimB1 0 99999999 | grep sum | awk '{print $8}'` set scPcts = `echo $Pcts $EPscale | awk '{print $1*$2}'` set scBcts = `echo $Bcts $EBscale | awk '{print $1*$2}'` #echo $Ects $Pcts $Bcts $scPcts $scBcts set Ects = `echo $Ects $scPcts | awk '{print $1-$2}'` set scBcts = `echo $scBcts $scPcts | awk '{print $1-$2}'` set diff = `echo $Ects $scBcts | awk '{print $1-$2}'` set difffrac = `echo $diff $scBcts | awk '{print $1/$2}'` #echo $Ects $scBcts $diff echo 'Background correction factor... '$difffrac echo 'Creating DBG exposure map...iteration '$i eexpmap -w 0 -V 0 attitudeset=$att pimin=$pi1 pimax=$pi2 imageset=im_$root'.fits' expimageset=tempexp1 eventset=$ev usedss=no echo 'DBG exposure map created...' farith tempexp1 tempEXP1 tempexp2 MUL set Expcts = `fimgstat tempexp2 0 99999999 | grep sum | awk '{print $8}'` #echo $Expcts set expscale = `echo $diff $Expcts | awk '{print $1/$2}'` fcarith tempexp1 $expscale tempimE6 MUL if ($i == 1) then cp tempimE6 tempDBG$i else @ j = $i - 1 farith tempDBG$j tempimE6 tempDBG$i ADD endif rm tempim?? rm tempexp? end cp tempDBG$i imsebg_$root'.fits' cphead im_$root'.fits' imsebg_$root'.fits' scale=Y else cp im_$root'.fits' tempDBG0 fcarith tempDBG0 0 imsebg_$root'.fits' MUL clobber=Y cphead im_$root'.fits' imsebg_$root'.fits' scale=Y endif echo 'Creating double background (photons)...' if (-e imdbgph_$root'.fits') then rm -f imdbgph_$root'.fits' endif farith imbgps_$root'.fits' imsebg_$root'.fits' imdbgph_$root'.fits' ADD echo 'Creating total background (double background photons + particles)...' if (-e imtotbg_$root'.fits') then rm -f imtotbg_$root'.fits' endif farith imdbgph_$root'.fits' imscp_$root'.fits' imtotbg_$root'.fits' ADD echo 'Subtracting total background...' if (-e imbgs_$root'.fits') then rm -f imbgs_$root'.fits' endif farith im_$root'.fits' imtotbg_$root'.fits' imbgs_$root'.fits' SUB echo 'Creating detector mask...' emask -w 0 -V 0 expimageset=imexp_$root'.fits' detmaskset=immsk_$root'.fits' threshold1=0.25 threshold2=0.5 cphead imexp_$root'.fits' immsk_$root'.fits' scale=Y echo 'Exposure correcting...' if (-e imbgsc_$root'.fits') then rm -f imbgsc_$root'.fits' endif farith imbgs_$root'.fits' imexp_$root'.fits' imbgsc_$root'.fits' DIV echo 'Masking...' if (-e imbgscm_$root'.fits') then rm -f imbgscm_$root'.fits' endif farith imbgsc_$root'.fits' immsk_$root'.fits' imbgscm_$root'.fits' MUL rm tempEXP1 rm tempDBG? echo 'ImageBGsub Completed.' exit