#!/usr/bin/env tcsh 
# Copyright 2005, 2006 University of Leiden.
#
# This file is part of MIA+EWS.
#
# MIA+EWS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# MIA+EWS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with MIA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#!/usr/bin/env tcsh 
#   Usage:
#   dispVis inputFiles (blank separated list of raw files) outputBaseName 
#
#
if ( $# < 2 ) then
   echo "   dispCenter needs at least 2 input parameters "
   exit 1
endif
echo "   computing fringes"
$vltiCbin/oirFormFringes "$1" $2.fringeimage.fits 
if (0 == $status) then
#  echo "   fringing complete"
else
   echo "   fringing failed"
   exit
endif
#echo "   removing group delay and dispersion constant "
$vltiCbin/oirRotateGroupDelay $2.fringeimage.fits $2.groupdelay.fits $2.fringeimagerot.fits -phase $2.ungroupdelay.fits
if (0 == $status) then
#  echo "   ungroup delay complete"
else
   echo "   ungroup delay failed"
   exit
endif
echo "   compute average correlation"
$vltiCbin/oirAverageVisImage $2.fringeimagerot.fits $2.flag.fits $2.fringeimageave.fits
if (0 == $status) then
   rm $2.fringeimage.fits
   rm $2.fringeimagerot.fits
endif
