#!/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:
#   dispSciPhotPhot ABfiles (blank separated list) maskFile CurveFile 
#      CrossFile photFile outputBaseName dSky

echo "   dispSciPhotPhot:deChopping AB images"
echo "photFile is $5"
echo "outbase is $6"

$vltiCbin/oirChopPhotoImages -in "$1" -out $6.ABphotometry.fits -dsky $6 -ref $3
if (0 != $status) then
   echo "   AB chop photometry failed"
   exit 1
endif
$vltiCbin/oirSci2HiPhot -AB $6.ABphotometry.fits -outbase $6 -ref $3 -cross $4 
if (0 != $status) then
   echo "   Conversion Sci to Hi failed "
   exit 1
endif
$vltiCbin/oirMakePhotoSpectra -A $6.Aphotometry.fits -B $6.Bphotometry.fits -out $6.Hphotometry.fits -mask $2 
if (0 != $status) then
   echo "   Mask photometry operation failed"
   exit 1
endif
$vltiCbin/oirRescaleSpectra $5 $6.Hphotometry.fits $6.photometry.fits
if (0 != $status) then
   echo "   photometry rescaling operation failed"
   exit 1
endif
