Gui Smooth

This function smooths the flux values of an AAR (either in unique parts, such as detectors, or all together) by convolution with a selected function: Boxcar, Gaussian, Lorentzian, Median, Hanning, or Sinc.

The Lorentzian function is of the form:

1 + -----------

The Hanning function is of the form:

1 - cos ( c delta_x )
where c in each case is a constant set by the program.

The other functions listed are used in their standard forms. I

The Algorithm:

In each case, the full width at half maximum (FWHM) of the function is set to be equal to the user's specified "function width" in microns. (For median smoothing this does not apply: the median flux value is taken from the set of data values found within the requested "function width").

For each lambda value supplied by the user in the original AAR, a smoothed flux value Fj is computed by averaging all the original surrounding flux values found within HW, where HW is the distance from the smoothing function center to where the function falls off to 10^(-3) of its peak value.

The new flux, Fj, is computed from the input flux values, Fi, using the expression:

Fj = sum [weight(i) F(i)]
         sum [weight(i)]

where the sum over i is taken where the abs ( delta_x(i) ) < HW, where delta_x(i) = lambda(j) - lambda(i), and weight is described below.

Note that there may be only a few points (i) found when smoothing data located at the exteme wavelength end of the AAR. The smoothed results may become noisier at the end points, but the algorithm is designed to always return the same number of points at the same lambda values as were input.

The new standard deviations, STDEV, are computed by finding the weighted dispersion of the data around the smoothed flux result, Fj.

                 sum [ weight(i) ( Fj - Fi ) ^2 ]
STDEV^2(j) =     --------------------------------
                      sum [ weight (i) ]

where weight(i) = f(delta_x(i))^2 / STDEV(i)^2 or else, when "error weighting" is not requested, weight(i) = f(delta_x(i))^2, and where f(delta_x(i)) is the selected smoothing function.

In the case of median smoothing, the error-weighting mode is not allowed, and the new STDEV values are computed as above with f(delta_x(i))=1.

If gaps in the input data are found that are wider than the requested "output sampling interval," then no smoothed data is produced in the gaps.