; RMSD
;----------------------------------------------------------------------
;! Calculate rms for each pixel using data at the box around the pixel
;# TASK IMAGING ANALYSIS
;-----------------------------------------------------------------------
;;  Copyright (C) 2002, 2005, 2007, 2008
;;  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
;-------------------------------------------------------------------
RMSD      LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
RMSD      Creates the image of RMS at each velocity plane.
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 unit #
OUTNAME                            Output image name (name)
OUTCLASS                           Output image name (class)
OUTSEQ           -1.0     9999.0   Output image name (seq. #)
OUTDISK           0.0        9.0   Output image disk unit #.
BLC                                Bottom left corner of input
TRC                                Top right corner of input
IMSIZE                             Size of the box used to
                                   calculate rms, in pixels
                                   IMSIZE(2)=-1 => the circle
                                   of diameter=IMSIZE(1)is used
OPCODE                             'RMS ', 'MEAN', or 'BLAN'
                                   (see help), '    ' => 'RMS '
OPTYPE                             'ROBS', 'HIST'
                                   (see help), '    ' => 'ROBS'
SCALR1                             Data<SCALR1*RMS are replaced
                                   by blank (OPCODE='BLAN')
SCALR2                             >0 =>
                                    ABS(DATA) < SCALR2*RMS
                                    are replaced by blank
                                    (OPCODE='BLAN')
                                   <0 =>
                                    ABS(DATA) > ABS(SCALR2)*RMS
                                    are replaced by blank
                                    (OPCODE='BLAN')
                                   0 => no blanking
SCALR3                             Number of RMS used at each
                                   iteration calculating final
                                   RMS.  0 => 3
FLUX                               Data with RMS>FLUX
                                    are replaced by blank
                                    (OPCODE='BLAN')
                                   0 => no blanking
XINC                               Increment at X to calculate
                                   RMS, in pixels
YINC                               Increment at Y to calculate
                                   RMS, in pixels
                                   The intermediate points are
                                   calculated by interpolation
----------------------------------------------------------------
RMSD
Task:  Creates the image of RMS at each velocity(frequency) plane.
       The rms is calculated for each pixel based on the data at
       the box surrounding the pixel. The size of the box is
       controlled by the user (adverb IMSIZE).
       RMS is calculated on the multi iteration (30) basis.
       At the first iteration the RMS is calculated using all points
       of the box. The points which differ of the mean more than
       SCALR3*RMS are excluded from the consideration for the next
       iteration.
       The iteration process is terminated if none point is excluded.
Adverbs:
             The input image should have the standard sequence of axes
             the first is X
             the second is Y
             the third is velocity/frequency
  INNAME.....Input image name (name).     Standard defaults.
  INCLASS....Input image name (class).    Standard defaults.
  INSEQ......Input image name (seq. #).   0 => highest.
  INDISK.....Disk drive # of input image. 0 => any.
  OUTNAME....Output image name (name).    Standard defaults.
  OUTCLASS...Output image name (class)    Standard defaults.
  OUTSEQ.....Output image name (seq. #).  0 => highest unique.
  OUTDISK....Disk drive # of output image.  0 => highest
  BLC........Bottom left corner in input image of desired
             subimage.  Default is entire image.
  TRC........Top right corner in input image of desired
             subimage.  Default is entire image.
  IMSIZE.....Size of the box used to calculate rms, in pixels
             IMSIZE(2)=-1 =>
             the circle of diameter=IMSIZE(1)is used, instead of
             the box IMSIZE(1)xIMSIZE(2)
  OPCODE.....'RMS ' =>
                creates map of RMSes calculated for each pixel
                using the data inside of the given box surrounded
                the pixel.
             'MEAN' =>
                creates map of MEANes calculated for each pixel
                using the data inside of the given box surrounded
                the pixel.
             'BLAN' =>
                the image value is replaced by BLANK under control
                of adverbs SCALR1 and SCALR2 and calculated RMS.
                This option prepares the image cube to be ready for
                other tasks (XMOM for example) that require
                cutoff the 'bad' points on the basis of rms calculated
                at the vicinity of each image  point.
             '    ' => 'RMS '
  OPTYPE.....Concept of RMS' calculation
             'ROBS' => The far away points are rejected at the multi
                       iteration process
             'HIST' => The histogram concept is used. Data for histogram
                       are at the range -+ 1.5sigma. The histogram is
                       calculated at 16 intervals with center at the
                       mean value
  SCALR1.....Number of the rms used at the cutoff.
             Data values below SCALR1*RMS are replaced by BLANK.
             (OPCODE='BLAN')
  SCALR2.....Number of the rms used at the cutoff.
             When SCALR2 > 0.0,
               data values less in absolute value
               than RMS*SCALR2 are replaced by blank.
             When SCALR2 < 0.0,
               data values greater in absolute value
               than ABS(SCALR2) are replaced by blank.
             When SCALR2=0,
               no replacement by blank
  SCALR3.....Number of RMS used at each iteration calculating
             final RMS.  0 => 3
  FLUX.......Data with RMS>FLUX are replaced by blank (OPCODE='BLAN')
             FLUX is in Jy/beam
             0 => no replacement by blank

  Replacement by blank is carried out (OPCODE='BLAN')
  if 'SCALR1' .OR. 'SCALR2' .OR. 'FLUX'

  XINC.......Increment at X to calculate RMS, in pixels

  YINC.......Increment at Y to calculate RMS, in pixels

  The task RMS requires a lot of computing time. XINC, YINC are invented
  to weaken the computing time problem. The RMS is calculated every
  XINC, YINC at the X,Y directions. The RMS of intermediate points are
  estimated by interpolation. The computing time should be reduced
  by the factor XINC*YINC

  Programmer Leonia Kogan
------------------------------------------------------------------





