; RSPEC
;---------------------------------------------------------------
;! Plots and prints spectrum of rms of a cube
;# TASK PLOT SPECTRAL HARDCOPY
;-----------------------------------------------------------------------
;;  Copyright (C) 2010-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
;-----------------------------------------------------------------------
RSPEC     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
RSPEC : Task to plot spectrum of the rms of an image
USERID      -32000.0      32000.0  User ID.  ignored
INNAME                             Image name (name)
INCLASS                            Image name (class)
INSEQ            0.0       9999.0  Image name (seq. #)
INDISK           0.0          9.0  Disk drive #
BLC              0.0       4096.0  Bottom left corner 0->use all
                                     (1,2) -> exclude area
TRC              0.0       4096.0  Top right corner 0 -> use all
                                     (1,2) -> exclude area
OPTYPE                             'MEDI' median window
                                   'LOW' use tight limits in rms
                                      else use less tight limits
OPCODE                             '    ' => RMS
                                   'WEIT' => WEIGHT=1/(RMS**2)
DOOUTPUT        -1.0          1.0  > 0 => write S/N data cube
OUTNAME                            Output name(name).
OUTCLASS                           Output name(class).
OUTSEQ         -1.0      9999.0    Output name(seq. #).
                                     0 => highest unique
OUTDISK                            Output image disk drive #
                                     0 => highest with room
PIXRANGE                           Range of intensities to plot
ZINC         -8192.0       8192.0  Increment on freq axis.
                                   < 0 => invert Z axis in plot
SMOOTH                             Frequency smoothing function
LTYPE         -10.0        10.0    Type of labeling: 1 border,
                                   2 no ticks, 3 standard, 4 rel
                                   to center, 5 rel to subim cen
                                   6 pixels, 7-10 as 3-6 with
                                   only tick labels
                                   <0 -> no date/time
DOCENTER        -1.0          1.0  > 0 => plot with box-like
                                   lines, else plot line to
                                   points
DOTV           -1.0         1.0    > 0 Do plot on the TV, else
                                   make a plot file
GRCHAN          0.0         8.0    Graphics channel 0 => 1.
DOPRINT        -3.0       132.0    > 0 => use the terminal, 0 =>
                                   no output, < 0 => printer or
                                   file, > 72 => terminal width
OUTPRINT
                                   Printer disk file to save
DOSLICE        -1.0         2.0    > 0 => save as SLice file
XYRATIO         0.0                Stretch the X axis wrt Y axis
                                   0 -> 1.33
----------------------------------------------------------------
RSPEC
Type: Task
Use : Task to plot and print the rms of an area in the first two axes
      of an image as a function of location on the third axis of an
      image.  It is probably best to set the area to the full image.
      The image is read into memory one plane at a time and the rms
      found by robust means.  The spectrum will be placed in a plot
      file and can be displayed with the display task of the user's
      choice.  Note that the third axis does not have to be a
      spectral-line axis - all standard axis types are allowed.

      If the third axis is FQID, the plots made will be adjusted to a
      frequency axis with points placed appropriately.  Slices made
      will be interpolated onto a regular frequency grid.
Adverbs:
  USERID......User ID of owner of image.  Ignored.
  INNAME......Image name(name).  blank => any
  INCLASS.....Image name(class).  blank => any
  INSEQ.......Image name(seq. #).  0 => any
  INDISK......Disk drive # of image.  0 => any
  BLC.........The Bottom Left-hand pixel of the subarray of the image to
              be plotted. The value (0,0,...) means (1,1,1,1,1,1,1).
              Usage is different here: the rectangle BLC(1) to TRC(1)
              on axis 1 by BLC(2)-TRC(2) on axis 2 is OMITTED from the
              computation.  BLC = 0 or 1 means include the full
              image.  Axes 3-7 are used normally - e.g. BLC(3) to
              TRC(3) defines the channels to be plotted.
  TRC.........The Top Right-hand pixel of the subarray of the image to
              be plotted.  The value (0,0,...) means the top right hand
              corner of the entire image.
  OPTYPE......= 'MEDI' => a median selection is done followed by a
                          median selection on the absolute value of
                          the difference from the median using a new,
                          faster method of doing medians.
              = 'LOW'  => a robust mean and rms are done with the
                          final iteration ignoring points more than
                          1.5 sigma from the mean
              = other  => a robust mean and rms are done with the
                          final iteration ignoring points more than
                          2.5 sigma from the mean.
              The MEDI operation is faster than the other two
              methods.  However, the robust methods will be more
              successful at ignoring signal portions of the image to
              return the true "noise" in the image.  A median will be
              skewed if a significant number of pixels have real
              signal.  The LOW method will return a lower "rms" in
              part because it ignores more of the distribution.  It
              may get into convergence trouble if the image has lots
              of areas of real signal.  The default method should have
              less trouble with convergence because it is less
              agressive at all stages.
  OPCODE..... Operation code.
              '    ' => RMS
              'WEIT'= > the evaluated RMSs are recalculated to
                        WEIGHT=1/(RMS**2)
  DOOUTPUT....> 0 => write an output image cube of S/N.
  OUTNAME.....Output name of image(name).    Standard defaults.
  OUTCLASS....Output name of image(class).   Standard defaults.
  OUTSEQ......Output name of image(seq. #).  0 => highest unique
  OUTDISK.....Disk drive # of Output image.  0 => highest with
              space.
  PIXRANGE....Range of pixel values to plot; values below PIXR(1) are
              set to PIXR(1), values above PIXR(2) are set to PIXR(2).
              PIXR(1) >= PIXR(2) implies use the full range of pixel
              values in the image.
  ZINC........Increment between plotted pixels on 3rd axis.
              If < 0, abs(ZINC) is used and the Z axis is inverted
              when listing and plotting.
  SMOOTH.....Specifies the type of spectral smoothing to be applied to
             a uv database . The default is not to apply any smoothing.
             The elements of SMOOTH are as follows:
             SMOOTH(1) = type of smoothing to apply: 0 => no smoothing
               To smooth:
                 1 => Hanning, 2 => Gaussian, 3 => Boxcar, 4 => Sinc
                 5 => Hanning, 6 => Gaussian, 7 => Boxcar, 8 => Sinc
             SMOOTH(2) = the "diameter" of the function, i.e. width
               between first nulls of Hanning triangle and sinc
               function, FWHM of Gaussian, width of Boxcar. Defaults
               (if < 0.1) are 4, 2, 2 and 3 channels for SMOOTH(1) =
               1 - 4 and 5 - 8, resp.
             SMOOTH(3) = the diameter over which the convolving
               function has value - in channels.  Defaults: 1,3,1,4
               times SMOOTH(2) used when input SMOOTH(3) < net
               SMOOTH(2).
  LTYPE.......Labelling type: 1 = border, 2 = no ticks, 3 or 7 =
              standard, 4 or 8 = relative to ref. pixel, 5 or 9 =
              relative to subimage (BLC, TRC) center, 6 or 10 = pixels.
              7-10 all labels other than tick numbers and axis type are
              omitted.  Less than 0 is the same except that the plot
              file version number and create time are omitted.
  DOCENTER....False (<= 0) means to draw plot lines between the data
              points of the "spectrum" producing a jagged looking plot.
              True (> 0) means to plot 1-channel horizontal lines
              centered on each data point and connected to adjacent
              points by vertical lines producing a histogram-like plot.
  DOTV........> 0 => plot directly on the TV device, otherwise make a
              plot file for later display on one or more devices
              (including the TV if desired).
  GRCHAN......Graphics channel (1 - 7) to use for line drawing. 0 => 1.
  DOPRINT.....False (<= 0) use the line printer if OUTPRINT = ' ' else
                 write named OUTPRINT file only.  When OUTPRINT is not
                 blank, DOPRINT=-2 suppresses the page-feed character
                 on page headers and DOPRINT=-3 suppresses page
                 headers and most other header information.
                 DOPRINT=-3 is especially recommended for OPCODE='WEIT'.
                 In this case, the OUTPRINT file does not include any
                 extra lines at the top and therefore is ready for
                 using as the input file for a task such as FARS.
              True  (> 0) use the terminal interactively.  The task will
                 use the actual terminal width as a display limit
                 unless 72 < DOPRINT < width.  In that case, the
                 display limit will be DOPRINT characters.
  OUTPRINT....Disk file name in which to save the line printer output.
              ' ' => use scratch and print immediately for interactive
              jobs - batch jobs use OUTPRINT = 'PRTFIL:BATCHjjj.nnn'
              (jjj= job #, nnn = user #).  When OUTPRINT is not blank,
              multiple outputs are concatenated, and the file is not
              actually printed.
  DOSLICE.....> 0 => save the spectrum as a SLice file suitable for
              the usual plotting and fitting done on slices.
  XYRATIO.....The ratio of the axes X to Y in the plot.  1.0 makes a
              square plot.  0 -> 1.3 (about the usual ratio of X to Y
              on the TV screen or A format paper).
----------------------------------------------------------------
