Author Topic: Background Models  (Read 2225 times)

Gseward

  • Global Moderator
  • Professor
  • *****
  • Posts: 134
Background Models
« on: July 22, 2016, 11:06:04 AM »
John,

Could you clarify please:

I have off-peak bkgd and I use a polynomial fit (e.g.), based on some wavescan data (e.g. for an unknown), I define a curve based on fit parameters. I then apply this fit to other unknnowns. Nominally I assume this is only appropriate for similar unknowns where I don't expect the background to change very much. BUT - what happens if the ratio of hi to lo backgrounds changes slightly? How is the shape of the curve defined then fitted to the two measured background values? Minimised fit to the acquired backgrounds, or something different???

Cheers,

Gareth

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Background Models
« Reply #1 on: July 23, 2016, 01:07:21 PM »
I have off-peak bkgd and I use a polynomial fit (e.g.), based on some wavescan data (e.g. for an unknown), I define a curve based on fit parameters. I then apply this fit to other unknnowns. Nominally I assume this is only appropriate for similar unknowns where I don't expect the background to change very much. BUT - what happens if the ratio of hi to lo backgrounds changes slightly? How is the shape of the curve defined then fitted to the two measured background values? Minimised fit to the acquired backgrounds, or something different???

Hi Gareth,
This is a great question.   I'll describe from my code comments what I do with some extra text. I'm not saying there couldn't be a better method for adapting a polynomial fit from a wavescan to a different (unknown) sample, but I'll paste the complete code below.

1. Load three known spectrometer positions based on saved polynomial fit
2. Calculate three intensity values for these positions
3. Scale calculated intensity values to current nominal beam
4. Re-fit the polynomial using the new scaled y values
5. Calculate new off-peak values based on new fit coefficients
6. Calculate intensity offsets from the actual off-peak measurements
7. Average actual intensity offsets
8. Calculate new y intercept for this sample based on offsets
9. Calculate actual background using new rescaled coefficients at on-peak position

john

Code: [Select]
pxdata!(1) = sample(1).LoPeaks!(j%)     ' load three known positions
pxdata!(2) = sample(1).OnPeaks!(j%)
pxdata!(3) = sample(1).HiPeaks!(j%)

' Get three y values for these positions
pydata!(1) = sample(1).BackgroundPolynomialCoefficients!(1, j%) + sample(1).BackgroundPolynomialCoefficients!(2, j%) * sample(1).LoPeaks!(j%) + sample(1).BackgroundPolynomialCoefficients!(3, j%) * sample(1).LoPeaks!(j%) ^ 2
pydata!(2) = sample(1).BackgroundPolynomialCoefficients!(1, j%) + sample(1).BackgroundPolynomialCoefficients!(2, j%) * sample(1).OnPeaks!(j%) + sample(1).BackgroundPolynomialCoefficients!(3, j%) * sample(1).OnPeaks!(j%) ^ 2
pydata!(3) = sample(1).BackgroundPolynomialCoefficients!(1, j%) + sample(1).BackgroundPolynomialCoefficients!(2, j%) * sample(1).HiPeaks!(j%) + sample(1).BackgroundPolynomialCoefficients!(3, j%) * sample(1).HiPeaks!(j%) ^ 2

' Scale y values to current nominal beam
If UseBeamDriftCorrectionFlag Then
If sample(1).BackgroundPolynomialNominalBeam!(j%) <> 0# And NominalBeam! <> 0 Then
temp! = NominalBeam! / sample(1).BackgroundPolynomialNominalBeam!(j%)
pydata!(1) = pydata!(1) * temp!
pydata!(2) = pydata!(2) * temp!
pydata!(3) = pydata!(3) * temp!
End If
End If

' Re-fit the data using new scaled y values
order% = 2  ' 2nd order polynomial
npts% = 3
Call LeastSquares(order%, npts%, pxdata!(), pydata!(), acoeff!())
If ierror Then Exit Sub

' Calculate off-peak values based on new fit coefficients
temp1! = acoeff!(1) + acoeff!(2) * sample(1).HiPeaks!(j%) + acoeff!(3) * sample(1).HiPeaks!(j%) ^ 2
temp2! = acoeff!(1) + acoeff!(2) * sample(1).LoPeaks!(j%) + acoeff!(3) * sample(1).LoPeaks!(j%) ^ 2

' Calculate offsets from current off-peak measurements
temp3! = sample(1).HiPeakCounts!(i%, j%) - temp1!
temp4! = sample(1).LoPeakCounts!(i%, j%) - temp2!

' Average current offsets
temp! = (temp3! + temp4!) / 2#

' Calculate new y intercept for this sample based on offset
tintercept! = temp! + acoeff(1)

' Calculate actual background using new rescaled coefficients at on-peak position
bgdcts! = tintercept! + acoeff!(2) * sample(1).OnPeaks!(j%) + acoeff!(3) * sample(1).OnPeaks!(j%) ^ 2
sample(1).BgdData!(i%, j%) = bgdcts!
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"