Skip to content

Commit

Permalink
feffit_panel: more fixes for handling no data, and for changing datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
newville committed May 27, 2024
1 parent 00fd076 commit 570630f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions larch/wxxas/feffit_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from larch.fitting import group2params, param
from larch.utils.jsonutils import encode4js, decode4js
from larch.inputText import is_complete
from larch.utils import fix_varname, fix_filename, gformat, mkdir
from larch.utils import fix_varname, fix_filename, gformat, mkdir, isValidName
from larch.io.export_modelresult import export_modelresult
from larch.xafs import feffit_report, feffpath
from larch.xafs.feffdat import FEFFDAT_VALUES
Expand Down Expand Up @@ -1150,7 +1150,7 @@ def onPlot(self, evt=None, dataset_name='_feffit_dataset',
dgroup = self.controller.get_group()
# print("no data? dgroup ", dataset.data, dgroup)
if dgroup is not None:
self.larch.eval(f"_feffit_dataset.set_datagroup({dgroup.groupname})")
self.larch.eval(f"{dataset_name}.set_datagroup({dgroup.groupname})")
dataset = getattr(self.larch.symtable, dataset_name, None)
dgroup = dataset.data
# print("now data now dgroup ", dataset, getattr(dataset, 'data', None), dgroup)
Expand Down Expand Up @@ -1200,7 +1200,11 @@ def onPlot(self, evt=None, dataset_name='_feffit_dataset',

def plot_feffit_result(self, dataset_name, topwin=None, **opts):

dataset = getattr(self.larch.symtable, dataset_name, None)
if isValidName(dataset_name):
dataset = getattr(self.larch.symtable, dataset_name, None)
else:
dataset = self.larch.eval(dataset_name)

if dataset is None:
dgroup = self.controller.get_group()
else:
Expand All @@ -1209,7 +1213,7 @@ def plot_feffit_result(self, dataset_name, topwin=None, **opts):
model_name = dataset_name + '.model'
has_data = getattr(dataset, 'has_data', True)

print("plot_feffit_result/ dgroup, dataset: ", dgroup, dataset, has_data)
#print("plot_feffit_result/ dgroup, dataset: ", dataset_name, dgroup, dataset, has_data)

title = fname = opts['filename']
if title is None:
Expand Down Expand Up @@ -1323,7 +1327,7 @@ def add_path(self, filename, pathinfo=None, feffpath=None, resize=True):

if pathinfo is None and feffpath is None:
raise ValueError("add_path needs a Feff Path or Path information")

self.params_need_update = True
parent, fname = os.path.split(filename)
parent, feffrun = os.path.split(parent)

Expand Down Expand Up @@ -1513,7 +1517,7 @@ def build_fitmodel(self, groupname=None, opts=None):
if self.dgroup is None:
self.dgroup = self.controller.get_group()

self.params_panel.update()
# self.params_panel.update()
cmds.extend(self.params_panel.generate_params())

if opts is None:
Expand Down

0 comments on commit 570630f

Please sign in to comment.