#!/bin/csh -f
# A standard processing shell script
if ($1 == ^) then
   caterr <<'EOF'

   A standard processing shell script
     usage: autofocas catalog Nmin sigma size [first last minsky maxsky]
     Arguments:
	catalog - catalog to be processed
        Nmin - minimum number of stars to be found by findstars
        sigma - maximum (sigma r1)/<r1> for stars in findstars
	size - the psf size (<=15) for template
     Optional detect parameters:
	first - first line for detection
	last - last line for detection
	minsky - minimum sky in initial sky estimate
	maxsky - maximum sky in initial sky estimate

      Output: Diagnostics from the processing.
 
     The shell script is as follows:
	echo Processing of catalog begun `date`
	echo Detection begun `date`
        detect catalog
	echo Sky evaluation begun `date`
	sky catalog
	skycorrect catalog
	echo Evaluation begun `date`
        evaluate catalog
	echo Splitting begun `date`
        splits catalog
	echo Autopsf begun `date`
        autopsf catalog Nmin sigma size
	echo Resolution begun `date`
        resolution catalog
	echo Processing of catalog finished `date`
     where the arguments are as given above.
'EOF'
  exit
endif
 
set cat=$1
set Nmin=$2
set sigma=$3
set size=$4

shift; shift; shift; shift
echo Processing of $cat begun `date`
echo Detection begun `date`
detect $cat $*
echo Sky evaluation begun `date`
sky $cat
skycorrect $cat
echo Evaluation begun `date`
evaluate $cat
echo Splitting begun `date`
splits $cat
echo Autopsf begun `date`
autopsf $cat $Nmin $sigma $size
echo Resolution begun `date`
resolution $cat
echo Processing of $cat finished `date`
