1
0
forked from IPKM/nmreval

add exclude range to fit limits (#237)

Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de>
Reviewed-on: IPKM/nmreval#237
This commit is contained in:
2024-02-07 17:55:07 +00:00
parent 567148b7e6
commit 40746bfa7c
5 changed files with 24 additions and 5 deletions

View File

@ -888,7 +888,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
self.fit_dialog.load(self.management.active_sets)
for item in self.fit_dialog.preview_lines:
self.current_graph_widget.add_external(item)
if self.action_custom_range.isChecked():
if self.action_custom_range.isChecked() or self.actionExclude_region.isChecked():
self.current_graph_widget.add_external(self.fit_toolbar.region)
block_window = True
@ -904,7 +904,7 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
if self.current_graph_widget is None:
return
if action == self.action_custom_range and self.fit_dialog.isVisible():
if action in [self.action_custom_range, self.actionExclude_region] and self.fit_dialog.isVisible():
self.current_graph_widget.add_external(self.fit_toolbar.region)
else:
self.current_graph_widget.remove_external(self.fit_toolbar.region)

View File

@ -511,13 +511,16 @@ class UpperManagement(QtCore.QObject):
_x = data_i.x
# options for fit limits 'none', 'x', ('in', custom region), ('out', excluded region)
if fit_limits == 'none':
inside = slice(None)
elif fit_limits == 'x':
x_lim, _ = self.graphs[self.current_graph].ranges
inside = np.where((_x >= x_lim[0]) & (_x <= x_lim[1]))
elif fit_limits[0] == 'in':
inside = np.where((_x >= fit_limits[1][0]) & (_x <= fit_limits[1][1]))
else:
inside = np.where((_x >= fit_limits[0]) & (_x <= fit_limits[1]))
inside = np.where((_x < fit_limits[1][0]) | (_x > fit_limits[1][1]))
try:
if isinstance(we, str):