Break out each comb tooth's fit data into its own tab

master
michael 2021-08-05 15:47:55 -07:00
parent b64b18b1a7
commit d8b0b6d0fd
3 changed files with 76 additions and 41 deletions

2
app.py
View File

@ -203,7 +203,7 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
self.check_advanced_peak_detection.isChecked()
)
# print(mem['fit_equations'])
self.peak_fits_graph.plot()
self.peak_fit_viewer.plot()
self.graph_tabs.setCurrentIndex(4)
self.fit_button.pressed.connect(init_fit)

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>1343</width>
<height>907</height>
<height>746</height>
</rect>
</property>
<property name="windowTitle">
@ -40,8 +40,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>278</width>
<height>846</height>
<width>261</width>
<height>812</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -794,7 +794,11 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<widget class="FitsGraph" name="peak_fits_graph" native="true"/>
<widget class="FitsGraphViewer" name="peak_fit_viewer">
<property name="currentIndex">
<number>-1</number>
</property>
</widget>
</item>
</layout>
</widget>
@ -829,7 +833,7 @@
<x>0</x>
<y>0</y>
<width>279</width>
<height>802</height>
<height>641</height>
</rect>
</property>
<widget class="QGroupBox" name="groupBox_3">
@ -1021,12 +1025,6 @@ p, li { white-space: pre-wrap; }
<header>widgets</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FitsGraph</class>
<extends>QWidget</extends>
<header>widgets</header>
<container>1</container>
</customwidget>
<customwidget>
<class>AddedPeaksGraph</class>
<extends>QWidget</extends>
@ -1039,6 +1037,12 @@ p, li { white-space: pre-wrap; }
<header>widgets</header>
<container>1</container>
</customwidget>
<customwidget>
<class>FitsGraphViewer</class>
<extends>QTabWidget</extends>
<header>widgets</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@ -92,41 +92,72 @@ class AddedPeaksGraph(BaseGraph):
for i in mem['peak_indices']:
self.canv.axes.axvspan(int(i-self.params['peak_width']/2+self.params['shift_over']), int(i+self.params['peak_width']/2+self.params['shift_over']), color='red', alpha=0.4)
class FitsGraph(BaseGraph):
class FitGraph(BaseGraph):
def __init__(self, x):
super(FitsGraph, self).__init__(x)
super().__init__(x)
def set_peak_index(self, i):
self.peak_index = i
def plot_data(self):
for g_i in range(len(mem['isolated_peaks'])):
for p_i in range(len(mem['isolated_peaks'][g_i])):
peak = mem['isolated_peaks'][g_i][p_i]
x_data = np.arange(len(peak))
popt = mem['fit_equations'][g_i][p_i]['popt']
self.canv.axes.plot(peak)
self.canv.axes.plot(x_data, exp_func(x_data, *popt), color='red')
peak = mem['isolated_peaks'][g_i][self.peak_index]
x_data = np.arange(len(peak))
popt = mem['fit_equations'][g_i][self.peak_index]['popt']
self.canv.axes.plot(peak)
self.canv.axes.plot(x_data, exp_func(x_data, *popt), color='red')
# def plot_data(self):
class FitsGraphViewer(QtWidgets.QTabWidget):
def __init__(self, x):
super(FitsGraphViewer, self).__init__(x)
layout = QtWidgets.QGridLayout()
self.setLayout(layout)
# try:
# self.canv.axes.remove()
# except AttributeError:
# pass
def plot(self): # Create tabs & plot ALL data (each individual graph)
self.clear()
# subplots_stacked = len(mem['isolated_peaks'][0]) # should all be same length
# axes = self.canv.figure.subplots(subplots_stacked, 1, sharex=True)
for p_i in range(len(mem['isolated_peaks'][0])):
tab_name = str(p_i+1)
fit_graph = FitGraph(self)
fit_graph.set_peak_index(p_i)
self.addTab(fit_graph, tab_name)
fit_graph.plot()
# for g_i in range(len(mem['isolated_peaks'])):
# for p_i in range(subplots_stacked):
# peak = mem['isolated_peaks'][g_i][p_i]
# axes[p_i].plot(peak)
# x_data = np.arange(len(peak))
# popt = mem['fit_equations'][g_i][p_i]['popt']
# axes[p_i].plot(x_data, exp_func(x_data, *popt), color='red')
# class FitsGraph(BaseGraph):
# for ax in axs.flat:
# ax.set(xlabel='x-label', ylabel='y-label')
# def __init__(self, x):
# super(FitsGraph, self).__init__(x)
# # def plot_data(self):
# # for g_i in range(len(mem['isolated_peaks'])):
# # for p_i in range(len(mem['isolated_peaks'][g_i])):
# # peak = mem['isolated_peaks'][g_i][p_i]
# # x_data = np.arange(len(peak))
# # popt = mem['fit_equations'][g_i][p_i]['popt']
# # self.canv.axes.plot(peak)
# # self.canv.axes.plot(x_data, exp_func(x_data, *popt), color='red')
# def plot_data(self):
# try:
# self.canv.axes.remove()
# except AttributeError:
# pass
# subplots_stacked = len(mem['isolated_peaks'][0]) # should all be same length
# axes = self.canv.figure.subplots(subplots_stacked, 1, sharex=True)
# for g_i in range(len(mem['isolated_peaks'])):
# for p_i in range(subplots_stacked):
# peak = mem['isolated_peaks'][g_i][p_i]
# axes[p_i].plot(peak)
# # x_data = np.arange(len(peak))
# # popt = mem['fit_equations'][g_i][p_i]['popt']
# # axes[p_i].plot(x_data, exp_func(x_data, *popt), color='red')
# # for ax in axs.flat:
# # ax.set(xlabel='x-label', ylabel='y-label')
class TimeConstantGraph(BaseGraph):
pass