; MAPBM
;---------------------------------------------------------------
;! Map VLA beam polarization
;# TASK CALIBRATION POLARIZATION UV Image VLA OOP
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1997, 2000, 2002-2003
;;  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
;-----------------------------------------------------------------------
MAPBM     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
MAPBM:  Map VLA beam polarization
INNAME                             Input UV data (name)
INCLASS                            Input UV data (class)
INSEQ                              Input UV data (seq. #)
INDISK                             Input UV data disk drive #
SOURCES                            Source (pointings) list
QUAL                               Source qualifier
TIMERANG                           Time range to process.
BIF               0.0      100.0   Lowest IF number 0=>all
EIF               0.0      100.0   Highest IF number 0=>all
PMODEL                             Source polarization
DOCALIB          -1.0        2.0   Calibrate multisource data?
                                   = 2 calibrate weights
GAINUSE                            CL table to apply
DOPOL            -1.0       10.0   If >0.5 correct polarization.
BLVER                              BL table to apply.
FLAGVER                            Flag table version
DOBAND           -1.0       10.0   If >0 apply bandpass cal.
                                   Method used depends on value
                                   of DOBAND (see HELP file).
BPVER                              Bandpass table version
OUTNAME                            Output image name (name)
OUTDISK                            Output image disk drive #
                                   Note:  OUTCLASS='ANT_#'
                                          'RMS_#' for rms maps
                                   where # is antenna number.
OUTSEQ          -1.0    32000.0    Output seq. no.
IMSIZE          1.       4096.     Image size (X,Y) in pixels
CELLSIZE      1.E-12               (X,Y) size of grid in asec
APARM                              Task enrichment parms
                                   (1) Avg. time in sec.
                                   (2) Blank time at the begin.
                                       of the avg. time in sec.
                                   (3) 0 => no rms maps
                                       1 => yes rms maps
                                            no scaling for the
                                            rms maps
                                   (4) 0 => Yes dividing of a
                                            polarization map by
                                            its maximum
                                       1 => No dividing of a
                                            polarization map by
                                            its maximum
                                   (5) 0 => create separate maps
                                            for each of selected
                                            antennas
                                       1 => combine data of all
                                            selected antennas
                                            and create one map
ANTENNAS                           Selected antennas from the
                                   list of measured antennas
                                       0 => all
                                       If any number is negative
                                       then all antennas listed
                                       are NOT selected and
                                       all others are.
BASELINE                           The reference antenna list
                                   Must be given!!!
BADDISK                            Disk drive #'s to avoid
----------------------------------------------------------------
MAPBM
Type:  Task
Use:   Image VLA quasi "holography" mode data to make total
       intensity gain images and images of the fractional Q, U
       and V polarizations.  The uv data are expected to be
       rasters in azimuth and elevation. Prior calibration and
       editing may be applied and then the data is then averaged
       over baseline.
          The resultant images are the qubes of primary beam
       (and the rms of each of these) for each of the selected antennas
       with the stokes I, Q, U and V as the third axis.
       For Stokes I, the image is the average observed I
       divided by PMODEL(1).  For the other values of Stokes the
       image values are the real part of the ratio of the complex Stokes'
       value to I (complex also) after correction for source polarization.
          Note: QUACK is needed to eliminate the first couple of
       integrations of a raster while the on-line system
       (VLA 9/93) sorts out where it needs to be.
          Note: QUACK may not be enough; exceedingly painful,
       careful editing of the data will be needed to insure that
       all the spurious points are removed.
Adverbs:
  INNAME.....Input UV data file (name).     Standard defaults.
             MUST be a multi source file.
  INCLASS....Input UV data file (class).    Standard defaults.
  INSEQ......Input UV data file (seq. #).   0 => highest.
  INDISK.....Input UV data file disk drive #.  0 => any.
  SOURCES....List of sources (pointings) to be processed.
             All blank means any.
  QUAL.......Source qualifier for rasters.
  TIMERANG...Time range of the data to be processed. In order:
             Start day, hour, min. sec,
             end day, hour, min. sec. Days relative to ref.
             date.
  BIF........First IF to image. 0=>all.
  EIF........Highest IF to image. 0=>all higher than BIF
  PMODEL.....The Stokes parameters for the  source.
                PMODEL(1) = I flux density (Jy)
                PMODEL(2) = Q flux density (Jy)
                PMODEL(3) = U flux density (Jy)
                PMODEL(4) = V flux density (Jy)
  DOCALIB....If true (>0), calibrate the data using information in the
             specified Cal (CL) table for multi-source or SN table for
             single-source data.  If > 1.5, also calibrate the weights
             (new for VLA, normal for VLBI).
  GAINUSE....CL table version number to apply.  0=> highest.
  DOPOL......If > 0.5, correct data for instrumental polarization as
             represented in the AN table.  This correction  is only
             useful if PCAL has been run or feed polarization parameters
             have been otherwise obtained. See HELP DOPOL for available
             correction modes.  Use only integer values for DOPOL with
             this task.
  BLVER......Version number of the baseline based calibration (BL)
             table to appply. <0 => apply no BL table, 0 => highest.
  FLAGVER....Specifies the version of the flagging table to be
             applied. 0 => highest numbered table.  <0 => no flagging
             to be applied.
  DOBAND.....If true (>0) then correct the data for the shape of the
             antenna bandpasses using the BP table specified by BPVER.
             The correction has five modes:
             (a) if DOBAND=1 all entries for an antenna in the table
             are averaged together before correcting the data.
             (b) if DOBAND=2 the entry nearest in time (including
             solution weights) is used to correct the data.
             (c) if DOBAND=3 the table entries are interpolated in
             time (using solution weights) and the data are then
             corrected.
             (d) if DOBAND=4 the entry nearest in time (ignoring
             solution weights) is used to correct the data.
             (e) if DOBAND=5 the table entries are interpolated in
             time (ignoring solution weights) and the data are then
             corrected.
  BPVER......Specifies the version of the BP table to be applied.
             <0 => no bandpass correction done.
  OUTNAME....Output image name (name).      Standard defaults.
  OUTDISK....The disk drive # of output images.  0 => highest
             with space.
             Note:  OUTCLASS='ANT_#' ('RMS_#' for rms maps)
             where # is the antenna number.
             In the case when all antenna data averaged (APARM(5) = 1)
             OUTCLASS='ANT_*'
  OUTSEQ.....Output sequence number. 0 => highest unique.
  IMSIZE.....(X,Y) image size in pixels.  Should be odd.
  CELLSIZE...(X,Y) pixel separation in asec. It should be close to the
             actual separation at the pointing at the holography
             measurements.
  APARM......Task enrichment parameters.
             (1) Averaging time in seconds; normally interval
                 of each pointing.
             (2) Time in seconds to ignore at the beginning of
                 each pointing; this allows for antenna move.
             (3) 0 => no rms maps
                 1 => yes rms maps
                      no scaling (dividing by the map maxima)
                      for the rms maps
             (4) 0 => Yes dividing of a polarization map by
                      its maximum
                 1 => No dividing of a polarization map by
                      its maximum
             (5) 0 => create separate maps for each selected
                      antennas
                 1 => combine data of all selected antennas
                      and create one map
  ANTENNAS...A list of the antennas to be selected.
             0 => all.
             If any number is negative then all antennas listed are NOT
             selected and all others are.
             ANTENNAS list is the list of measured antennas.
  BASELINE...List of the reference antennas. Must be given!!!
  BADDISK....Disk drive #'s to avoid for scratch files
----------------------------------------------------------------
  You can create the average maps averaging all selected antennas
  and all selected reference antennas, or
  You can create maps for each selected antenna separately.

  OUTCLASS of the output map is 'ANT_#'.
           For 'rms' maps the OUTCLASS of the output map is 'RMS_#'.
           where # is the antenna number.
  In the case when all antenna data averaged (APARM(5) = 1)
  OUTCLASS='ANT_*'

  Each output map is the cube with the third axis dimension is 4
  (one plate for Stokes parameter).
  So KNTR can plot all polarization at one page. The four maps can
  be normalized to 1(one) (APARM(4)) dividing by the maximum value
  at each plate. No normalization for the 'rms' maps.
  So the values of the maps have to be multiplied by the scale factors.
  The value of the scale factors can be found as keywords using aips
  verb 'imh'
  The scaling all stokes maps to 1, simplifies selection of the levels
  in KNTR.






