; IM2UV
;---------------------------------------------------------------
;! converts an image to a visibility data set
;# Task Imaging UV AP
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 2005-2006, 2008
;;  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
;-----------------------------------------------------------------------
IM2UV     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
IM2UV :  Task to FFT an image and convert to a UV data file
INNAME                             Image name (name)
INCLASS                            Image name (class)
INSEQ              0.0      9999.0 Image name (seq. #)
INDISK             0.0         9.0 Image disk drive #
BLC             0.0      4096.0    Bottom left corner
TRC             0.0      4096.0    Top right corner
OUTNAME                            Output uv data file name
OUTCLASS                           Output uv data file class
OUTSEQ            -1.0      9999.0 Output uv data (seq. #)
OUTDISK            0.0         9.0 Output drive #
WTUV              0.0              Central data weight
UVTAPER           0.0              UV taper in kilolambda to 30%
UVRANGE           0.0              UV range in kilolambda
FLUX                               Peak flux
SHIFT                              Ra Dec shifts in arc sec
BADDISK                            Disks to avoid for scratch.
----------------------------------------------------------------
IM2UV
Type: Task
Use:  IM2UV FFTs a subportion of an image and writes the data as a uv
      data file.  Multiple frequency channels will be handled.  The
      output file will contain dummy values of the time and baseline
      random parameters.  A dummy AN table will also be created.  The
      output weights will be set to to a Gaussian function centered on
      the origin with the peak and widths set by the user.  Note that
      input images must have columns at least 256 pixels long.
         The output file may be treated as any othe uv data set,
      including editing, imaging with IMAGR or MX, and concatenating
      with other data.  Not all uv data manipulation routines will do
      something sensible with the output data file (e.g. calibration
      in CALIB).
Adverbs:
  INNAME......The input real part name.   Standard defaults.
  INCLASS.....The input real part class.   Standard defaults.
  INSEQ.......The input real part seq. no. 0 => highest.
  INDISK......The input real part disk no. 0 => any.
  BLC.........Bottom left corner of the input image. 0's => whole image.
  TRC.........Top right corner of the input image.   0's => whole image.
  OUTNAME.....The output uv data file name; standard defaults.
  OUTCLASS....The output uv data file class; standard defaults.
  OUTSEQ......The output image seq. #.  0 => highest unique.
              Old files may NOT be overwritten.
  OUTDISK.....The output disk drive no. 0 => highest with space.
  WTUV........Weight for the data sample at u = v = 0.  0 => 1.0.
  UVTAPER.....Gaussian tapering applied to the weights (NOT the data) in
              kilo wavelengths to the 30% point.
  UVRANGE.....Range of spatial frequencies in 1000's of wavelengths.
              0 => all.
  FLUX........> 0 Rescale the Fourier transform of the image to have
                  FLUX (Jy) at the origin (u = v = 0).  The scaling is
                  done against the first spectral channel.
              < 0 Rescale the Fourier transform to have -FLUX at the
                  maximum in the Fourier transform of the first
                  spectral channel, whether or not at the origin.
              = 0 Use some build in scaling not much like the original
                  visibility values that went into the image.
  SHIFT.......Shift the phaes from the reference position by SHIFT arc
              seconds in arc seconds at the referenceposition.  Thus
              RA = RA0 + SHIFT(1)/cos(DEC) and DEC = DEC0 + SHIFT(2).
  BADDISK.....This array contains the numbers of disks on which it is
              desired that scratch files not be located. BADDISK has no
              effect on input and output files.
----------------------------------------------------------------
IM2UV: Task to Fourier transform an image and convert it to a uv data
       format file.
DOCUMENTOR: W. Cotton NRAO (preliminary)
RELATED PROGRAMS: IMAGR, WTMOD, UVFLG, DBCON

                         PURPOSE

     This task allows an image to be Fourier transformed and converted
to a uv data format file.  This allows using the tools available for
editing in the Fourier domain before retransforming to the image domain
using UVMAP, MX, or IMAGR.  Alternately, this task allows combining data
derived from a single-dish antenna with interferometer data.

                         USAGE

     If the specified window in the input image is not a power of 2,
then the (sub)image is zero padded to a power of two before being FFTed.
The input image must have columns that are at least 256 pixels long.

     The coordinate projection type of the image is coded into the UU-L
and VV-L fields so that the imaging routines can reconstruct the correct
projection codes.

     Since IM2UV uses FFTs to do the transform the sampling of u-v cells
is entirely determined by the image.  The imaging routines assume that
the u,v and w sampled scale with frequency as will always be true of an
interferometer.  Because IM2UV cannot sample at arbitrary u-v positions
the output data can be correct for only one frequency.  If more than one
frequency is requested only the first will be done.  The other
frequencies must be processed separately.

     For best results when transforming the output of IM2UV back to the
image plane, use twice the number of cells and half the cell spacing of
the input image to IM2UV.  Then use SUBIM with XINC=2; YINC=2; BLC=2,1;
TRC=0 to recover the original spacing.  If the retransformed image is to
be deconvolved then oversampling by a factor of three or more is
desirable (cell spacing 1/3 of original image) and the output image
should not be subimaged until after deconvolution.
