; WARP
;---------------------------------------------------------------
;! Model warps in Galaxies
;# TASK ANALYSIS
;-----------------------------------------------------------------------
;;  Copyright (C) 1995, 2009
;;  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
;-----------------------------------------------------------------------
WARP      LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
WARP :  Task to model warps in galaxies
INNAME                             Image name (name)
INCLASS                            Image name (class)
INSEQ            0.0       9999.0  Image name (seq. #)
INDISK           0.0          9.0  Disk drive #
IN2NAME                            Image name (name)
IN2CLASS                           Image name (class)
IN2SEQ           0.0       9999.0  Image name (seq. #)
IN2DISK          0.0          9.0  Disk drive #
BLC              0.0       4096.0  Bottom left corner of image
                                     0=>entire image
TRC              0.0       4096.0  Top right corner of image
                                     0=>entire image
FACTOR           0.0          1.0  Convergence criterion
                                     0=> 0.001
FUNCTYPE                           Rot. curve type. 'EX': Expo-
                                   nential, def: constant.
APARM                              (1),(2) central position;(3),
                                   (4) first guesses to p.a., i.
                                   (5) Vsys;(6) Vmax;(7) Rmax;
                                   (9) 1: residual map(s)
CPARM                              (4),(5),(6): R(min,max,inc);
                                   (7),(8) guesses b and d in
                                   pa = a + b*R, i = c + d*R.
PIXSTD                             Estimated rms uncertainty in
                                   the observed radial velocity
                                   at one pixel.  0=>10000
----------------------------------------------------------------
WARP
Type: Task
Use:  Adverbs:
  INNAME......Image name(name).  blank=>any
  INCLASS.....Image name(class).  blank=>any
  INSEQ.......Image name(seq. #).  0=>any
  INDISK......Disk drive # of image.  0=>any
  IN2NAME.....Image name(name) second input map.  blank=>no
              second input map.
  IN2CLASS....Image name(class).  blank=>any
  IN2SEQ......Image name(seq. #).  0=>any
  IN2DISK.....Disk drive # of image.  0=>any
  BLC.........The Bottom Left-hand pixel of the subarray of
              the image to be analysed. The value (0,0)
              means (1,1).
  TRC.........The Top Right-hand pixel of the subarray of
              the image to be analysed.  The value (0,0) means
              the top right hand corner of the entire image.
  FACTOR......Criterion to stop least squares fitting.
  FUNCTYPE....Type of rotation curve to be fitted.
                'EX' : Exponential flat curve   :
                                        - ln(100.0) * (R / Rmax)
                   V / Vmax   =   1 - e
                'CC' : Constant curve (default) :
                   V / Vmax   =   1
  APARM.......Same is in GAL.HLP, only (3) and (4) are now ini-
              tial guesses, others remain constant.
  CPARM       (4),(5) Rmin,Rmax. (6) Rinc: width of radius in
              which root is sought. (7),(8) guesses b and d in
              pa = a + b*R, i = c + d*R.
  PIXSTD......Estimated rms uncertainty in observed radial
              velocity at one pixel.
----------------------------------------------------------------
WARP :  Task which analyzes a velocity field, and models the variation
   of position angle and inclination with radius. It is advisible to
   use GAL first, and use the resulting central position and systemic
   velocities in WARP.  Only linear variations are assumed, so
   strongly warped galaxies may not be modeled correctly.  It can also
   model velocity fields with double profiles.  In that case, make two
   velocity fields, one with velocities using only the profiles
   closest to the systemic velocity, and one using the other profiles.
   Two such maps can most easily be made using the task XGAUS.

      The program searches for roots of the following equation :
          r = r (R, pa(R), i(R)),
   where r is the observed (projected) radius, pa and i the position
   angle and the inclination, and R the unknown true radius.  Clearly,
   for constant pa and i, there is at most one root, and this R can be
   calculated directly, as is done in the task GAL.  For varying pa
   and i, more than one root is possible, as is demonstrated by the
   occurrence of double profiles.  The search is performed by the
   subroutine WORTEL, which begins its search at R = r, and ends at
   Rmax, specified by CPARM(5)  It first looks if in the interval (r,
   r + increment) the sign of r (R) changes.  If so, the root in the
   interval is determined.  Then the search continues in the next
   interval, and this is repeated until Rmax is reached.  The size of
   the increment is specified by CPARM(6).  It should be chosen small
   enough to separate neighbouring roots, but not so small to cause an
   unnecessary increase in CPU time.  The total number of roots found
   clearly depends strongly on Rmax, which should be chosen larger
   than the largest radius expected.  A too low choice of Rmax may
   cause pixels to be discarded if the current values of pa and i are
   off, whereas a too high choice again results in a waste of CPU
   time.  If the model results in two (or more) roots in the line of
   sight, it will attribute the lowest root to the value in map 2, and
   the next root to the value in map 1.  If only one root is found in
   the line of sight, it is attributed to the value in map 1.

      WARP assumes that you have two input maps if you provide a
   non-blank IN2NAME.  If IN2NAME is blank, it assumes only one input
   map, and it always takes the first root it encounters.  If APARM(9)
   = 1, you will get one or two (depending on the number of input
   maps) residual maps, with the same names and volume numbers as the
   input maps, but with class RESID1 and RESID2.
