Skip to content

Commit

Permalink
Merge pull request #233 from wpfff/analyzer
Browse files Browse the repository at this point in the history
small improvements for working with the initial guess.
  • Loading branch information
wpfff authored Nov 19, 2021
2 parents bed476a + 2675a28 commit 39f7f35
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions plottr/analyzer/fitters/fitter_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ def analyze(self, coordinates, data, dry=False, params={}, **fit_kwargs):
for pn, pv in self.guess(coordinates, data).items():
_params.add(pn, value=pv)
for pn, pv in params.items():
_params[pn] = pv
if isinstance(pv, lmfit.Parameter):
_params[pn] = pv
else:
_params[pn].set(value=pv)

if dry:
lmfit_result = lmfit.model.ModelResult(model, params=_params,
data=data,
coordinates=coordinates)
else:
lmfit_result = model.fit(data, params=_params,
coordinates=coordinates, **fit_kwargs)
for pn, pv in _params.items():
pv.set(vary=False)
lmfit_result = model.fit(data, params=_params,
coordinates=coordinates, **fit_kwargs)

return FitResult(lmfit_result)

Expand Down

0 comments on commit 39f7f35

Please sign in to comment.