#!/bin/ksh
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# acis_step3_make_images.ksh
# 
# INPUT:    	acis_E300-10000_FLUXED_G2.fits, 
# 		${REGION_FOR_SPECTRUM}_sou.pi
#	       ($REGION_FOR_EXCLUDE)
# 
# OUTPUT:	$REGION_FOR_SPECTRUM.pi.jpg, 
#		$REGION_FOR_SPECTRUM.pi.ps,
#		$REGION_FOR_SPECTRUM.ps,
#		$REGION_FOR_SPECTRUM.jpg 
# 
# CALLS:	xspec
# 		dmstat
# 		convert
#		fimgtrim
#		$SCRIPTPATH/convert_region.pl
#		$SCRIPTPATH/overlay_region.pl
#		ds9
#		pstrim
#
# PARAMS:       $REGION_FOR_SPECTRUM
#               $REGION_FOR_EXCLUDE
#               $ROOT_NAME_FOR_SNR_SPECTRA
#		$YRANGE_MAX
#		$YRANGE_MIN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# - - - - - - - - - - - - PRELIMINARY STUFF - - - - - - - - - - - - -

# set -a

if [[ $SNRCAT_SCRIPT_PATH == "" ]]
then
  case $OSTYPE in
    solaris) SNRCAT_SCRIPT_PATH=/data/snrcat/development/bin ;;
    linux) SNRCAT_SCRIPT_PATH=/snrcat/development/bin ;;
    *) echo
       echo "	OS type $OSTYPE not supported at this time."
       echo 
       exit ;;
  esac
fi

echo $PATH | grep $SNRCAT_SCRIPT_PATH > /dev/null 2>&1

if [[ $? -ne 0 ]]
then
  PATH=$PATH:$SNRCAT_SCRIPT_PATH
fi

. setup.ksh

. $LHEASOFT/lhea-init.sh

echo
echo "	>>> `basename $0`"

check_set REGION_FOR_SPECTRUM="$REGION_FOR_SPECTRUM" \
 ROOT_NAME_FOR_SNR_SPECTRA=$ROOT_NAME_FOR_SNR_SPECTRA 

check_file REGION_FOR_EXCLUDE=$REGION_FOR_EXCLUDE

echo
echo "	ROOT_NAME_FOR_SNR_SPECTRA = $ROOT_NAME_FOR_SNR_SPECTRA"
echo "	REGION_FOR_SPECTRUM = $REGION_FOR_SPECTRUM"
echo "	REGION_FOR_EXCLUDE = $REGION_FOR_EXCLUDE" 
echo "	YRANGE_MAX = $YRANGE_MAX"  
echo "	YRANGE_MIN = $YRANGE_MIN"  
echo "	CLOBBER = $CLOBBER"
echo

acis_step3_make_images_part1.ksh

acis_step3_make_images_part2.ksh
