Residuals support & slight changes to (broken) persistence system
parent
a290f73957
commit
ab04c16e31
29
app.py
29
app.py
|
@ -90,17 +90,21 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
# path_hash = md5(filename.encode('utf-8')).hexdigest()
|
||||
|
||||
# def set_value(name, val):
|
||||
# with SqliteDict(f"./db/{path_hash}.sqlite", autocommit=True) as storage:
|
||||
# with SqliteDict(f"{getcwd()}/db/{path_hash}.sqlite", autocommit=True) as storage:
|
||||
# print(f"Change {name} to {val}.")
|
||||
# storage[name] = val
|
||||
# storage.commit()
|
||||
# print(f"Check: {storage[name]}")
|
||||
|
||||
# with SqliteDict(f"./db/{path_hash}.sqlite", autocommit=True) as storage:
|
||||
# with SqliteDict(f"{getcwd()}/db/{path_hash}.sqlite", autocommit=True) as storage:
|
||||
# print(f"Check: {storage[name]}")
|
||||
|
||||
# with SqliteDict(f"{getcwd()}/db/{path_hash}.sqlite", autocommit=True) as storage:
|
||||
|
||||
# for w in synced_value_widgets:
|
||||
# name = w.objectName()
|
||||
# try:
|
||||
# w.setValue(bool(storage[name]))
|
||||
# w.setValue(storage[name])
|
||||
# print(f"Loaded {name}.")
|
||||
# except KeyError:
|
||||
# print(f"Failed to load object {name}.")
|
||||
|
@ -110,8 +114,8 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
|
|||
# for w in synced_check_widgets:
|
||||
# name = w.objectName()
|
||||
# try:
|
||||
# w.setChecked(storage[name])
|
||||
# print(f"Loaded {name}.")
|
||||
# w.setChecked(bool(storage[name]))
|
||||
# print(f"Loaded {name} as {storage[name]}.")
|
||||
# except KeyError:
|
||||
# print(f"Failed to load object {name}.")
|
||||
# pass
|
||||
|
@ -308,6 +312,21 @@ Tau Average: {tau_avg}
|
|||
pass
|
||||
self.export_csv_button.pressed.connect(export_csv)
|
||||
|
||||
def export_csv_residuals():
|
||||
try:
|
||||
mem['residuals']
|
||||
except KeyError:
|
||||
display_error("No residual data to export.")
|
||||
return
|
||||
filename, _ = QtWidgets.QFileDialog.getSaveFileName(self, "Export Residuals CSV", "residuals.csv")
|
||||
df = DataFrame(mem['residuals'])
|
||||
# df.index = arange(1, len(df)+1)
|
||||
try:
|
||||
df.to_csv(filename, index=False)
|
||||
except:
|
||||
pass
|
||||
self.export_csv_button_resid.pressed.connect(export_csv_residuals)
|
||||
|
||||
# Show self
|
||||
|
||||
self.show()
|
||||
|
|
|
@ -810,7 +810,7 @@
|
|||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>261</width>
|
||||
<height>351</height>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
|
@ -868,7 +868,20 @@ p, li { white-space: pre-wrap; }
|
|||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export CSV</string>
|
||||
<string>Export Tau CSV</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="export_csv_button_resid">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>350</y>
|
||||
<width>221</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Export Residuals CSV</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -102,13 +102,19 @@ class FitGraph(BaseGraph):
|
|||
self.peak_index = i
|
||||
|
||||
def plot_data(self):
|
||||
resid = []
|
||||
for g_i in range(len(mem['isolated_peaks'])):
|
||||
peak = mem['isolated_peaks'][g_i][self.peak_index]
|
||||
x_data = np.arange(len(peak))
|
||||
x_data_target = x_data[mem['overlayed_peak_indices'][g_i][self.peak_index]+mem['shift_over_fit']:]
|
||||
peak_target = peak[mem['overlayed_peak_indices'][g_i][self.peak_index]+mem['shift_over_fit']:]
|
||||
popt = mem['fit_equations'][g_i][self.peak_index]['popt']
|
||||
self.canv.axes.plot(peak)
|
||||
self.canv.axes.plot(x_data_target, exp_func(x_data_target, *popt), color='red')
|
||||
|
||||
resid.append(peak_target - exp_func(x_data_target, *popt)),
|
||||
self.canv.axes.plot(x_data_target, peak_target - exp_func(x_data_target, *popt), c='green')
|
||||
mem['residuals'] = resid
|
||||
|
||||
class FitsGraphViewer(QtWidgets.QTabWidget):
|
||||
def __init__(self, x):
|
||||
|
@ -187,7 +193,7 @@ class TimeConstantGraphsViewer(QtWidgets.QTabWidget):
|
|||
self.clear()
|
||||
|
||||
for p_i in range(len(mem['time_constants'][0])):
|
||||
tab_name = str(p_i)
|
||||
tab_name = str(p_i+1)
|
||||
tau_graph = TimeConstantGraph(self)
|
||||
tau_graph.set_peak_index(p_i)
|
||||
self.addTab(tau_graph, tab_name)
|
||||
|
|
Loading…
Reference in New Issue