The `BASE` command subtracts polynomial baselines of degree .
The fitting algorithm uses Chebyshev polynomials, and does not allow any
extrapolation outside the fitting range. It is thus important to fit the
baseline out to the maximum extension of the wanted spectrum. If
extrapolation is needed, a constant value will be used outside the fitting
range, equal to the polynom value at the boundary. The algorithm warns if
the polynomial degree is too high. See section for a typical
baseline fitting session.

The user first defines line windows by the command `SET WINDOW` with
the following syntax:

SET WINDOW [wl1 wu1 [wl2 wu2 [...]]] [/VAR array] [/POLYGON [N] [filename1...filenameN]] [/NOCURSOR]The

Up to 100 windows or 5 polygons may be defined. `BASE` then fits a
polynomial to the part of the spectrum outside the line windows. However,
only the ``visible'' parts of the spectrum are used and bad channels are
taken out. The degree of the polynomial is defined by `SET BASE`
`n`, or temporarily by the `BASE` command itself with its argument.

Sinusoidal baselines may also be subtracted, using the command
`BASE SINUS` `Amplitude Period Phase` where `Amplitude`, ` Period` and `Phase` are initial guesses for a minimization routine.
A linear baseline is added to the sinusoid in any case.

When working on an individual spectrum (not the index),
the `/PLOT` option plots the fitted baseline in the current box. The
area in the windows as well as the rms noise, are computed.
A baseline can be computed for one spectrum, and then subtracted from a
different one using `BASE LAST`. This may be helpful for example at
Pico-Veleta where you may remove from the 100 kHz backend the baseline
determined from the 1 MHz one. Be sure that you do not change the X-unit
between the time you computed the baseline and the time you remove it...

When working on the whole index, the baseline are fitted spectrum per
spectrum and the baseline-corrected spectra are stored in the 2D array
ready for plotting with the next `PLOT /INDEX` command. However,
baseline fitting results are lost and an explicit loop on the index entry
must be use including a new baseline computation) to store the results with
the `WRITE` command.