; SNP2D
;---------------------------------------------------------------
;! Task to convert SN table single-channel phase to delay
;# TASK CALIBRATION
;-----------------------------------------------------------------------
;;  Copyright (C) 2013-2014
;;  Associated Universities, Inc. Washington DC, USA.
;;
;;  This program 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.
;;
;;  This program 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 this program; if not, write to the Free
;;  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge,
;;  MA 02139, USA.
;;
;;  Correspondence concerning AIPS should be addressed as follows:
;;         Internet email: aipsmail@nrao.edu.
;;         Postal address: AIPS Project Office
;;                         National Radio Astronomy Observatory
;;                         520 Edgemont Road
;;                         Charlottesville, VA 22903-2475 USA
;-----------------------------------------------------------------------
SNP2D     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
SNP2D     Convert single-channel phase to delay in SN table
INNAME                             Input image name (name)
INCLASS                            Input image name (class)
INSEQ             0.0     9999.0   Input image name (seq. #)
INDISK            0.0        9.0   Input image disk unit #
INVERS                             Input table file version no.
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
OUTSEQ           -1.0     9999.0   Output image name (seq. #)
OUTDISK           0.0        9.0   Output image disk unit #.
BIF               1.0              IF of channel used in CALIB
                                   in dataset INNAME
BCHAN             1.0              Channel in BIF used in CALIB
DOAPPLY          -1.0        1.0   > 0 copy amplitudes in SN
                                   else force amplitude to 1.0.
----------------------------------------------------------------
SNP2D
Task:  In some cases, a strong spectral line is the best calibration
       source available.  With the wide bandwidth of modern
       instruments, the phase measured at the frequency of the line
       cannot be transferred directly to calibrate all other channels.
       Instead, the measured phase needs to be interpreted as a delay
       and that delay applied to all IFs (spectral windows).

       Note that the antennas, source numbers, subarrays, frequency
       IDs, etc. in the output file must exactly match those in the
       input file.  Otherwise, the information conveyed in the output
       SN file will be confusing at best.

       Note that the delay is simply the phase in turns divided by the
       frequency of the spectral channel used to determine the phase.

       This task determines the current frequency quite carefully
       using the same code as CVEL.  You must set a rest frequency in
       the source table with SETJY if there is none to begin with.

       WARNING: This task is to be used AFTER you have done as good a
       job as possible with your absolute calibrator and your phase
       reference calibrator.  Run a FRING on the former to take out
       gross delays and line up phases.  Then run a FRING or CALIB as
       a function of time on the phase reference calibrator.  Then run
       a CALIB on the reference spectral line preferably using a few
       rounds of self-cal (unless you know it to be a point source).
       SNP2D will then convert small phases into modest additional
       delays as a function of time.  If there is any issue of phase
       wraps and the like, then this task will not do the right
       thing.  If you used CALIB rather than FRING on the phase
       reference source, you may need to run CALIB again on that
       source after SNP2D (and CLCAL of course).

Adverbs:
  INNAME.....Input image name (name).       Standard defaults.
  INCLASS....Input image name (class).      Standard defaults.
  INSEQ......Input image name (seq. #).     0 => 1.
  INDISK.....Disk drive # of input image.   0 => any.
  INVERS.....Version number of input SN table, 0 => highest
  OUTNAME....Output image name (name).      ' ' => INNAME
  OUTCLASS...Output image name (class).     ' ' => INCLASS
  OUTSEQ.....Output image name (seq. #).    0 => INSEQ
  OUTDISK....Disk drive # of output image.  0 => INDISK
  BIF........IF in data set INNAME containing channel used in CALIB -
             no default.
  BCHAN......Spectral channel of BIF in INNAME used in CALIB -
             no default.
  DOAPPLY....The real and imaginary parts of the gain determine the
             phase from which the output delay is computed.  The
             output gain will have zero imaginary part (no phase).
             If DOAPPLY > 0, the output real part will be equal to the
             amplitude in the SN table of BIF.  Otherwise, the output
             real part of the gain will be 1.0.
----------------------------------------------------------------
