sourceinfo (version 1.1)

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

###########################################################################
#
# SYNTAX: sourceinfo
#
# BRIEFLY: Create an HTML page listing the detected sources
#
# DESCRIPTION: This routine creates an HTML page describing the sources
# DESCRIPTION: detected in processing.
#
# VERSION: 1.1
#
# HISTORY: 0.0 -> 1.0 5/9/97
# HISTORY: Now reports extended flag.
# HISTORY:
# HISTORY: 1.0 -> 1.1 5/23/97
# HISTORY: Now correctly reports the resolution of the GIS source image.
#
###########################################################################
#DEBUG=1

$UTIL/milestone "Creating HTML source list"

sourceinfo=$($UTIL/generate_filename sourceinfo)
header=$($UTIL/generate_filename header)
seq=$($UTIL/read_parfile $JOBPAR sequence)

rm -f $sourceinfo

##############
# Title, etc.
##############

echo "<HTML>"                                                     >>$sourceinfo
echo "<!-- This page generated by $0 on $(date) -->"              >>$sourceinfo
echo "<HEAD>"                                                     >>$sourceinfo
echo "<TITLE>ASCA Sequence ${seq} Source List</TITLE>"            >>$sourceinfo
echo "</HEAD>"                                                    >>$sourceinfo

echo "<BODY>"                                                     >>$sourceinfo
echo "<H1>ASCA Sequence $seq Source List</H1>"                    >>$sourceinfo

echo "This page lists the sources detected in processing for"     >>$sourceinfo
echo "this observation."                                          >>$sourceinfo
echo "The counts quoted below are the raw counts in the"          >>$sourceinfo
echo "extraction circle"                                          >>$sourceinfo
echo "from the screened BRIGHT or PH mode data."                  >>$sourceinfo
echo "No corrections have been made for"                          >>$sourceinfo
echo "background or vignetting."                                  >>$sourceinfo

echo "<P>"                                                        >>$sourceinfo

echo "The following information is also available:"               >>$sourceinfo
echo "<UL>"                                                       >>$sourceinfo
echo "  <LI><STRONG><A HREF=\"${header}\">"                       >>$sourceinfo
echo "  The processing header page</A></STRONG>"                  >>$sourceinfo
echo "</UL>"                                                      >>$sourceinfo


echo "<HR>"                                                       >>$sourceinfo

############################
# Loop over source catalogs
############################
list=$($UTIL/generate_filename sourcecat any any any any)
list=$(ls $list 2>/dev/null)
for sourcecat in $list; do

    inst=$($UTIL/parse_filename inst $sourcecat )
    dimen=$($UTIL/parse_filename index $sourcecat)
    mode=$($UTIL/parse_filename mode $sourcecat)

    ################################
    # Trim leading zeros from dimen
    ################################
    let dimen=$dimen

    ###################
    # Debugging output
    ###################
    if [ -n "$DEBUG" ]; then
        echo ${0##*/}: sourcecat=$sourcecat
        echo ${0##*/}: inst=$inst
        echo ${0##*/}: dimen=$dimen
        echo ${0##*/}: mode=$mode
    fi

    ##########
    # Heading
    ##########
    case "$inst" in
    sis)
        echo "<H2>Sources detected in combined SIS0 and SIS1 data</H2>" \
                                                               >>$sourceinfo
         ;;
    gis)
        echo "<H2>Sources in combined GIS2 and GIS3 data with $dimen" \
             "pixel resolution</H2>"                           >>$sourceinfo
        ;;
    esac

    ###################
    # List all sources
    ###################

    nsources=$($UTIL/read_fits_keyword $sourcecat[1] NAXIS2)

    if [ $nsources -eq 0 ]; then
        echo "No sources were found in these data."            >>$sourceinfo
    else
        echo "<OL>" >>$sourceinfo

        typeset -i source=1
        while [ $source -le $nsources ]; do

            xpixel=$($UTIL/read_bintable $sourcecat xpixel $source)
            ypixel=$($UTIL/read_bintable $sourcecat ypixel $source)
            rpixel=$($UTIL/read_bintable $sourcecat rpixel $source)

            ra=$(  $UTIL/read_bintable $sourcecat RA  $source)
            dec=$( $UTIL/read_bintable $sourcecat Dec $source)
            rdeg=$($UTIL/read_bintable $sourcecat rdeg $source)

            ra=$(  $STOOL/equals "int(${ra}  *1000+.5)/1000")
            dec=$( $STOOL/equals "int(${dec} *1000+.5)/1000")
            rdeg=$($STOOL/equals "int(${rdeg}*60*10+.5)/10")

            hardcnts=$($UTIL/read_bintable $sourcecat hardcnts $source)
            softcnts=$($UTIL/read_bintable $sourcecat softcnts $source)

            echo "  <LI>"                                      >>$sourceinfo

            echo "  <STRONG>Sky coordinate central pixel:</STRONG>" \
                                                               >>$sourceinfo
            echo "  ($xpixel,$ypixel)<BR>"                     >>$sourceinfo

            echo "  <STRONG>R.A.:</STRONG>"                    >>$sourceinfo
            echo "  $ra degrees<BR>"                           >>$sourceinfo
            echo "  <STRONG>Dec.:</STRONG>"                    >>$sourceinfo
            echo "  $dec degrees<BR>"                          >>$sourceinfo

            echo "  <STRONG>Extraction radius:</STRONG>"       >>$sourceinfo
             echo "  $rpixel pixels =  $rdeg arcmin<BR>"       >>$sourceinfo

            echo "  <STRONG>Hard (>2 keV) counts:</STRONG>"    >>$sourceinfo
            echo "  $hardcnts<BR>"                             >>$sourceinfo

            echo "  <STRONG>Soft (<2 keV) counts:</STRONG>"    >>$sourceinfo
            echo "  $softcnts<BR>"                             >>$sourceinfo

            extended=$($UTIL/read_bintable $sourcecat extended $source)
            case "$extended" in
            T)
                echo "  This source is extended"               >>$sourceinfo;;
            F)
                echo "  This source is compact"                >>$sourceinfo;;
            *)
                $UTIL/exception $0 1 "Unknown extended flag $extended"
            esac

            echo "  <P>"                                       >>$sourceinfo
            echo ""                                            >>$sourceinfo

            let source=$source+1

        done

        echo "</OL>" >>$sourceinfo

    fi

done

echo "</BODY>"                                                 >>$sourceinfo
echo "</HTML>"                                                 >>$sourceinfo


exit 0