Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upNew peakshape #137
New peakshape #137
Conversation
0eece4a
to
85f54f2
|
This looks awesome. Want to throw a few tests in if you get a chance? It's one of the last entirely-uncovered bits :) |
|
Sure! I'll probably have a go in a couple of days! |
This PR proposes a completely different algorithm to find the FWHM.
The old algorithm estimated the FWHM by finding the closest values to the half maximum value. This meant that it could easily make mistakes when spectra had multiple peaks (see plots below).
The new algorithm starts from the maximum value and then moves left (then right) until it finds the first value that falls below the half maximum value. This means it will never be fooled by multiple peaks
(left plot is the old algorithm and right plot is the new one)
With the old algorithm, it was very had to determine when the FWHM overlapped with the wavelength range. This means that the right-hand side value (
HWHM.r) was not actually at half maximum but was the lowest value to the right of the FWHM.With the new algorithm, it's trivial to detect such cases and
peakshape()now accordingly returnsNAwhen the FWHM range overlaps with the wavelength range.(left plot is the old algorithm and right plot is the new one)
The new algorithm is slower (spends 150% of the time spent before) than the old one but I may still be able to improve it a bit(fixed by ffeb760)