## Baseline fitting

Figure: Beta sorted series of dumped spectra intensities as a function of the velocity. All the lambda offsets are shown here, implying the presence of horizontal stripes in the image. This representation of the data nevertheless enable a very quick (even though not optimal) first data reduction by the definition of baseline windows through a polygon drawing.

Other operations than visualization may benefit from the definition of the 2D array. The first coming in mind is baseline fitting. It is well known that this requires the separation of the spectrum channels between signal and baseline, in other words the definition of baseline windows. When dealing with a small number of spectra, the windows are often defined separately on each spectrum. When dealing with thousands of spectra, we still need to define windows adapted to each individual spectrum as large velocity gradients (e.g. in galaxies) may quickly move in frequency the separation between signal and baseline from one spectrum to another. However, defining windows on each individual spectrum is both impractical and inefficient as this does not take into account spatial homogeneity (really useful in case of moderately weak lines). We thus enable the definition of spectral windows directly on the 2D plot with polygons.

The following set of commands are used to define the polygon and to fit the baselines

              LAS90> file out 12co21-newfmt-base.30m new
              LAS90> plot /index
              LAS90> set window /polygon
              LAS90> for iobs 1 to found
              LAS90>    get next
              LAS90>    base
              LAS90>    write
              LAS90> next

Up to 21 independent polygons may be defined. The polygon boundaries are directly converted to individual windows for each dumped spectra. Those windows are stored in the `set%window` SIC array which is then used by the base and write commands. In the end, each spectrum will have its own baseline window stored in its header. Each polygon is also stored in a separate file for the user's convenience.