; RM
;---------------------------------------------------------------
;! Task to calculate rotation measure and magnetic field
;# TASK POLARIZATION 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
;-----------------------------------------------------------------------
RM        LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
RM: Task to calculate rotation measure and magnetic field
INNAME                             Input image name (name)
INCLASS                            Input image name (class)
INSEQ           0.0      9999.0    Input image name (seq. #)
INDISK          0.0         9.0    Input image disk drive #
IN2NAME                            Noise image name (name)
IN2CLASS                           Noise image name (class)
IN2SEQ          0.0      9999.0    Noise image name (seq. #)
IN2DISK         0.0         9.0    Noise image disk drive #
BLC             0.0      4096.0    Bottom Left corner of fit
TRC             0.0      4096.0    Top Right corner of fit
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
                                    (NOT USED AT PRESENT)
OUTSEQ         -1.0      9999.0    Output image name (seq. #)
OUTDISK         0.0         9.0    Output disk drive #
APARM                              (1) begin channel
                                   (2) end channel
                                   (3) initial guess of RM
                                   (4) max expected |RM|
                                   (5) > 0 use noise image
                                   (6) blanking method
                                   (7) blanking level
                                   SEE HELP re 4, 6, 7
SCALR1         -1.0         1.0    <= 0 => Output normal map
                                   > 0  => Output error on map
----------------------------------------------------------------
RM
Type: Task
Use:  RM is a task which calculates rotation measure and
      intrinsic magnetic field from a set of (at least three)
      position angle maps made at different frequencies. The
      current version can accept a maximum of four frequencies.
      The algorithm will fit an unweighted or weighted fit of
      the position angle to the wavelength squared.  In the
      latter case, sigma (error) maps must also be supplied.
      These error maps must be made with the task COMB.
      RM outputs both a map of the rotation measure, and
      a map of the intrinsic magnetic field.  Various
      blanking options are supplied and it is vigorously
      suggested that one of them be used.
BLC, TRC values:
      BLC(1-6) : TRC(1-6) apply to axes 2 - 7 of the input
      cube.  In other words, they are the desired OUTPUT
      window rather than the input window.  APARM(1), APARM(2),
      and APARM(8) control the input window on the first
      (actually frequency) axis of the cube.
APARM values:
   (1): First frequency channel to use in fit, 0 -> 1
   (2): Last frequency channel to use in fit, 0 -> N
   (3): The initial guess for the rotation measure. Use the integrated
        values if nothing else is known. UNITS are RADIANS per METER
        squared.
   (4): If > 0, use a method due to F. Zhou to search a wide range of
        lobe ambiguities, based on APARM(4) as the maximum expected RM
        in absolute value.
   (5): Solution type. <= 0 => Unweighted fit
           >0 =>  Weight fit by errors in IN2NAME et al.
   (6): Blanking type. 0 => No blanking
        1 => Blank both output maps if corr. coeff. < APARM(7).
        2 => Blank both maps only if sigma of RM exceeds APARM(7)
            (rad/m.m)
        3 => Blank both maps only if sigma of B > APARM(7) (degrees)
        4 => Blank both maps if rms dev. per point from best fit line
             exceeds APARM(7) (degrees)
        5 => Blank both output maps if in input error of any input map
             value exceeds APARM(7).     THIS IS THE RECOMMENDED WAY.
   (7): The blanking level.  See APARM(6).
----------------------------------------------------------------
To run RM, you must follow these steps:

1) Run AXDEFINE for each p.a. map and each sigma map (if you
   wish weighted fits), and change the 3rd axis (frequency)
   to an arbitrary unit (i.e. 'PERLEYS'), whose values
   increase uniformly from map to map.  Although the order of
   the frequencies is not critical, the program stands the
   best chance of working properly if the 3rd axis increases
   with frequency.  It is important that the two frequencies
   closest in wavelength have the 3rd axes set to 1 and 2.
   Set the third axis of the position angle maps from 1 to
   N, where N is the number of frequencies, then set the
   position angle error maps to have the third axis run from N+1
   to 2N, keeping the same frequency order as the position
   angle maps. (If you do not intend to weight by fit, you need
   not include the error maps).  When running AXDEFINE, set
   AXINC = 1 and AXREF = 1 also.
2) Run RENAME for each map to make the name and class of each
   the same.  Make the sequence number of each map the same as
   the new "frequency" value (i.e. from 1 to N for the position
   angle maps, and N+1 to 2N for the error maps.)
3) Run MCUBE and assemble these N (or 2N if you want a weighted
   fit) maps into a data cube.
4) Run TRANS and transpose the cube.  Make the initial first
   axis ('LL') the second, the initial second ('MM') the third,
   and the initial third (frequency in units of 'PERLEYS' or
   whatever) the first.  That is, the new order is '312'.
5) Run RM ! INNAME is the transposed cube. Only the OUTNAME
   is used, OUTCLASS is pre-set to 'ROTMES' and 'BFIELD'.
----------------------------------------------------------------
