forked from IPKM/nmreval
more detailed error message in fit preparation
This commit is contained in:
parent
e51a02d277
commit
2cbc7e8d75
@ -449,13 +449,23 @@ class UpperManagement(QtCore.QObject):
|
|||||||
# sets are not in active order but in order they first appeared in fit dialog
|
# sets are not in active order but in order they first appeared in fit dialog
|
||||||
# iterate over order of set id in active order and access parameter inside loop
|
# iterate over order of set id in active order and access parameter inside loop
|
||||||
# instead of directly looping
|
# instead of directly looping
|
||||||
list_ids = list(model_p['parameter'].keys())
|
try:
|
||||||
set_order = [self.active_id.index(i) for i in list_ids]
|
list_ids = list(model_p['parameter'].keys())
|
||||||
|
set_order = [self.active_id.index(i) for i in list_ids]
|
||||||
|
except ValueError as e:
|
||||||
|
raise Exception('Getting order failed') from e
|
||||||
|
|
||||||
for pos in set_order:
|
for pos in set_order:
|
||||||
set_id = list_ids[pos]
|
set_id = list_ids[pos]
|
||||||
|
try:
|
||||||
|
data_i = self.data[set_id]
|
||||||
|
except KeyError as e:
|
||||||
|
raise KeyError(f'{set_id} not found') from e
|
||||||
|
|
||||||
data_i = self.data[set_id]
|
try:
|
||||||
set_params = model_p['parameter'][set_id]
|
set_params = model_p['parameter'][set_id]
|
||||||
|
except KeyError as e:
|
||||||
|
raise KeyError(f'No parameter found for {set_id}') from e
|
||||||
|
|
||||||
if we_option.lower() == 'deltay':
|
if we_option.lower() == 'deltay':
|
||||||
we = data_i.y_err**2
|
we = data_i.y_err**2
|
||||||
@ -474,20 +484,26 @@ class UpperManagement(QtCore.QObject):
|
|||||||
if fit_limits == 'none':
|
if fit_limits == 'none':
|
||||||
inside = slice(None)
|
inside = slice(None)
|
||||||
elif fit_limits == 'x':
|
elif fit_limits == 'x':
|
||||||
x_lim, _ = self.graphs[self.current_graph].ranges
|
x_lim, _ = self.graphs[self.current_graph].range
|
||||||
inside = np.where((_x >= x_lim[0]) & (_x <= x_lim[1]))
|
inside = np.where((_x >= x_lim[0]) & (_x <= x_lim[1]))
|
||||||
else:
|
else:
|
||||||
inside = np.where((_x >= fit_limits[0]) & (_x <= fit_limits[1]))
|
inside = np.where((_x >= fit_limits[0]) & (_x <= fit_limits[1]))
|
||||||
|
|
||||||
if isinstance(we, str):
|
try:
|
||||||
d = fit_d.Data(_x[inside], _y[inside], we=we, idx=set_id)
|
if isinstance(we, str):
|
||||||
else:
|
d = fit_d.Data(_x[inside], _y[inside], we=we, idx=set_id)
|
||||||
d = fit_d.Data(_x[inside], _y[inside], we=we[inside], idx=set_id)
|
else:
|
||||||
|
d = fit_d.Data(_x[inside], _y[inside], we=we[inside], idx=set_id)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f'Setting data failed for {set_id}')
|
||||||
|
|
||||||
d.set_model(m)
|
d.set_model(m)
|
||||||
d.set_parameter(set_params[0], var=model_p['var'],
|
try:
|
||||||
lb=model_p['lb'], ub=model_p['ub'],
|
d.set_parameter(set_params[0], var=model_p['var'],
|
||||||
fun_kwargs=set_params[1])
|
lb=model_p['lb'], ub=model_p['ub'],
|
||||||
|
fun_kwargs=set_params[1])
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception('Setting parameter failed') from e
|
||||||
|
|
||||||
self.fitter.add_data(d)
|
self.fitter.add_data(d)
|
||||||
|
|
||||||
@ -504,7 +520,9 @@ class UpperManagement(QtCore.QObject):
|
|||||||
logger.error('Fit preparation failed', *e.args)
|
logger.error('Fit preparation failed', *e.args)
|
||||||
QtWidgets.QMessageBox.warning(QtWidgets.QWidget(),
|
QtWidgets.QMessageBox.warning(QtWidgets.QWidget(),
|
||||||
'Fit prep failed',
|
'Fit prep failed',
|
||||||
f'Fit preparation failed with message\n{e.args}')
|
f'Fit preparation failed:\n'
|
||||||
|
'Message:\n'
|
||||||
|
f'{e.args}:\n')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def start_fit(self):
|
def start_fit(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user