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() self.check_advanced_peak_detection.isChecked()
) )
# print(mem['fit_equations']) # print(mem['fit_equations'])
self.peak_fits_graph.plot() self.peak_fit_viewer.plot()
self.graph_tabs.setCurrentIndex(4) self.graph_tabs.setCurrentIndex(4)
self.fit_button.pressed.connect(init_fit) self.fit_button.pressed.connect(init_fit)

View File

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

View File

@ -92,41 +92,72 @@ class AddedPeaksGraph(BaseGraph):
for i in mem['peak_indices']: 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) 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): 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): def plot_data(self):
for g_i in range(len(mem['isolated_peaks'])): 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][self.peak_index]
peak = mem['isolated_peaks'][g_i][p_i]
x_data = np.arange(len(peak)) x_data = np.arange(len(peak))
popt = mem['fit_equations'][g_i][p_i]['popt'] popt = mem['fit_equations'][g_i][self.peak_index]['popt']
self.canv.axes.plot(peak) self.canv.axes.plot(peak)
self.canv.axes.plot(x_data, exp_func(x_data, *popt), color='red') 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: def plot(self): # Create tabs & plot ALL data (each individual graph)
# self.canv.axes.remove() self.clear()
# except AttributeError:
# pass
# subplots_stacked = len(mem['isolated_peaks'][0]) # should all be same length for p_i in range(len(mem['isolated_peaks'][0])):
# axes = self.canv.figure.subplots(subplots_stacked, 1, sharex=True) 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'])): # class FitsGraph(BaseGraph):
# 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: # def __init__(self, x):
# ax.set(xlabel='x-label', ylabel='y-label') # 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): class TimeConstantGraph(BaseGraph):
pass pass