#! /bin/sh

# Batch pour analyse des images de mires

usage="mire [-s(kip sextractor)] nom.fits reperes.txt timing.txt"

skip_sextractor=false;
while getopts s flag ; do
    case $flag in
	s) skip_sextractor=true;;
	\?) echo $usage; exit 1;;
    esac
done
shift `expr "$OPTIND" - 1`


echo "********** Image : $1 ****"

PATH_TO_MIRE="/home/meynadie/svn/mire"

CATALOG=$(basename $1 .fits).cat
if test $skip_sextractor == false
then
    rm -f $CATALOG mire.param
    echo "Détection d'objets..."
    cp -f $PATH_TO_MIRE/mire.param .
    sex -c $PATH_TO_MIRE/mire.sex $1
    mv test.cat $CATALOG
fi

echo "Mesures géométriques..."
OUTPUT_FILENAME=$(basename $1 .fits).mes
python $PATH_TO_MIRE/process.py -c $CATALOG -r $2 -o test.fits -m $OUTPUT_FILENAME -t $3





exit 0