header (version 1.2)

You can also look at:
#! /usr/bin/ksh

###########################################################################
#
# 
# SYNTAX: header
#
# BRIEFLY: Create an HTML header page.
#
# DESCRIPTION: This routine creates an HTML page which gives basic 
# DESCRIPTION: information about the observation and processing.
# DESCRIPTION: This page also contains links to other information pages.
#
#
# VERSION: 1.2
#
# HISTORY: 0.0 -> 1.0 1/3/97
# HISTORY: Fixed spelling. only "principal" is an adjective
# HISTORY: 
# HISTORY: 1.0 -> 1.1 2/4/97
# HISTORY: Converted from float... STOOLS to equals
# HISTORY: now explicitly state the processing revision number after the
# HISTORY: script version number
# HISTORY: Now read observation coordinates directly from job.par instead
# HISTORY: of recalculating them from the euler angles
# HISTORY: 2/20/97 Duration now given in kiloseconds
# HISTORY: 
# HISTORY: 1.1 -> 1.2 2/22/97
# HISTORY: now round duration to nearest tenth of a kilosecond
# HISTORY: 3/17/97 straightened out galactic longitude and latitude
#
##############################################################################
#DEBUG=1

$UTIL/milestone "Creating sequence documentation"

##########################
# header page
#############################
header=$(    $UTIL/generate_filename header     )
eventinfo=$( $UTIL/generate_filename eventinfo  )
fileinfo=$(  $UTIL/generate_filename fileinfo   )
milestones=$($UTIL/generate_filename milestones )
sourceinfo=$($UTIL/generate_filename sourceinfo )


#####################
# debugging output
#####################
if [ -n "$DEBUG" ]; then
     echo ${0##*/}: header=$header
fi





rm -f $header

#########################
# title, etc.
#########################
seq=$($UTIL/read_parfile $JOBPAR sequence )

echo "<html>"                                                       >>$header
echo "<title>"                                                      >>$header
echo "ASCA Sequence $seq Header Page"                               >>$header
echo "</title>"                                                     >>$header
echo "<body>"                                                       >>$header
echo "<h1>ASCA Sequence $seq Header Page</h1>"                      >>$header

echo "This page gives a basic description of this sequence"       >>$header
echo "and references to more detailed information."               >>$header
echo "<p>"                                                        >>$header

echo "The following information is also available:"                  >>$header
echo "<ul>"                                                          >>$header
echo "<li> <a href=\"${eventinfo}\">Details of each event file</a>"  >>$header
echo "<li> <a href=\"${sourceinfo}\">A list of detected sources</a>" >>$header
echo "<li><a href=\"${fileinfo}\">A list of all files</a>"           >>$header
echo "<li><a href=\"${milestones}\">The processing log index</a>"    >>$header
echo "</ul>"                                                         >>$header

echo "<hr>"                                                          >>$header

#############################
# observation
#############################

object=$($UTIL/read_parfile $JOBPAR object )

ra=$( $UTIL/read_parfile $JOBPAR ra  )
dec=$($UTIL/read_parfile $JOBPAR dec )

Lii=$($UTIL/read_parfile $JOBPAR glon )
Bii=$($UTIL/read_parfile $JOBPAR glat )


ra=$( $STOOLS/equals "int(${ra}  * 1000 +.5)/1000 " )
dec=$($STOOLS/equals "int(${dec} * 1000 +.5)/1000 " )

Lii=$($STOOLS/equals "int(${Lii} * 1000 +.5)/1000 " )
Bii=$($STOOLS/equals "int(${Bii} * 1000 +.5)/1000 " )






#####################
# date
#####################
telem=$(ls ft* |grep -v fits |head -1 )
date=${telem#ft}
date=${date%%_*}

yr="19${date%????}"

mo=${date#??}
mo=${mo%%??}
case "$mo" in
01) mo=January ;;
02) mo=February ;;
03) mo=March ;;
04) mo=April ;;
05) mo=May ;;
06) mo=June ;;
07) mo=July ;;
08) mo=August ;;
09) mo=September ;;
10) mo=October ;;
11) mo=November ;;
12) mo=December ;;
*) $UTIL/exception $0 "Unknowm month $mo";;
esac

day=${date#????}
day=${day#0}

date="$mo ${day}, $yr"

#####################
# duration
#####################
duration=0.
for telem in $(ls ft??????_????.???? ); do

     time0=$($UTIL/read_fits_keyword $telem[1] MTIME0 )
     time1=$($UTIL/read_fits_keyword $telem[1] MTIME1 )
     time=$($STOOLS/equals "$time1 - $time0" )
     duration=$($STOOLS/equals "$duration + $time" )
     
     ########################
     # debugging output
     #########################
     if [ -n "$DEBUG" ]; then
          echo ${0##*/}: telem=$telem
          echo ${0##*/}: time0=$time0
          echo ${0##*/}: time1=$time1
          echo ${0##*/}: time=$time
          echo ${0##*/}: duration=$duration
     fi

done

duration=$($STOOLS/equals "int($duration/100+.5)/10" )

########################
# ISAS times
########################

sis_isas_time=$($UTIL/read_parfile $JOBPAR sis_isas_time )
gis_isas_time=$($UTIL/read_parfile $JOBPAR gis_isas_time )

sis_isas_time=$($STOOLS/equals "int($sis_isas_time/100+.5)/10" )
gis_isas_time=$($STOOLS/equals "int($gis_isas_time/100+.5)/10" )

     




echo "<h2>Observation Information</h2>"        >>$header
echo "<ul>"                                    >>$header
echo "<li> <strong>Object:</strong> $object"   >>$header
echo "<li> <strong>Nominal Pointing</strong> (degrees)"  >>$header
echo "     <ul>"                               >>$header
echo "     <li> <strong>R.A.=</strong>$ra <strong>Dec.=</strong>$dec" >>$header
echo "     <li> <strong>Lii=</strong>$Lii <strong>Bii=</strong>$Bii"  >>$header
echo "     </ul>"                                                     >>$header
echo "<li> <strong>Observation Date:</strong> $date"                  >>$header
echo "<li> <strong>Duration:</strong> $duration kiloseconds"          >>$header

echo "<li> <strong>Approximate SIS Exposure:</strong>"                >>$header
echo "$sis_isas_time kiloseconds"                                     >>$header

echo "<li> <strong>Approximate GIS Exposure:</strong>"                >>$header
echo "$gis_isas_time kiloseconds"                                     >>$header

echo "</ul>"                                                          >>$header
 

####################
# processing
####################
seqver=$($UTIL/read_parfile $JOBPAR seqprocnum )
procver=$($UTIL/read_parfile $PARFILE version )
ftools=${FTOOLS##*/ftools}
ftools=${ftools#.}
ftools=${ftools%/bin.host}

case "$procver" in
6.*) rev="(Revision 1+)";;
7.*) rev="(Revision 2)" ;;
*) rev="" ;;
esac

echo "<h2>Processing Information</h2>"                              >>$header
echo "<ul>"                                                         >>$header
echo "<li> <strong>Sequence Version:</strong> $seqver"              >>$header
echo "<li> <strong>Processing Version:</strong> $procver"           >>$header
echo "$rev"                                                         >>$header
echo "<li> <strong>FTOOLS Version:</strong> $ftools"                >>$header
echo "<li> <strong>Processing Date:</strong> $(date +'%b %e, %Y' )" >>$header
echo "</ul>"                                                        >>$header

#######################
# US PI
#######################
echo "<h2>US Principal Investigator</h2>"  >>$header
for param in uspiname \
             uspiaddr1 uspiaddr2 uspiaddr3 uspiaddr4 uspiaddr5 \
             uspiemail; do

     line=$($UTIL/read_parfile $JOBPAR $param)
     if [ -n "$line" ]; then
          echo "$line <br>" >>$header
     fi
done

#######################
# Japanese PI
#######################
echo "<h2>Japan Principal Investigator</h2>" >>$header
for param in jppiname \
             jppiaddr1 jppiaddr2 jppiaddr3 jppiaddr4 jppiaddr5 \
             jppiemail; do

     line=$($UTIL/read_parfile $JOBPAR $param)
     if [ -n "$line" ]; then
          echo "$line <br>" >>$header
     fi
done



#################
# closing
##################
echo "</body>" >>$header
echo "</html>" >>$header


exit 0