&readParameters; convolver = &getConvolver; (values, uncerts) = &getInSet; mask = &getMask; noHoleMask = mask; foreach (hole in mask) { if (hole width <= fillholewidth) { noHoleMask = true; values = 0.0; } } if (normalise) { norm = 1.0; } else { norm = sum(convolver); } smoothedValues = 0.0; for (n = 1 to vectorSize) { next if (!noHoleMask(n)); summ = 0.0; weight = 0.0; for (i = 1 to convolverSize) { j = n - (i - 1 - convolverSize / 2) next if (j < 1 || j > vectorSize || !mask(j)); summ = summ + convolver(i) * values(j); weight = weight + convolver(i); } smoothedValues(n) = summ * norm / weight; } if (witherrors) { smoothedUncerts = 0.0; for (n = 1 to vectorSize) { next if (!noHoleMask(n)); summ = 0.0; weight = 0.0; for (i = 1 to convolverSize) { j = n - (i - 1 - convolverSize / 2) next if (j < 1 || j > vectorSize || !mask(j)); summ = summ + convolver(i) * convolver(i) * values(j) * values(j); weight = weight + convolver(i); } smoothedUncerts(n) = sqrt(summ) * norm / weight; } } &writeFitsOutput(smoothedValues, smoothedUncerts, noHoleMask); if (withPlotOutput) { &writePlotOutput(smoothedValues, smoothedUncerts, noHoleMask); }