The function CutPeakInSpectrum allows you to remove a peak in a spectrum and replace it by an interpolated line. The variable parameter Spec contains the raw data of the spectrum, the parameters Piv1 and Piv2 specify the endpoints of the interpolation range (these are zerobased indices into the spectrum). The spectral intensities of the endpoints can be averaged by specifying the DeltaPiv parameter which defines the range around the end points. All points in the intervals [Piv1DeltaPiv, Piv1+DeltaPiv] and [Piv2DeltaPiv, Piv2+DeltaPiv] are taken to calculate the average y values which are then used as the basis for the interpolated line. DeltaPiv may take values from 0 to 10 (which results in 2*DeltaPiv+1 data points).
The following image shows the replacement of a peak by a linear interpolation between the endpoints Piv1 and Piv2. The black dots represent the original data, the red circles indicate the spectral line after calling CutPeakInSpectrum.
The function returns the following error codes:
0 ... everything is OK
1 ... invalid DeltaPiv (valid range: 0..10)
2 ... either Piv1 or Piv2 is out of range
