I work in a lab making quantum dots, and was recently tasked with finding a way to extract some figures of merit from old data in an automated way. In particular, I'm looking to extract the peak position, and FWHM from a Gaussian fit of said peak. I believe this would normally be relatively trivial, however the data has an unusual shape, which is not playing nicely with Mathematica's built-in functions. An example of the data, zoomed into the ROI is available here
My current procedure is as follows:
- Smooth data using Savitsky-Golay (Code obtained from here)
- Background Subtract using
EstimatedBackground - Use
PeakDetectto find the relevant peaks
Unfortunately, the background estimation, and peak detection appear to be very sensitive to the values of $\sigma$ which is chosen. I made a simple Manipulate object to show what I mean: (Example, Yellow=Smoothed Data, Blue=Estimated Background, Green=Background Subtracted, and Orange=Results from PeakDetect)
EDIT:
Manipulate[
ListLinePlot[
{EstimatedBackground[smoothed[[;; , 2]], i],
smoothed[[;; , 2]],
smoothed[[;; , 2]] - EstimatedBackground[smoothed[[;; , 2]], i],
PeakDetect[
smoothed[[;; , 2]] - EstimatedBackground[smoothed[[;; , 2]], i],
n]*smoothed[[;; , 2]]},
DataRange -> {400, 800},
PlotRange -> All
],
{i, 0, 100}, {n, 0, 100}
]
I find that a good $\sigma$ value for the Background Subtraction for this particular dataset is ~30 and a good $\sigma$ for the Peak Detection is ~25.
To be clear, the left side of the plot is not of interest to me. It's an example of a standard semiconductor absorbance spectrum (like this), and my peak of interest is simply superimposed on it. Ideally I would simply subtract out the left side using a known function, but it's complicated since it's the result of multiple compounds in a given sample.
In short:
- Is there a better way to do this, which will result in more generalizable code?
- If my approach is the best way to do this (which I doubt) how can it be improved to require minimal human intervention?