; AFARS
;--------------------------------------------------------------------
;! Is used after FARS to determine Position and Value of the maximum
;# TASK ANALYSIS POLARIZATION
;--------------------------------------------------------------------
;;  Copyright (C) 2011
;;  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                            First output image name  RM
OUTCLASS                           First output image class
OUTSEQ         -1.0      9999.0    First output image seq. #
OUTDISK         0.0         9.0    First output image disk  #
OUT2NAME                           2nd output image name Amp/Pha
OUT2CLAS                           2nd output image class
OUT2SEQ         0.0      9999.0    2nd output image seq #
OUT2DISK        0.0         9.0    2nd output image 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                             'PHAS' => phase in 2nd output
                                   otherwise amplitude at peak
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
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.

      The first output image:
           Position of maximum in radians/m^2.
      The second output image:
           Phase at the position of maximum in degrees if
           OPCODE='PHAS'; otherwise the maximum value in Jy/beam.
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 forst utput image name. (Position of max and zero)
  OUTCLASS....Output image class.   Default 'AFARrm'
  OUTSEQ......Output image seq. #.  0 => highest unique.
  OUTDISK.....Output disk number. 0 => highest with space.
  OUT2NAME....The second output image name.
                  (Amplitude and phase of the maximum)
  OUT2CLAS....Output image class.   Default 'AFARam' or 'AFARph'
  OUT2SEQ.....Output image seq. #.  0 => highest unique.
  OUT2DISK....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 cube?
              'PHAS' => phase at the maximum amplitude position
               ELSE  => the maximum amplitude itself
              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.
  DOHIST......Normally the HI file of input 1 is copied to the output
              history file and the HI file of the second input is
              appended.  If you are doing many AFARSs this can lead to
              immense history files of little use to anyone.  Thus,
              DOHIST=-2 => copy the first HI file only.
              DOHIST=-3 => copy no HI file, write AFARS HI only.
----------------------------------------------------------------


