; AFARS
;--------------------------------------------------------------------
;! Is used after FARS to determine Position and Value of the maximum
;# TASK ANALYSIS POLARIZATION
;--------------------------------------------------------------------
;;  Copyright (C) 2011-2012
;;  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
;-----------------------------------------------------------------------
AFARS      LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
AFARS:     Find RM of maximum amplitude and the Amp/Phase there
INNAME                             First image (real/ampl) name
INCLASS                            First image class
INSEQ           0.0      9999.0    First image seq. #
INDISK          0.0         9.0    First image disk drive #
IN2NAME                            2nd image (imag/phase) name
IN2CLASS                           2nd image class
IN2SEQ          0.0      9999.0    2nd image seq. #
IN2DISK         0.0         9.0    2nd image disk drive #
OUTNAME                            Output images name  RM
OUTSEQ         -1.0      9999.0    Output images seq. #
OUTDISK         0.0         9.0    Output images disk  #
DOALIGN        -2.0         1.0    Should images be coincident?
                                   (See HELP.)
BLC             0.0      4096.0    Bottom left corner
TRC             0.0      4096.0    Top right corner
OPCODE                             'CMPL' => 2nd and 3rd outputs
                                   real and imaginary at peak,
                                   else amplitude and phase
BPARM                              (1) If peak < BPARM(1), blank
                                       output RM and phase
                                   (2) Value for blanked RMs
                                       -1111 => magic blank
                                   (3) Value for blanked phases
                                       -1111 => magic blanks
                                   (5) method of finding peak
DOHIST         -3.0         1.0    -2 => copy 1st HI only
                                   -3 => copy no HI files
----------------------------------------------------------------
AFARS
Type: Task

      The task may be used to find the position and value of maximum
      of the spectrum given in the input cubes.  The cubes should be
      the output cubes of the task FARS (CLEAN or UNCLEAN) with
      reals in the first cube and imaginaries in the second cube OR
      with amplitudes in the first cube and phases in the second
      cube.  These images are the output of FARS (not the transposed
      output from the procedure DOFARS) and so have the RM spectrum on
      the first axis and RA/Dec on the second and third axes.

      The first output image:
           Position of maximum in radians/m^2.
      The second and third output images:
           Real and imaginary at the position of maximum in Jy/beam if
           OPCODE='CMPL'; otherwise the maximum amplitude in Jy/beam
           and the phase at the position of the maximum in degrees.
Adverbs:
  USERID......The ID of the owner of the images. 0 => current
              user, 32000 => any user.
  INNAME......First image name. (amplitude)
  INCLASS.....First image class.    Standard defaults.
  INSEQ.......First image seq. #.   0 => highest.
  INDISK......Disk drive # for the first image.  0 => any.
  IN2NAME.....Second image name (phase)
  IN2CLASS....Second image class.   Standard defaults.
  IN2SEQ......Second image seq. #.  0 => highest.
  IN2DISK.....Disk drive # for the second image.  0 => any.
  OUTNAME.....The output images name. (Position of max and zero)
              Output classes are 'AFARrm' and 'AFARam', 'AFARph' or
              'AFARre', 'AFARim'
  OUTSEQ......Output images seq. #.  0 => highest unique.
  OUTDISK.....Output disk number. 0 => highest with space.
  DOALIGN.....Controls how the four images are to be aligned (see HELP
              DOALIGN).  True (>.1) means that the images must agree in
              their coordinates, though not necessarily in the reference
              pixel position.  Alignment is by coordinate values (if
              DOALIGN > -0.1) or by offsets from the reference pixel
              positions (if DOALIGN <= -0.1).  NOTE: all real axes (>1
              point) are aligned.  If DOALIGN = -2, the headers are
              ignored and the images are aligned at pixel (1,1,...).
  BLC.........Bottom left corner of the 1st input image.
  TRC.........Top right corner of the 1st input images. (See BLC.)
  OPCODE......What is recorded to second and third cube?
              'CMPL' => real and imaginary at the maximum amplitude
                        position
               ELSE  => the maximum amplitude itself and the phase at
                        the position of the maximum amplitude
              The position (on the faraday rotation axis) is recorded
              in the first cube.
  ICUT........If the amplitude is < ICUT, blank the output position
              and phase
  BPARM.......(1) If the peak value is < BPARM(1) then the output will
                  be blanked using value BPARM(2) for RM and BPARM(3)
                  for phase.  0 -> no blanking.
              (2) Value for blanked pixels in the RM output image.
                  The value -1111 is used to request magic blanks.
              (3) Value for blanked pixels in the phase output image.
                  The value -1111 is used to request magic blanks.
              (5) <= 0 -> use a simple 3-point parabolic fit around
                         the maximum amplitude to find the estimated
                         maximum and its location in the RM row
                  =  1 -> use a 5-point least-squares parabolic fit
                         around the maximum amplitude to find the
                         estimated maximum in the the RM row
                  >= 2 -> use the maximum in the row and its position
                         as the estimate.
  DOHIST......Normally the HI file of input 1 is copied to the output
              history file and the HI file of the second input is
              ignored (it will be very similar to the first one).
              DOHIST >= -2 => copy the first HI file only.
              DOHIST  = -3 => copy no HI file, write AFARS HI only.
----------------------------------------------------------------


