Improve naming consistency with lmfit
This commit is contained in:
parent
7c1e2fdf0c
commit
3e174f22e5
@ -191,7 +191,7 @@ def create():
|
|||||||
plot_fit_source.data.update(x=x_fit, y=fit.eval(x=x_fit))
|
plot_fit_source.data.update(x=x_fit, y=fit.eval(x=x_fit))
|
||||||
|
|
||||||
for i, model in enumerate(fit_params):
|
for i, model in enumerate(fit_params):
|
||||||
if "background" in model:
|
if "linear" in model:
|
||||||
comps = fit.eval_components(x=x_fit)
|
comps = fit.eval_components(x=x_fit)
|
||||||
plot_bkg_source.data.update(x=x_fit, y=comps[f"f{i}_"])
|
plot_bkg_source.data.update(x=x_fit, y=comps[f"f{i}_"])
|
||||||
break
|
break
|
||||||
@ -249,7 +249,7 @@ def create():
|
|||||||
|
|
||||||
plot.add_layout(
|
plot.add_layout(
|
||||||
Legend(
|
Legend(
|
||||||
items=[("data", [plot_scatter]), ("best fit", [plot_fit]), ("background", [plot_bkg])],
|
items=[("data", [plot_scatter]), ("best fit", [plot_fit]), ("linear", [plot_bkg])],
|
||||||
location="top_left",
|
location="top_left",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -324,10 +324,10 @@ def create():
|
|||||||
fitparams_add_dropdown = Dropdown(
|
fitparams_add_dropdown = Dropdown(
|
||||||
label="Add fit function",
|
label="Add fit function",
|
||||||
menu=[
|
menu=[
|
||||||
("Background", "background"),
|
("Linear", "linear"),
|
||||||
("Gauss", "gauss"),
|
("Gaussian", "gaussian"),
|
||||||
("Voigt", "voigt"),
|
("Voigt", "voigt"),
|
||||||
("Pseudo Voigt", "pseudovoigt"),
|
("Pseudo Voigt", "pvoigt"),
|
||||||
# ("Pseudo Voigt1", "pseudovoigt1"),
|
# ("Pseudo Voigt1", "pseudovoigt1"),
|
||||||
],
|
],
|
||||||
default_size=145,
|
default_size=145,
|
||||||
@ -369,16 +369,16 @@ def create():
|
|||||||
fitparams_remove_button.on_click(fitparams_remove_button_callback)
|
fitparams_remove_button.on_click(fitparams_remove_button_callback)
|
||||||
|
|
||||||
def fitparams_factory(function):
|
def fitparams_factory(function):
|
||||||
if function == "background":
|
if function == "linear":
|
||||||
params = ["slope", "intercept"]
|
params = ["slope", "intercept"]
|
||||||
elif function == "gauss":
|
elif function == "gaussian":
|
||||||
params = ["center", "sigma", "amplitude"]
|
params = ["amplitude", "center", "sigma"]
|
||||||
elif function == "voigt":
|
elif function == "voigt":
|
||||||
params = ["center", "sigma", "amplitude", "gamma"]
|
params = ["amplitude", "center", "sigma", "gamma"]
|
||||||
elif function == "pseudovoigt":
|
elif function == "pvoigt":
|
||||||
params = ["center", "sigma", "amplitude", "fraction"]
|
params = ["amplitude", "center", "sigma", "fraction"]
|
||||||
elif function == "pseudovoigt1":
|
elif function == "pseudovoigt1":
|
||||||
params = ["center", "g_sigma", "l_sigma", "amplitude", "fraction"]
|
params = ["amplitude", "center", "g_sigma", "l_sigma", "fraction"]
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown fit function")
|
raise ValueError("Unknown fit function")
|
||||||
|
|
||||||
@ -407,9 +407,9 @@ def create():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# start with `background` and `gauss` fit functions added
|
# start with `background` and `gauss` fit functions added
|
||||||
fitparams_add_dropdown_callback(types.SimpleNamespace(item="background"))
|
fitparams_add_dropdown_callback(types.SimpleNamespace(item="linear"))
|
||||||
fitparams_add_dropdown_callback(types.SimpleNamespace(item="gauss"))
|
fitparams_add_dropdown_callback(types.SimpleNamespace(item="gaussian"))
|
||||||
fitparams_select.value = ["gauss-1"] # add selection to gauss
|
fitparams_select.value = ["gaussian-1"] # add selection to gauss
|
||||||
|
|
||||||
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ def create():
|
|||||||
plot_fit_source.data.update(x=x_fit, y=fit.eval(x=x_fit))
|
plot_fit_source.data.update(x=x_fit, y=fit.eval(x=x_fit))
|
||||||
|
|
||||||
for i, model in enumerate(fit_params):
|
for i, model in enumerate(fit_params):
|
||||||
if "background" in model:
|
if "linear" in model:
|
||||||
comps = fit.eval_components(x=x_fit)
|
comps = fit.eval_components(x=x_fit)
|
||||||
plot_bkg_source.data.update(x=x_fit, y=comps[f"f{i}_"])
|
plot_bkg_source.data.update(x=x_fit, y=comps[f"f{i}_"])
|
||||||
break
|
break
|
||||||
@ -292,7 +292,7 @@ def create():
|
|||||||
|
|
||||||
plot.add_layout(
|
plot.add_layout(
|
||||||
Legend(
|
Legend(
|
||||||
items=[("data", [plot_scatter]), ("best fit", [plot_fit]), ("background", [plot_bkg])],
|
items=[("data", [plot_scatter]), ("best fit", [plot_fit]), ("linear", [plot_bkg])],
|
||||||
location="top_left",
|
location="top_left",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -401,10 +401,10 @@ def create():
|
|||||||
fitparams_add_dropdown = Dropdown(
|
fitparams_add_dropdown = Dropdown(
|
||||||
label="Add fit function",
|
label="Add fit function",
|
||||||
menu=[
|
menu=[
|
||||||
("Background", "background"),
|
("Linear", "linear"),
|
||||||
("Gauss", "gauss"),
|
("Gaussian", "gaussian"),
|
||||||
("Voigt", "voigt"),
|
("Voigt", "voigt"),
|
||||||
("Pseudo Voigt", "pseudovoigt"),
|
("Pseudo Voigt", "pvoigt"),
|
||||||
# ("Pseudo Voigt1", "pseudovoigt1"),
|
# ("Pseudo Voigt1", "pseudovoigt1"),
|
||||||
],
|
],
|
||||||
default_size=145,
|
default_size=145,
|
||||||
@ -446,16 +446,16 @@ def create():
|
|||||||
fitparams_remove_button.on_click(fitparams_remove_button_callback)
|
fitparams_remove_button.on_click(fitparams_remove_button_callback)
|
||||||
|
|
||||||
def fitparams_factory(function):
|
def fitparams_factory(function):
|
||||||
if function == "background":
|
if function == "linear":
|
||||||
params = ["slope", "intercept"]
|
params = ["slope", "intercept"]
|
||||||
elif function == "gauss":
|
elif function == "gaussian":
|
||||||
params = ["center", "sigma", "amplitude"]
|
params = ["amplitude", "center", "sigma"]
|
||||||
elif function == "voigt":
|
elif function == "voigt":
|
||||||
params = ["center", "sigma", "amplitude", "gamma"]
|
params = ["amplitude", "center", "sigma", "gamma"]
|
||||||
elif function == "pseudovoigt":
|
elif function == "pvoigt":
|
||||||
params = ["center", "sigma", "amplitude", "fraction"]
|
params = ["amplitude", "center", "sigma", "fraction"]
|
||||||
elif function == "pseudovoigt1":
|
elif function == "pseudovoigt1":
|
||||||
params = ["center", "g_sigma", "l_sigma", "amplitude", "fraction"]
|
params = ["amplitude", "center", "g_sigma", "l_sigma", "fraction"]
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown fit function")
|
raise ValueError("Unknown fit function")
|
||||||
|
|
||||||
@ -484,9 +484,9 @@ def create():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# start with `background` and `gauss` fit functions added
|
# start with `background` and `gauss` fit functions added
|
||||||
fitparams_add_dropdown_callback(types.SimpleNamespace(item="background"))
|
fitparams_add_dropdown_callback(types.SimpleNamespace(item="linear"))
|
||||||
fitparams_add_dropdown_callback(types.SimpleNamespace(item="gauss"))
|
fitparams_add_dropdown_callback(types.SimpleNamespace(item="gaussian"))
|
||||||
fitparams_select.value = ["gauss-1"] # add selection to gauss
|
fitparams_select.value = ["gaussian-1"] # add selection to gauss
|
||||||
|
|
||||||
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
fit_output_textinput = TextAreaInput(title="Fit results:", width=750, height=200)
|
||||||
|
|
||||||
|
@ -96,13 +96,13 @@ def fit_scan(scan, model_dict):
|
|||||||
model_name, _ = model_name.split("-")
|
model_name, _ = model_name.split("-")
|
||||||
prefix = f"f{model_index}_"
|
prefix = f"f{model_index}_"
|
||||||
|
|
||||||
if model_name == "background":
|
if model_name == "linear":
|
||||||
_model = LinearModel(prefix=prefix, name="background")
|
_model = LinearModel(prefix=prefix)
|
||||||
elif model_name == "gauss":
|
elif model_name == "gaussian":
|
||||||
_model = GaussianModel(prefix=prefix, name="gauss")
|
_model = GaussianModel(prefix=prefix)
|
||||||
elif model_name == "voigt":
|
elif model_name == "voigt":
|
||||||
_model = VoigtModel(prefix=prefix)
|
_model = VoigtModel(prefix=prefix)
|
||||||
elif model_name == "pseudovoigt":
|
elif model_name == "pvoigt":
|
||||||
_model = PseudoVoigtModel(prefix=prefix)
|
_model = PseudoVoigtModel(prefix=prefix)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown model name: '{model_name}'")
|
raise ValueError(f"Unknown model name: '{model_name}'")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user