silx
silx copied to clipboard
Adding a custom theory to the FitManager
Good afternoon.
I am using a FitWidget, and I would like to add a pearson7 theory to the FitWidget with the FitManager. Although my pearson7 function seems to be fine, when I try to estimate a peak in the application, I get only 1 for every parameter, and when I fit I get this display :

I am adding the theory to the FitWidget like mentioned in the tutorial :
fit = FitManager()
fit.loadtheories(fittheories)
fit.addtheory("pearson7", function=pearson7, parameters=["backgr", "slopeLin", "amplitude", "center", "fwhmLike", "exposant"])
window = FitWidget(parent=self.plot, fitmngr=fit)
By the way, I tried with lmfit.lineshapes.pearson7 function, and with a custom one :
def pearson7(x, backgr, slopeLin, amplitude, center, fwhmLike, exposant):
return backgr + slopeLin * x + amplitude * (1 + ((x-center) / fwhmLike) ** 2.0) ** (-exposant)
But both gave me the same result, that you can see up above. Is there something wrong with my FitManager's approach ?
I understood I was loading a theory in a dirty way, so I added this to the addtheory function :
fit.addtheory("pearson7", function=pearson7bg,
parameters=["backgr", "slopeLin", "a", "amplitude", "center", "fwhmLike", "exposant"],
estimate=pearson7,
configure=FitTheories().configure)
It still does not work but I know the errors come from my estimate function.
I'm not familiar with silx fit, but the following doesn't sounds correct, you have no way to get the configured values:
configure=FitTheories().configure)
The simplest is to pass None as configure. The interface should request the user to fill the estimation by hand in that case.
I'm closing this since discussion is stalled and there is no clear issue to fix. Please re-open to discuss further.