Skip to content

Commit

Permalink
feffit_panel: add warning when rmin goes below rbkg
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed Nov 21, 2023
1 parent 4c260d7 commit 284d85c
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion larch/wxxas/feffit_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,7 @@ def __init__(self, parent=None, controller=None, **kws):
self.resetting = False
self.model_needs_rebuild = False
self.params_need_update = False
self.rmin_warned = False
TaskPanel.__init__(self, parent, controller, panel='feffit', **kws)
self.paths_data = {}
self.config_saved = self.get_defaultconfig()
Expand Down Expand Up @@ -772,8 +773,8 @@ def build_display(self):
fit_kmin = self.add_floatspin('fit_kmin', value=2, **fsopts)
fit_kmax = self.add_floatspin('fit_kmax', value=17, **fsopts)
fit_dk = self.add_floatspin('fit_dk', value=4, **fsopts)
fit_rmin = self.add_floatspin('fit_rmin', value=1, **fsopts)
fit_rmax = self.add_floatspin('fit_rmax', value=5, **fsopts)
fit_rmin = self.add_floatspin('fit_rmin', value=1, action=self.onRmin, **fsopts)

wids['fit_kwstring'] = Choice(pan, size=(150, -1),
choices=list(Feffit_KWChoices.keys()))
Expand Down Expand Up @@ -879,6 +880,30 @@ def add_text(text, dcol=1, newrow=True):
sizer.Add(self.paths_nb, 1, LEFT|wx.GROW, 5)
pack(self, sizer)

def onRmin(self, event=None, **kws):
dgroup = self.controller.get_group()
if dgroup is None:
return
rbkg = getattr(dgroup, 'rbkg', None)
callargs = getattr(dgroup, 'callargs', None)
if rbkg is None and callargs is not None:
autobk_args = getattr(callargs, 'autobk', {'rbkg': 1.0})
rbkg = autobk_args.get('rbkg', None)
if rbkg is None: rbkg = 0.0
rmin = self.wids['fit_rmin'].GetValue()
if rmin > (rbkg-0.025):
self.rmin_warned = False

if rmin < (rbkg-0.025) and not self.rmin_warned:
self.rmin_warned = True
Popup(self,
f"""Rmin={rmin:.3f} Ang is below Rbkg={rbkg:.3f} Ang.
This should be done with caution.""",
"Warning: Rmin < Rbkg",
style=wx.ICON_WARNING|wx.OK_DEFAULT)


def onPathsNBChanged(self, event=None):
updater = getattr(self.paths_nb.GetCurrentPage(), 'update_values', None)
if self.params_need_update and not self.resetting:
Expand Down

0 comments on commit 284d85c

Please sign in to comment.