[SciPy-User] Asymmetric peak fitting

Paweł Kwaśniewski pawel.kw at gmail.com
Thu Mar 19 05:57:01 EDT 2015


Matt,

I have one more question: the weights for fitting a model should be
1./error_bar or the error_bar? The name "weights" suggests the former, but
I'd like to be sure.

Cheers,

Paweł

2015-03-19 9:09 GMT+01:00 Paweł Kwaśniewski <pawel.kw at gmail.com>:

> Jonathan, Matt,
>
> Thank you for your answers. I must say that lmfit is already a good friend
> of mine - I use it for quite some time for fitting. Somehow I didn't think
> of looking there for asymmetric peak models. Thanks for pointing this out!
> I suppose this will solve my problem.
>
> Cheers,
>
> Pawel
>
> 2015-03-19 2:16 GMT+01:00 Matt Newville <newville at cars.uchicago.edu>:
>
>> Pawel,
>>
>> On Wed, Mar 18, 2015 at 10:06 AM, Paweł Kwaśniewski <pawel.kw at gmail.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> I'm currently trying to fit some experimental data in the form of
>>> asymmetric peaks. In principle it's difficult to find a distribution
>>> describing this kind of data. My goal is to get the full width half maximum
>>> of the peak and the peak position. I tried to look for some ready solutions
>>> within scipy but could not find any. I did find a nice paper though:
>>>
>>> http://arxiv.org/abs/0711.4449
>>>
>>> Since it's not so trivial (at least not for me) to implement this, I'd
>>> like to ask if anyone in the community has already done this (or something
>>> similar) and would like to share the code.
>>>
>>> Cheers,
>>>
>>> Pawel Kwasniewski
>>>
>>
>> You might find the lmfit module (http://lmfit.github.io/lmfit-py/)
>> useful.  This is a module for least-squares minimization and curve-fitting,
>> built on top of scipy.optimize.  It includes several built-in Models, a few
>> representing asymmetric peaks such as an exponentially damped Gaussian (
>> http://lmfit.github.io/lmfit-py/builtin_models.html#exponentialgaussianmodel).
>> A quick look at the paper you referenced suggests this function might be
>> sufficient, but if this or one of the other built-in Models isn't exactly
>> what you're looking forward, it's very easy to make a new Model class from
>> a Python function that calculates and returns the model function.  Lmfit
>> Models can also be added  or multiplied together to make composite models
>> (say, Gaussian + Step + Quadratic), and allow you to place bounds and/or
>> constraints on any of the Parameters in the fit.
>>
>> Though there are many features you can use to set up models and their
>> parameters, using these models (either built-in or one that you define
>> yourself) for curve-fitting data is pretty straightforward.  See
>> http://lmfit.github.io/lmfit-py/builtin_models.html#example-1-fit-peaked-data-to-gaussian-lorentzian-and-voigt-profiles
>> for a simple example.   That example uses symmetric peaks, but the use of
>> any Model for curve-fitting is basically the same.
>>
>> Hope that helps,
>>
>> --Matt Newville
>>
>>
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.scipy.org/pipermail/scipy-user/attachments/20150319/10700194/attachment.html>


More information about the SciPy-User mailing list