Histogram Background Subtraction
nabrams
Tue, 07/10/2012 - 06:43 am
I have two histograms: one for counts across an energy range and one for the background counts across the same range. The histograms have the same bin characteristics. I would like to subtract the counts of the background histogram from the counts of the data histogram, without changing the bin characteristics. However, when I subtract them, the bin characteristics are affected. Additionally, is there a way to scale the counts in a histogram (like double the number of counts in each bin) without changing the bin characteristics. For example, if my histogram has a gaussian shape with a peak at x=250, and I do the following:
Variable i=0
Do
TempHistScale[i]=TempHistBack[i]*2
i+=1
While(i
Then the peak of the gaussian for TempHistScale will be at ~x=50 (why?). I looked for awhile on the forum and IGOR's manual, but I am very sorry if I missed it/ the solution is obvious. Thanks.
I have two histograms: one for counts across an energy range and one for the background counts across the same range. The histograms have the same bin characteristics. I would like to subtract the counts of the background histogram from the counts of the data histogram, without changing the bin characteristics. However, when I subtract them, the bin characteristics are affected. Additionally, is there a way to scale the counts in a histogram (like double the number of counts in each bin) without changing the bin characteristics. For example, if my histogram has a gaussian shape with a peak at x=250, and I do the following:
Variable i=0
Do
TempHistScale[i]=TempHistBack[i]*2
i+=1
While(i (less than) numpnts(TempHistBack))
Then the peak of the gaussian for TempHistScale will be at ~x=50 (why?). I looked for awhile on the forum and IGOR's manual, but I am very sorry if I missed it/ the solution is obvious. Thanks.
July 10, 2012 at 06:49 am - Permalink
You are better off doing this with a wave assignment:
TempHistScale = 2*TempHistBack
which implies a loop over all points of TempHistScale. If the two histograms cover different X ranges, you will need to do some gymnastics to get the arithmetic to do the Right Thing. The easiest way to subtract two waves that don't have equal X ranges is to use the Wave Arithmetic package. See the demo at File->Example Experiments->Analysis->Wave Arithmetic Panel Demo.
To read about wave assignments, copy this command, paste it into Igor's command line and press enter:
DisplayHelpTopic "Waveform Arithmetic and Assignment"
And to post code that includes things like greater than signs, see this: http://www.igorexchange.com/filter/tips
and read about the igor tag.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 10, 2012 at 09:01 am - Permalink
July 10, 2012 at 10:20 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 10, 2012 at 12:19 pm - Permalink
July 11, 2012 at 06:44 am - Permalink