#! /bin/tcsh -f

echo "******************************"
echo "*  start barycenter_att.csh  *"
echo "******************************"
date

set att1=`ls $data_dir/$dir0/*AttHk*`
set att1_ctrl=`ls $data_dir/$dir0/*AttHk* | wc -l | awk '{print $1}'`
if ( $att1_ctrl == 1 ) then
 echo "OK: the attitude file $att1 exists"
 echo ""
 echo "Starting to apply barycentric correction to the attitude file ${att1}..."
 echo ""
 cp ${att1} $data_dir/$dir0/${dir0}ATTITUDE.ds
 echo "barycen withtable=yes table=${att1}:ATTHK timecolumn=TIME withsrccoordinates=true srcra="$RA_NOM" srcdec="$DEC_NOM" processgtis=no ephemeris=DE405 -w ${warn}" > ${data_dir}/${dir0}/bary.csh
 source ${data_dir}/${dir0}/bary.csh
 rm ${data_dir}/${dir0}/bary.csh
else
 echo "ERROR: the attitude file $att1 does not exist"
 echo "ERROR: the attitude file $att1 does not exist" >> $log_dir/messages.log
endif
