I'm in a little over my head here and I'm fully aware of it, so I'm hoping for some help. I've been assigned to a project where I am given data:
http://www.pastebin.ca/3061136 (Example Data)
I then smooth it with a moving median:
and then I need to find Gaussian functions that fit each pulse of the data. The steps as I understand them are to take the data, apply a cubic spline function to interpolate, Find the peaks (max) of the cubic spline, Find a Gaussian function that fits that peak, then trim out that peak and repeat, and keep repeating for the user entered N pulses until all N pulses in the data are found, and Gaussian functions for each pulse returned.
The issue with this being that after a couple days of work, my very limited programming skills are falling short. I first thought the GaussianWindow or NonlinearModelFit functions could serve, but I cannot seem to get them to function in this context at all. Is pulse fitting in the method I described even feasible?
I've found several topics that have helped somewhat, but so far I'm at a hard brick wall for actually making anything work. Having to enter initial values is something that's fine, especially as the manipulate functions make that so easy, but even with that my limited skills are running quite dry.
Problem with NonlinearModelFit
How to perform a multi-peak fitting?
Code so far for reference:
Needs["Splines`"]
Needs["ErrorBarPlots`"]
filelocation = SystemDialogInput["FileOpen"];
rawfiledata = Import[filelocation, "Table"];
rawtop = Drop[rawfiledata, {1}];
erroramt = rawtop[[All, 4]];
trimmedfiledata = Drop[rawfiledata, {1}, {2, 4}];
Number of points in given data :
datalength = Length[trimmedfiledata]
Select the number of points to apply a Moving Median to:
Manipulate[moveamt = movelength, {movelength, 1, 25, 1}]
Dynamic[errbar = MovingMedian[erroramt, moveamt]];
Dynamic[ListPlot[mmdata = MovingMedian[trimmedfiledata, moveamt]]]
Dynamic[bsplinedat = BSplineFunction[mmdata]]
Dynamic[ParametricPlot[bsplinedat[x], {x, -8, 8}]]