rev1products (version 1.5)

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

###########################################################################
#
# 
# SYNTAX: rev1products
#
# BRIEFLY: Generate the rev1 data products.
#
# DESCRIPTION: This routine generates the rev 1 data products which will
# DESCRIPTION: not be part of rev2.
# DESCRIPTION: These include the following: 
# DESCRIPTION: <ol>
# DESCRIPTION: <li> Detector and sky coordinate
# DESCRIPTION:      FITS format images for each event file.
# DESCRIPTION: <li> GIF format sky coordinate images which are summed over
# DESCRIPTION:      all event files for each instrument.
# DESCRIPTION: <li> Quick analysis (sqaplot and gqaplot) plots and outputs
# DESCRIPTION:      text output for each filtered event file.
# DESCRIPTION:      Note that sqaplot is run on event file which have 
# DESCRIPTION:      already had the hot and flickering pixels removed.
# DESCRIPTION: </ol>
#
# VERSION: 1.5
#
# HISTORY: 0.0 -> 1.0 9/11/96
# HISTORY: Deleted creation of images and GIFs since they are now made in 
# HISTORY: the
# HISTORY: images subroutine. Detector coordinate images are still made here.
# HISTORY: 
# HISTORY: 1.0 -> 1.1 11/15/96
# HISTORY: Deleted the quick look ASCII output files. These were deemed
# HISTORY: unnecessary by the GOF and the sqaplot output files produced
# HISTORY: by FTOOLS 3.6 had extremely long lines which were causing the
# HISTORY: FITS wrapping software to choke
# HISTORY: 
# HISTORY: 1.1 -> 1.2 11/20/96
# HISTORY: The last change caused a bug. The quick look ascii output files 
# HISTORY: were changed to "NONE". Instead of not creating no output file
# HISTORY: it created one named "NONE" (at least for gqaplot). The output file
# HISTORY: has been changed back to what it was before, but the output file
# HISTORY: is explicitly removed. Also discovered from this bug that 
# HISTORY: sqaplot/gqaplot can print error messages to stdout.
# HISTORY: Now the script will log an error if anything is written to stdout
# HISTORY: Also, now explicitly specify first extension in event files for 
# HISTORY: sqaplot. The current version of gqaplot does not seem to understand
# HISTORY: this convention.
# HISTORY: 
# HISTORY: 1.2 -> 1.3 11/25/96
# HISTORY: Now remove lines with "chips with events" from combined 
# HISTORY: stdout+stderr in order to avoid extraneous error messages.
# HISTORY: Also inserted missing error level (2) in ftool_test call for 
# HISTORY: [s|g]qaplot calls. This was probably causing me to mistake stderr
# HISTORY: for stdout previously.
# HISTORY: 12/11/96 Supplied a missing "|" when catting together stdout
# HISTORY: and stderr
# HISTORY: for sqaplot logging. Also changed $? to $code in sqaplot
# HISTORY: ftool_test call.
# HISTORY: 
# HISTORY: 1.3 -> 1.4 1/14/97
# HISTORY: Went back to checking for sqaplot errors in the normal way.
# HISTORY: 
# HISTORY: 1.4 -> 1.5 3/25/97
# HISTORY: removed code for creating detector images
#
##############################################################################
#DEBUG=1

$UTIL/milestone "Generating Revision 1 data products"

###############################
# sqa/gqa plots
################################
list=$($UTIL/generate_filename event any any any any )
list=$(ls $list )
for event in $list ; do

     inst=$(   $UTIL/parse_filename inst    $event )
     index=$(  $UTIL/parse_filename index   $event )
     mode=$(   $UTIL/parse_filename mode    $event)
     bitrate=$($UTIL/parse_filename bitrate $event)

     ps=$( $UTIL/generate_filename quickps  $inst $index $mode $bitrate )
     out=$($UTIL/generate_filename quickout $inst $index $mode $bitrate )


     $UTIL/log_entry "Generating quick look analysis of $event"

     rm -f $out
     rm -f pgplot.ps
     rm -f allout.tmp

     case "$inst" in
     s?)
          ####################
          # SIS
          ####################
          $UTIL/setup_parfile $FTOOLS/sqaplot.par infile=${event}[1]  \
                                                  outfile=$out   \
                                                  eventfile=NONE \
                                                  split=40       \
                                                  device="/ps"  
          $FTOOLS/sqaplot >stdout.log 2>stderr.log
          code=$?
          $UTIL/ftool_test sqaplot $code $0 2 stdout.log stderr.log
          ;;
     g?)
          ######################
          # GIS
          ######################
          $UTIL/setup_parfile $FTOOLS/gqaplot.par infile=${event}  \
                                                  outfile=$out   \
                                                  device="/ps"

           
          $FTOOLS/gqaplot >stdout.log 2>stderr.log
          code=$?
          cat stdout.log stderr.log >allout.tmp
          $UTIL/ftool_test gqaplot $? $0 2 stdout.log stderr.log allout.tmp
          ;;
     *)
          #####################
          # unknown
          ######################
          $UTIL/exception $0 1 "Unknown instrument $inst"
     esac

     mv -f pgplot.ps $ps
     rm -f $out
     rm -f allout.tmp


done

          
                                                  

          


     

          



exit 0