Definition of the output spectrum

##
Definition of the output spectrum

Let's denote and two spectra that one wants to add, and the output sum. With the ACCUMULATE command, and are precisely the corresponding buffers exposed to the user in CLASS. With the AVERAGE command, is the average spectrum returned by the loop, and the spectrum in index, with its weight array correctly set. We also call (resp. ) the resolution of (resp. ). This resolution is either in “number of channels”3, frequency, or velocity per channel depending on the alignment mode (SET ALIGN CHANNEL|FREQUENCY|VELOCITY resp.).

From these, the output resolution is taken as the highest of the two (absolute) resolutions in input:

(1)
This ensures that we never oversample a spectrum which has a low resolution.

The range of abscissa in output spectrum depends on the combination mode:

- COMPOSITE mode:

  |  |  |  | (2)
  |  |  |  | (3)

- INTERSECT mode:

  |  |  |  | (4)
  |  |  |  | (5)

Given the output resolution and range, the number of channels can be deduced:

(6)
where the 1.5 value adds 1 or 2 extra-channels to avoid the erosion of the spectra at the boundaries.

For the oncoming call of the addition routine, we also define the abscissa at the channel used as reference:

(7)
being the abscissa value of the first channel of the output spectrum. Again, unit is either in “channels”, velocity or frequency depending on the SET ALIGN mode.

This definition of the output spectrum is done only once with the ACCUMULATE command. On the other hand with the AVERAGE command, the above parameters are revised (if required) each time a new spectrum of the index is added. For example, the output range and number of channels may enlarge (SET ALIGN * COMPOSITE) or reduce (SET ALIGN * INTERSECT). Also, the resolution is progressively reduced to the coarsest of all the resolutions in the index (eq. ).