[SciPy-User] Fitting Gaussian in spectra

josef.pktd@gmai... josef.pktd@gmai...
Thu Oct 4 08:50:20 CDT 2012


On Thu, Oct 4, 2012 at 7:20 AM, Joe Philip Ninan <indiajoe@gmail.com> wrote:
> Hi Matt, Christian, Jerome, Kevin and David.
> Thanks a lot for all the suggestions.
> First i apologize for my delay in replying. something was wrong with my
> subscription, and i was only able to read the emails in archive page.
> I tried to model the continuum as an exponential function and did least
> square fit. ( at first i was trying out 2nd degree polynomials)
> With the iterative masking method suggested. it seems to be doing a good
> job. I haven't tried on all data set yet.
> Since the width,position nor amplitude of peaks were not same in all data,
> peak finding was not easy.
> But the code by sixtenbe in github https://gist.github.com/1178136 helped me
> find the peaks _almost_ reliably.
> Thanking you again for all the help.

Is there some sample data of spectra that has this pattern available somewhere?

Kevins iterative dropping/masking method is very similar to least
trimmed squares.
My impression is that identifying peaks and fitting the
continuum/baseline is very similar to outlier detection with robust
estimation.

statsmodels has robust M-estimation, essentially replacing least
squares by a robust loss function.
I have in preparation for statsmodels, least trimmed squares (which
starts with a small subsample and adds observations until only
outliers are left), maximum trimmed likelihood (which also works for
other models like Poisson) and MM-estimators (which start with least
trimmed squares but then switches to M-estimation to get higher
efficiency in the normal case.)
Caveat: so far only for models that are linear in parameters.

With some sample data we could try if any of our robust estimators
would help in this case.

Josef

> -cheers
> joe
>
>
> On 29 September 2012 00:15, Joe Philip Ninan <indiajoe@gmail.com> wrote:
>>
>> Hi,
>> I have a spectra with multiple gaussian emission lines over a noisy
>> continuum.
>> My primary objective is to find areas under all the gaussian peaks.
>> For that, the following is the algorithm i have in mind.
>> 1) fit the continuum and subtract it.
>> 2) find the peaks
>> 3) do least square fit of gaussian at the peaks to find the area under
>> each gaussian peaks.
>> I am basically stuck at the first step itself. Simple 2nd or 3rd order
>> polynomial fit is not working because the contribution from peaks are
>> significant. Any tool exist to fit continuum ignoring the peaks?
>> For finding peaks, i tried find_peaks_cwt in signal module of scipy. But
>> it seems to be quite sensitive of the width of peak and was picking up
>> non-existing peaks also.
>> The wavelet used was default mexican hat. Is there any better wavelet i
>> should try?
>>
>> Or is there any other module in python/scipy which i should give a try?
>> Thanking you.
>> -cheers
>> joe
>> --
>> /---------------------------------------------------------------
>> "GNU/Linux: because a PC is a terrible thing to waste" -  GNU Generation
>>
>>
>
>
>
> --
> /---------------------------------------------------------------
> "GNU/Linux: because a PC is a terrible thing to waste" -  GNU Generation
>
> ************************************************
> Joe Philip Ninan    http://sites.google.com/site/jpninan/
> Research Scholar        /________________\
> DAA,                            | Vadakeparambil |
> TIFR,                           | Pullad P.O.         |
> Mumbai-05, India.      | Kerala, India      |
> Ph: +917738438212   | PIN:689548       |
> ------------------------------\_______________/--------------
>
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list