#! /bin/tcsh # NOTE: USER MAY HAVE TO EDIT THIS LINE TO FIND LOCAL tcsh # # UNIVERSITY OF LEICESTER # XMM-Newton EPIC Calibration # # Jenny Carter # jac48@star.le.ac.uk # 2006 # # PURPOSE: # To create exposure maps and reduce an event file # to include only those events that fall within a # given separation from a set of coordinates # # REQUIREMENTS: # The user must have downloaded the MasterList.txt of # observation details, and the script BGexpmerge. # The user must have an event list from which to select # the relevant events in the same directory as the list # and script mentioned above. # # SOFTWARE USED: # FTOOLS (various) # # # PROCEDURES CALLED: # BGexpmerge # # # WARNINGS AND ERRORS: # Error - search radius greater than 90 degrees. # Too large, select smaller serach radius. # Error - no component background information found. # Select a smaller search radius. # Error - Files and directories. Merge script and/or # Master table may not be in the correct directory. # Events file may not be in the correct directory. # Adjust locations accordingly. # # VERSION: # 1.0 200306 - original. # Version for blank sky event files website. JAC # 1.1 190606 - modification # Error message and comments corrected. JAC # 1.2 210606 - modification # Instead of deleting or directly appending # exposure extensions of evemts files, just append # 1.3 070806 - modification. JAC # Comments adapted # set version=1.3 # nice +19 cat <= 0 && $testGreater == 0 ) then # Within separation then take values and write to file set coincid = `echo $coincid 1 | awk '{print ($1 + $2)}'` # echo "Found exposure within range" $i $cosd $cosmaxDistRads if ($refill == Y || $refill == y) then echo $basicstring"P"$thisOBS$instr$thisEXP"BGEXMNR000.FIT" >> tempRDWriteexp # This may change to refer to another of the master obs attributes that refer to an index in the set of files # For example $dir"file"$index"BGEXMVR000.FIT" >> tempRDWriteexpV echo $basicstring"P"$thisOBS$instr$thisEXP"BGEXMVR000.FIT" >> tempRDWriteexpV else echo $basicstring"P"$thisOBS$instr$thisEXP"BGEXMNU000.FIT" >> tempRDWriteexp echo $basicstring"P"$thisOBS$instr$thisEXP"BGEXMVU000.FIT" >> tempRDWriteexpV endif echo $thisTLMIN1 $thisTLMAX1 >> tempPAIRS # Print out all this information to a subset file to be used to extract events # or/and sum up livetime value and liveti0n values set totallivetime = `echo $totallivetime $thisLivetime | awk '{print ($1 + $2)}'` set totalliveti01 = `echo $totalliveti01 $thisLiveti01 | awk '{print ($1 + $2)}'` set totalliveti02 = `echo $totalliveti02 $thisLiveti02 | awk '{print ($1 + $2)}'` set totalliveti03 = `echo $totalliveti03 $thisLiveti03 | awk '{print ($1 + $2)}'` set totalliveti04 = `echo $totalliveti04 $thisLiveti04 | awk '{print ($1 + $2)}'` set totalliveti05 = `echo $totalliveti05 $thisLiveti05 | awk '{print ($1 + $2)}'` set totalliveti06 = `echo $totalliveti06 $thisLiveti06 | awk '{print ($1 + $2)}'` set totalliveti07 = `echo $totalliveti07 $thisLiveti07 | awk '{print ($1 + $2)}'` # 130706 totalontime calculations set totalontime = `echo $totalontime $thisontime | awk '{print ($1 + $2)}'` set totalontime01 = `echo $totalontime $thisontime01 | awk '{print ($1 + $2)}'` set totalontime02 = `echo $totalontime $thisontime02 | awk '{print ($1 + $2)}'` set totalontime03 = `echo $totalontime $thisontime03 | awk '{print ($1 + $2)}'` set totalontime04 = `echo $totalontime $thisontime04 | awk '{print ($1 + $2)}'` set totalontime05 = `echo $totalontime $thisontime05 | awk '{print ($1 + $2)}'` set totalontime06 = `echo $totalontime $thisontime06 | awk '{print ($1 + $2)}'` set totalontime07 = `echo $totalontime $thisontime07 | awk '{print ($1 + $2)}'` if ($instr == EPN || $instr == PN || $instr == pn ) then set totalliveti08 = `echo $totalliveti07 $thisLiveti08 | awk '{print ($1 + $2)}'` set totalliveti09 = `echo $totalliveti07 $thisLiveti09 | awk '{print ($1 + $2)}'` set totalliveti10 = `echo $totalliveti07 $thisLiveti10 | awk '{print ($1 + $2)}'` set totalliveti11 = `echo $totalliveti07 $thisLiveti11 | awk '{print ($1 + $2)}'` set totalliveti12 = `echo $totalliveti07 $thisLiveti12 | awk '{print ($1 + $2)}'` set totalontime08 = `echo $totalontime $thisontime08 | awk '{print ($1 + $2)}'` set totalontime09 = `echo $totalontime $thisontime09 | awk '{print ($1 + $2)}'` set totalontime10 = `echo $totalontime $thisontime10 | awk '{print ($1 + $2)}'` set totalontime11 = `echo $totalontime $thisontime11 | awk '{print ($1 + $2)}'` set totalontime12 = `echo $totalontime $thisontime12 | awk '{print ($1 + $2)}'` endif else # Count unsuccessful tests set badCount = `echo $badCount 1 | awk '{print ($1 + $2)}'` endif endif end # Write type file for gti file, create GTI file if ( -e tempGTI ) rm -f tempGTI if ( -e tempGTIfits ) rm -f tempGTIfits touch tempGTI echo "START D" >> tempGTI echo "STOP D" >> tempGTI fcreate tempGTI tempPAIRS tempGTIfits fparkey "J.A. Carter" tempGTIfits CREATOR add=yes echo "SelectRADec: Number of coincidence files is: " $coincid " out of: " $nLines if ($coincid == 0) then # Clear up rm -f tempPAIRS rm -f tempRDWriteexp rm -f tempRDWriteexpV # Exit out of program if no components to the search area are found echo "ERROR: No relevant background areas found for your RA, declination and radius specifications" echo "Please widen the search radius, or choose different RA and declination values ...exiting" exit endif ######################### Take these observations and merge exposure maps ########################### # Non-vignetted exposure maps if ( -e ExpIndex ) rm -f ExpIndex ls `ls tempRDWriteexp` > ExpIndex set nexL=`wc -l ExpIndex | awk '{print $1}'` #echo 'File count, for exposure maps is: ' $nexL set i=0 while ($i != $nexL) @ i = $i + 1 #echo 'At file in list, or filename: ' $i set thisFile=`cat ExpIndex | head -$i | tail -1` #echo 'Filename now is: ' $thisFile $mergeScript $thisFile $instr $filter $mode".SelectMerge" 5 # SPECIFIC Script end # Vignetted exposure maps if ( -e ExpIndexV ) rm -f ExpIndexV ls `ls tempRDWriteexpV` > ExpIndexV set nexL=`wc -w ExpIndex | awk '{print $1}'` #echo 'File count, for exposure maps is: ' $nexL set i=0 while ($i != $nexL) @ i = $i + 1 #echo 'At file in list, or filename: ' $i set thisFile=`cat ExpIndexV | head -$i | tail -1` #echo 'Filename now is: ' $thisFile $mergeScript $thisFile $instr $filter $mode".SelectMergeV" 5 Y # SPECIFIC Script end rm -f ExpIndex ExpIndexV if ( -e tempRDWriteexp ) rm -f tempRDWriteexp if ( -e tempRDWriteexpV ) rm -f tempRDWriteexpV ##### Event file selection of events ############ echo "SelectRADec: Select appropriate events from event list: " if ($instr == EPN || $instr == PN || $instr == pn ) then # echo "PN evselect on gti" # -w 0 -v 0 evselect table=$events withfilteredset=Y filteredset=tempEvents \ destruct=Y keepfilteroutput=T \ expression='#XMMEA_EP && gti(tempGTIfits,TIME) && (PI>150)' else # echo "MOS evselect on gti" evselect table=$events withfilteredset=Y filteredset=tempEvents \ destruct=Y keepfilteroutput=T \ expression='#XMMEA_EM && gti(tempGTIfits,TIME) && (PI>150)' endif # Save temporary events file to final file as specified by the user set outevents='EventsSelected.FIT' mv -f tempEvents $outevents if ( -e tempPAIRS ) rm -f tempPAIRS if ( -e tempFIRST ) rm -f tempFIRST if ( -e tempGTI ) rm -f tempGTI echo 'SelectRADec task completed' exit