laserkelvin / PySpecTools

Routines for rotational spectroscopy analysis written in Python 3
MIT License
31 stars 5 forks source link

Issue with find_peaks "Intensity" output #11

Closed IlsaCooke closed 4 years ago

IlsaCooke commented 4 years ago

Thanks for the great program!

I'm having some issues with using the find_peaks function to determine the intensity of peaks in a laboratory spectrum. I'm wondering what the intensity column in the output data frame corresponds to? It does not appear to correspond directly to the intensity of the peaks.

For example, here is a peak in the lab spectrum that has an intensity of around 4.2e07 but the output from find_peaks is 6.6e+01.

Is there a way to output the raw intensity value that corresponds to the peaks in the lab spectrum?

image(1) image

laserkelvin commented 4 years ago

If I understand the problem correctly, the intensity column there is mislabeled: the documentation for that function says that if the threshold keyword isn't specified, the "intensity" used for the rest of the analysis is actually the signal-to-noise ratio.

In your function call, you've specified sigma = 5, and so it will mark every peak with an SNR greater than this value - so in this case, it's finding a peak of an SNR of 66. We prefer to work in SNR because it makes things more comparable between experiments and between labs - everyone's oscilloscope reads out a voltage that doesn't necessarily mean anything, and so SNR is more informative.

If you do want to work in raw intensity units, use a value of threshold instead of sigma, then peak finding will work in absolute intensity.