bound parameters on mpfit

38 views
Skip to first unread message

Andrew Thron

unread,
Mar 5, 2014, 5:28:32 PM3/5/14
to hypersp...@googlegroups.com
Francisco,

Is there a way to put upper and lower bounds on fit Parameters? For instance, I can use the .set_parameters_value to apply an initial guess to the FWHM for a Gaussian fit, but is there away to keep the FWHM with in a certain range (like the constraints in the lmfit module)?  I know that the mpfit will support bounding, but I am not quite sure how to set the boundaries. 

Cheers, 
Andrew 


Tomas Ostasevicius

unread,
Mar 5, 2014, 6:10:09 PM3/5/14
to hypersp...@googlegroups.com
Hi, 

Francisco will be able to correct me if I'm wrong, but:

You can set a particular bound (either minimum or maximum) for a parameter p like so (Gaussian example):

>>> p = components.Gaussian()
>>> p.FWHM.bmin = 0.0             # setting minimum bound
>>> p.FWHM.bmax = 130.0           # setting maximum bound
>>> p.FWHM.bounded = True         # letting the component (in this case Gaussian) know that FWHM is bounded


and then to later use the bound in fit (yes, only mpfit supports bounds) you should write:

>>> m.fit(fitter='mpfit', bounded=True)

Best of luck,

Tomas


--
You received this message because you are subscribed to the Google Groups "hyperspy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hyperspy-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Andrew Thron

unread,
Mar 7, 2014, 12:06:02 PM3/7/14
to hypersp...@googlegroups.com
Tomas, 

Wow that was simpler then I thought it would be! Thank you for the help!

Cheers, 
Andrew 
Reply all
Reply to author
Forward
0 new messages