Skip to content

Commit

Permalink
set correct default fwhm when changing model name in model_has_changes()
Browse files Browse the repository at this point in the history
  • Loading branch information
patquem committed Mar 5, 2025
1 parent 66a4848 commit 5dddd98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fitspy/apps/tkinter/toplevels.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from tkinter import IntVar, DoubleVar, StringVar, BooleanVar, W, E, END, RIGHT
from tkinter.ttk import Combobox

import numpy as np
from matplotlib.colors import rgb2hex
from lmfit import fit_report
from lmfit.model import ModelResult
Expand Down Expand Up @@ -147,8 +148,9 @@ def model_has_changed(self, i):
if new_model_name != old_model_name:
ampli = spectrum.peak_models[i].param_hints['ampli']['value']
x0 = spectrum.peak_models[i].param_hints['x0']['value']
peak_model = spectrum.create_peak_model(i + 1, new_model_name,
x0=x0, ampli=ampli)
dx = max(np.diff(spectrum.x))
peak_model = spectrum.create_peak_model(i + 1, new_model_name, x0=x0, ampli=ampli,
fwhm=dx, fwhm_l=dx, fwhm_r=dx)
spectrum.peak_models[i] = peak_model
self.spectrum.result_fit = lambda: None
self.plot() # pylint:disable=not-callable
Expand Down

0 comments on commit 5dddd98

Please sign in to comment.