; XBASL
;---------------------------------------------------------------
;! Fits and subtracts nth-order baselines from cube (x axis)
;# TASK SPECTRAL ANALYSIS PLOT
;-----------------------------------------------------------------------
;;  Copyright (C) 1995-1996, 1999
;;  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
;-----------------------------------------------------------------------
XBASL     LLLLLLLLLLLLUUUUUUUUUUUU CCCCCCCCCCCCCCCCCCCCCCCCCCCCC
XBASL     Fits n'th order polynomials to rows of images
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
YINC              0.0      128.0   Do every YINCth row
ZINC              0.0      128.0   Do every ZINCth plane
FLUX              0.0              Flux cutoff (see HELP)
DOOUTPUT         -1.0        1.0   Write images of parms
DOCONT           -1.0        1.0   > => retain continuum
DOSLICE          -1.0        2.0   Plot data on TEK
DOMODEL          -1.0        1.0   Plot model on TEK
DORESID          -1.0        1.0   Plot residuals on TEK
PIXRANGE                           Min,Max of image intensity
                                     Max <= Min => entire range
LTYPE            0.0         6.0   Type of labeling: 1 border,
                                   2 no ticks, 3 standard, 4 rel
                                   to center, 5 rel to subim cen
                                   6 map pixels
PIXVAL           0.0               Display if peak < PIXVAL
ORDER            0.0          4.0  Max order of polynomial
NBOXES           1.0         40.0  Max number of baseline
                                   windows
BOX              0.0       4096.0  Begin/end channel numbers for
                                   windows 1 - NBOXES
BADDISK                            Disk(s) to avoid for scratch
----------------------------------------------------------------
XBASL
Task:  Fits n'th order polynomials to each row of an image.  (Normally
       XBASL will be used on images with frequency or velocity as the
       first axis, but it will procede with others as well.)  The task
       fits up to 4'th order plus a constant baseline to each row and,
       optionally, writes up to 4 + 2*ORDER n-1 dimensional images
       containing the fit parameters and their uncertainties.  It will
       always write the image corrected for the baseline (i.e. with the
       baseline function, optionally minus its average, subtracted).
       With a careful choice of input parameters, the task is capable of
       running in a batch-like mode.  However, an interactive mode
       (using the TEK graphics terminal) is recommended.  Note that,
       since the TEK is not allowed in AIPS batch jobs, XBASL turns off
       all interactive options and TEK displays when it is run in batch.
Adverbs:
  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.
             Used only for the corrected image.  The OUTCLASSes
             for the fit parameters are CONST and DERIVn and for the
             uncertainties are DCONST and DDERVn.  The "flux" (average)
             of the baseline function is written with OUTCLASSes of FLUX
             and DFLUX.
  OUTSEQ.....Output image name (seq. #).   0 => highest unique.
  OUTDISK....Disk drive # of output image. 0 => highest number with
             sufficient space.
  BLC........Bottom right 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.
  YINC.......Do only every YINC'th row (beginning at BLC(2)).
  ZINC.......Do only every ZINC'th plane (beginning at BLC(3)).
  FLUX.......A flux cutoff in the same units as the input image (i.e.
             Jy/beam).  If a row does not have three consecutive points
             above this level - or below minus this level, no baseline
             is fit to the row.  Note that the row values are tested
             after subtracting a linear baseline for this test.
             0 => 0.00005.
  DOOUTPUT...True (> 0) requests that the parameter and uncertainty
             images be catalogued (see OUTCLASS).
  DOCONT.....True (> 0) implies subtract the baseline and add the
             average of the baseline from the output.  This attempts to
             retain the continuum (if any).  False (<= 0) is used when
             the continuum is zero, or already removed.
  DOSLICE....True (> 0) implies plot the data on the TEK.  > 1 also
             requests a TEK plot of the initial guess.  It must be set >
             1. if you wish the option to correct initial guesses with
             the TEK cross hairs.  If DOSLICE > 1 and NGAUSS > 1, the
             program pauses after plotting its initial guess and
             requests user input from the terminal.  Hit RETURN to
             procede with the program's initial guess.  Enter BAD to
             have the solution for the row blanked and E to have the
             program request your guidance as to an altered set of
             baseline windows.
  DOMODEL....True (> 0) requests a plot of the final model for each row
             on the TEK.
  DORESID....True (> 0) requests a plot of the final residual values in
             each row.  If any one or more of DOSLICE, DOMODEL, or
             DORESID is true, then the program will pause after each row
             and request input from the terminal.  At that point, you
             may enter BAD to have the solution blanked or simply a
             RETURN to keep the answer.  One may also enter RETR to loop
             back and try again with a new set of baseline windows.
  PIXRANGE...Min,Max of Image intensity.  0,0 => min,max of EACH row
             (separately).  Note that this will mean some plots are at
             too fine a scale and that the residuals will appear only if
             the slice contains a sufficient range about 0.0.
  LTYPE......Labelling type: 1 = border, 2 = no ticks,
             3 = standard, 4 = relative to center of row,
             5 = relative to subimage (BLC, TRC) center
             6 = pixels in original map
  PIXVAL.....Plot row only if the peak value < PIXVAL.  Limits the plots
             to those of uncertain intensities.
  ORDER......The maximum allowed order for the polynomial.  0 is a
             constant, 1 is linear, 4 is a bit much and is the maximum
             allowed.
  NBOXES.....The number of windows in each row (maximum) to be used in
             fitting the baseline up to 20.
  BOX........NBOXES pairs of channel numbers specifying the beginning
             and end channel numbers of each of the baseline windows.
             These numbers may be entered with the TEK cursor in
             interactive modes.
  BADDISK....Disk drives to avoid for scratch files.
----------------------------------------------------------------
