eventinfo (version 1.6)
You can also look at:
#! /usr/bin/ksh
###########################################################################
#
#
# SYNTAX: eventinfo
#
# BRIEFLY: Create a descriptive list of all the event files.
#
# DESCRIPTION: This routine creates an HTML page giving detailed
# DESCRIPTION: information about the event files.
# DESCRIPTION: The files are sorted by instrument, mode and bit-rate.
# DESCRIPTION: The following information is given for each file:
# DESCRIPTION: <ul>
# DESCRIPTION: <li> Exposure (not dead-time corrected)
# DESCRIPTION: <li> Counts
# DESCRIPTION: <li> Count rate
# DESCRIPTION: <li> A list of modal keyword values. All of keywords
# DESCRIPTION: whose values change within a particular
# DESCRIPTION: mode-bitrate group are listed.
# DESCRIPTION: </ul>
#
# VERSION: 1.6
#
# HISTORY: 0.0 -> 1.0 9/23/96
# HISTORY: Now include TLM_FILE among the unique keywords to be listed.
# HISTORY:
# HISTORY: 1.0 -> 1.1 1/3/97
# HISTORY: Now record total exposure times and number events in the job par
# HISTORY:
# HISTORY: 1.1 -> 1.2 2/4/97
# HISTORY: Added quotes to add_parameter arguments
# HISTORY: converted from floatint and floatdiv STOOLS to equals
# HISTORY:
# HISTORY: 1.2 -> 1.3 3/18/97
# HISTORY: Added a check for consistency between evt time and isas_time
# HISTORY:
# HISTORY: 1.3 -> 1.4 4/22/97
# HISTORY: Added ORIGMODE to the unique SIS keywords
# HISTORY:
# HISTORY: 1.4 -> 1.5 5/9/97
# HISTORY: Now report all times in kiloseconds
# HISTORY:
# HISTORY: 1.5 -> 1.6 5/13/97
# HISTORY: Supplied missing parenthesis when calculating kunftime and kevttime
#
##############################################################################
#DEBUG=1
$UTIL/milestone "Generating Event file information page"
evttimetoll=$($UTIL/read_parfile $PARFILE evttimetoll )
eventinfo=$($UTIL/generate_filename eventinfo )
header=$( $UTIL/generate_filename header )
#########################
# title, etc.
#########################
seq=$($UTIL/read_parfile $JOBPAR sequence )
rm -f $eventinfo
echo "<html>" >>$eventinfo
echo "<title>" >>$eventinfo
echo "ASCA Sequence $seq Event File Info" >>$eventinfo
echo "</title>" >>$eventinfo
echo "<body>" >>$eventinfo
echo "<h1>ASCA Sequence $seq Event File Info</h1>" >>$eventinfo
echo "This page lists the filtered and" >>$eventinfo
echo "unfiltered event files sorted by instrument and mode." >>$eventinfo
echo "Exposure times (not dead time corrected) and count rates" >>$eventinfo
echo "are given for each file along with a list of FITS keywords" >>$eventinfo
echo "describing the observation mode." >>$eventinfo
echo "Where two values are separated by a slash, the first value" >>$eventinfo
echo "refers to the filtered event file and the" >>$eventinfo
echo "second to the corresponding unfiltered file." >>$eventinfo
echo "<p>" >>$eventinfo
echo "The following information is also available:" >>$eventinfo
echo "<ul>" >>$eventinfo
echo "<li><strong><a href=\"${header}\">" >>$eventinfo
echo "The processing header page</a></strong>" >>$eventinfo
echo "</ul>" >>$eventinfo
echo "Here is in index of the event files for each instrument:" >>$eventinfo
echo "<ul>" >>$eventinfo
echo "<li><a href=\"#s0\">SIS 0</a>" >>$eventinfo
echo "<li><a href=\"#s1\">SIS 1</a>" >>$eventinfo
echo "<li><a href=\"#g2\">GIS 2</a>" >>$eventinfo
echo "<li><a href=\"#g3\">GIS 3</a>" >>$eventinfo
echo "</ul>" >>$eventinfo
##############################
# group by instrument
##############################
for inst in s0 s1 g2 g3; do
$UTIL/log_entry "Summing time and events for $inst event files"
case "$inst" in
s?)
#############
# SIS
#############
display=SIS${inst#s}
modes="0[23]" ;;
g?)
###############
# GIS
###############
display=GIS${inst#g}
modes=70;;
*) $UTIL/exception $0 "unknown instrument $inst";;
esac
##########################################
# total times and events and count files
##########################################
typeset -i unfevents=0
unftime=0.
typeset -i evtevents=0
evttime=0.
typeset -i evtfiles=0
typeset -i unffiles=0
list=$($UTIL/generate_filename unfiltered $inst any "$modes" any )
list=$(ls $list 2>/dev/null )
for unfiltered in $list; do
index=$($UTIL/parse_filename index $unfiltered )
bitrate=$($UTIL/parse_filename bitrate $unfiltered )
mode=$($UTIL/parse_filename mode $unfiltered )
filtered=$($UTIL/generate_filename event $inst $index $mode $bitrate)
#################
# unfiltered
##################
events=$($UTIL/read_fits_keyword ${unfiltered}[0] NEVENTS )
let unfevents=$unfevents+$events
time=$($UTIL/read_fits_keyword $unfiltered[0] ONTIME )
unftime=$($STOOLS/equals $unftime + $time )
############################
# debugging output
############################
if [ -n "$DEBUG" ]; then
echo ${0##*/}: unfiltered=$unfiltered
echo ${0##*/}: events=$events
echo ${0##*/}: unfevents=$unfevents
echo ${0##*/}: time=$time
echo ${0##*/}: unftime=$unftime
fi
let unffiles=$unffiles+1
#################
# filtered
##################
if [ -s $filtered ]; then
events=$($UTIL/read_fits_keyword $filtered[0] NEVENTS )
let evtevents=$evtevents+$events
time=$($UTIL/read_fits_keyword $filtered[0] ONTIME )
evttime=$($STOOLS/equals $evttime + $time )
let evtfiles=$evtfiles+1
########################
# debugging output
########################
if [ -n "$DEBUG" ]; then
echo ${0##*/}: filtered=$filtered
echo ${0##*/}: events=$events
echo ${0##*/}: evtevents=$evtevents
echo ${0##*/}: time=$time
echo ${0##*/}: evttime=$evttime
fi
fi
done
evttime=$($STOOLS/equals "int($evttime +.5)" )
unftime=$($STOOLS/equals "int($unftime +.5)" )
unfrate=$($STOOLS/equals "$unfevents / $unftime" )
evtrate=$($STOOLS/equals "$evtevents / $evttime" )
#############################
# record totals in par file
#############################
$UTIL/add_parameter $JOBPAR ${inst}unftime "$unftime" r \
"total exposure in $inst unfiltered event files"
$UTIL/add_parameter $JOBPAR ${inst}evttime "$evttime" r \
"total exposure in $inst filtered event files"
$UTIL/add_parameter $JOBPAR ${inst}unfevents "$unfevents" r \
"total events in $inst unfiltered event files"
$UTIL/add_parameter $JOBPAR ${inst}evtevents "$evtevents" r \
"total events in $inst filtered event files"
########################################
# check for consistency with ISAS times
########################################
isas_time=$($UTIL/read_parfile $JOBPAR ${inst%?}is_isas_time )
err=$($STOOLS/equals "($evttime - $isas_time )/$isas_time " )
if [ $($STOOLS/floatcmp $err $evttimetoll) = "lt" ]; then
$UTIL/exception $0 2 "Possible missing filtered time for $display"
fi
###############################
# convert times to kiloseconds
###############################
kunftime=$($STOOLS/equals "int($unftime /100 +.5 )/10" )
kevttime=$($STOOLS/equals "int($evttime /100 +.5 )/10" )
echo "<hr>" >>$eventinfo
echo "<h2><a name=\"$inst\">${display}:</a></h2>" >>$eventinfo
echo "<strong>Total Exposure: " >>$eventinfo
echo "</strong>${kevttime} / ${kunftime} kiloseconds<br>" >>$eventinfo
echo "<strong>Total Events: " >>$eventinfo
echo "</strong>${evtevents} / ${unfevents} events<br>" >>$eventinfo
echo "<strong>Mean Count Rate: " >>$eventinfo
echo "</strong>${evtrate} / ${unfrate} events per second<br>" >>$eventinfo
echo "<strong>Number of Files:" >>$eventinfo
echo "</strong>${evtfiles} / ${unffiles} " >>$eventinfo
####################
# individual files
####################
###################################
# loop through modes and bitrates
###################################
case "$inst" in
s?) modes="02 12 01 03"
;;
g?) modes="70 71"
;;
*) $UTIL/exception $0 "unknown instrument $inst"
;;
esac
for mode in $modes; do
########################
# display name for mode
#########################
case "$mode" in
01) modename="FAINT";;
02) modename="BRIGHT";;
12) modename="BRIGHT2";;
03) modename="FAST";;
70) modename="PH";;
71) modename="MPC";;
*) $UTIL/exception $0 "Unknown mode $mode";;
esac
for bitrate in h m l; do
###########################
# display name for bitrate
###########################
case "$bitrate" in
h) ratename="HIGH";;
m) ratename="MEDIUM";;
l) ratename="LOW";;
*) $UTIL/exception $0 "Unknown bitrate $bitrate";;
esac
#######################################
# determine which keywords are unique
#######################################
case "$inst" in
s[01])
######################
# SIS
######################
minimum="DATAMODE BIT_RATE"
minimum=""
i=S${inst#s}
modal=" ${i}_AEPOW ${i}_AEANL ${i}_DESTA ${i}BIASHV"
modal="$modal ${i}_ARENA"
modal="$modal ${i}_LVENA ${i}_LVDU0 ${i}_LVDU1 ${i}_LVDU2"
modal="$modal ${i}_LVDU3 ${i}_LVDL0 ${i}_LVDL1 ${i}_LVDL2"
modal="$modal ${i}_LVDL3 ${i}_ARIO0 ${i}_ARIO1 ${i}_ARIO2"
modal="$modal ${i}_ARIO3 ${i}_STAH0 ${i}_STAH1 ${i}_STAH2"
modal="$modal ${i}_STAH3 ${i}_ENDH0 ${i}_ENDH1 ${i}_ENDH2"
modal="$modal ${i}_ENDH3 ${i}BIASOF ${i}CCDPOW ${i}CCDMOD"
modal="$modal ${i}CCDLST ${i}_STAV0 ${i}_STAV1 ${i}_STAV2"
modal="$modal ${i}_STAV3 ${i}_ENDV0 ${i}_ENDV1 ${i}_STAV3"
modal="$modal ${i}_ENDV0 ${i}_ENDV1 ${i}_ENDV2 ${i}_ENDV3"
modal="$modal ${i}_GRADE ${i}_EVTR0 ${i}_EVTR1 ${i}_EVTR2"
modal="$modal ${i}_EVTR3 ${i}_SPTR0 ${i}_SPTR1 ${i}_SPTR2"
modal="$modal ${i}_SPTR3 ${i}STCLK"
modal="$modal TLM_FILE ORIGMODE"
;;
g[23])
######################
# GIS
######################
minimum="DATAMODE BIT_RATE"
minimum=""
modal="PHA_BINS RISEBINS TIMEBINS SP_BINS RAWXBINS RAWYBINS"
modal="$modal POWER BYPASS A_POWER HVH_POW HVL_POW HV_RED"
modal="$modal HVH_LVL HVL_LVL GAIN LE_DS CPU2 CPU3 CPU_SEL"
modal="$modal CPU_DSCN RBM_POW RBM_MFLG RBM_AUTO RBM_FLVL"
modal="$modal RBM_LDL RT_LD RT_UD RT_B_CD ANO_SEL ANO_TUNE"
modal="$modal POS_DET R_DSCR S_DSCR PH_TUNE MASK_1 M1_LOGIC"
modal="$modal MASK_2 M2_RGN PH_EVENT CETR_X_P CETR_Y_P "
modal="$modal CETR_X_F CETR_Y_F R_DSCR_P R_DSCR_F SP_A_L_P "
modal="$modal SP_A_U_P SP_B_P SP_C_P SP_A_L_F SP_A_U_F "
modal="$modal SP_B_F SP_C_F M2_XL M2_XU M2_YL M2_YU "
modal="$modal L1_S_DWN LD_S_DWN M2_S_DWN X_S_DWN 1D_S_DWN "
modal="$modal C2_PGVER C3_PGVER X_AN_USE SP_PH_P SP_PH_F "
modal="$modal MASK1_X MASK1_Y Y_AN_USE"
modal="$modal TLM_FILE"
;;
*)
$UTIL/exception $0 "Unknown instrument $inst";;
esac
#####################################
# get a list of the unfiltered files
#####################################
list=$($UTIL/generate_filename unfiltered \
$inst any $mode $bitrate )
list=$(ls $list 2>/dev/null )
################################################################
# skip all modal keywords if there are less than 2 event files
################################################################
nfiles=$(echo $list |wc -w )
if [ $nfiles -lt 2 ]; then
modal=""
fi
###################################
# filter out the unique keywords
###################################
unique=""
for key in $modal; do
same="yes"
value=""
for unfiltered in $list; do
if [ "$same" = "yes" ]; then
oldvalue="$value"
value=$($UTIL/read_fits_keyword $unfiltered[0] \
$key )
if [ -n "$oldvalue" -a "$oldvalue" != "$value" ]
then
same="no"
fi
#########################
# debugging output
#########################
if [ -n "$DEBUG" ]; then
echo ${0##*/}: unfiltered=$unfiltered
echo ${0##*/}: key=$key
echo ${0##*/}: value=$value
echo ${0##*/}: same=$same
fi
fi
done
if [ "$same" = "no" ]; then
unique="$unique $key"
fi
done
keywords="$minimum $unique"
#############################
# debugging output
###########################
if [ -n "$DEBUG" ]; then
echo ${0##*/}: unique=$unique
fi
########################
# heading
#########################
if [ $nfiles -gt 0 ]; then
echo "<h3>${display} $modename mode event files">>$eventinfo
echo "with $ratename bit rate</h3>" >>$eventinfo
echo "<ul>" >>$eventinfo
fi
###################
# list the files
###################
for unfiltered in $list; do
$UTIL/log_entry "listing $unfiltered"
index=$($UTIL/parse_filename index $unfiltered )
filtered=$($UTIL/generate_filename event \
$inst $index $mode $bitrate)
########################
# file name
########################
if [ -s "$filtered" ]; then
echo "<li> <tt>${filtered}</tt> / " >>$eventinfo
echo "<tt>$unfiltered</tt>" >>$eventinfo
else
echo "<li> <tt>$unfiltered</tt>" >>$eventinfo
fi
echo "<ul>" >>$eventinfo
######################
# times and events
#####################
#################
# unfiltered
##################
unfevents=$($UTIL/read_fits_keyword $unfiltered[0] NEVENTS )
unftime=$($UTIL/read_fits_keyword $unfiltered[0] ONTIME )
#################
# filtered
##################
evtevents=0
evttime=0.
if [ -s $filtered ]; then
evtevents=$($UTIL/read_fits_keyword $filtered[0] \
NEVENTS )
evttime=$($UTIL/read_fits_keyword $filtered[0] \
ONTIME )
fi
evttime=$($STOOLS/equals "int($evttime+.5)" )
unftime=$($STOOLS/equals "int($unftime+.5)" )
unfrate=$($STOOLS/equals "$unfevents / $unftime" )
evtrate=$($STOOLS/equals "$evtevents / $evttime" )
kevttime=$($STOOLS/equals "int($evttime/100+.5)/10" )
kunftime=$($STOOLS/equals "int($unftime/100+.5)/10" )
echo "<li><strong>Exposure: " >>$eventinfo
echo "</strong>${kevttime} / ${kunftime}" >>$eventinfo
echo " kiloseconds" >>$eventinfo
echo "<li><strong>Events:</strong> " >>$eventinfo
echo "${evtevents} / ${unfevents} events" >>$eventinfo
echo "<li><strong>Count Rate: </strong>" >>$eventinfo
echo "${evtrate} /" >>$eventinfo
echo "${unfrate} events per second" >>$eventinfo
########################
# keywords
########################
echo "<li> <strong>Selected FITS Keywords:</strong>" \
>>$eventinfo
echo "<ul>" >>$eventinfo
for key in $keywords; do
value=$($UTIL/read_fits_keyword $unfiltered[0] $key )
echo "<li> $key = $value" >>$eventinfo
done
echo " </ul>" >>$eventinfo
echo " </ul><p>" >>$eventinfo
done ;# file loop
###################################################
# end of list of files for this mode and bitrate
###################################################
if [ $nfiles -gt 0 ]; then
echo "</ul>" >>$eventinfo
fi
done ;# bitrate loop
done ;# mode loop
done #; inst loop
echo "</body>" >>$eventinfo
echo "</html>" >>$eventinfo
exit 0