diff --git a/app.py b/app.py index 861ce5c..f4fe8da 100644 --- a/app.py +++ b/app.py @@ -2,16 +2,13 @@ import sys import crds_calc from pandas import read_csv from PyQt5 import QtGui, QtWidgets, QtCore -from memdb import mem +from db import mem from mainwin import Ui_MainWindow from widgets import BaseGraph import pathlib class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow): - correlation_complete = QtCore.pyqtSignal() - fitting_complete = QtCore.pyqtSignal() - def __init__(self): super(AppWindow, self).__init__() self.setupUi(self) @@ -43,7 +40,9 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow): return mem['x_data'] = data.transpose()[0] mem['y_data'] = data.transpose()[1] - mem['timestep'] = mem['x_data'][1] - mem['x_data'][0] + timestep = mem['x_data'][1] - mem['x_data'][0] + mem['timestep'] = timestep + self.spin_timestep.setValue(timestep) self.raw_data_graph.plot() # Graph new stuff # self.groups_graph.clear() # Clear old stuff @@ -206,7 +205,11 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow): mem['shift_over_fit'] = self.spin_shift_over_fit.value() # print(mem['fit_equations']) self.peak_fit_viewer.plot() - self.graph_tabs.setCurrentIndex(4) + + mem['time_constants'] = crds_calc.get_time_constants(mem['fit_equations']) + self.tau_viewer.plot() + + self.graph_tabs.setCurrentIndex(5) self.fit_button.pressed.connect(init_fit) # Show equation diff --git a/memdb.py b/db.py similarity index 68% rename from memdb.py rename to db.py index aa0578d..15ca6ce 100644 --- a/memdb.py +++ b/db.py @@ -1,5 +1,6 @@ from sqlitedict import SqliteDict from varname.core import nameof +from hashlib import md5 class ModSqliteDict(SqliteDict): def __init__(self): @@ -12,4 +13,8 @@ class ModSqliteDict(SqliteDict): name = nameof(item) self[name] = item + def set_key_value(self, item, value): + name = nameof(item) + self[name] = value + mem = ModSqliteDict() \ No newline at end of file diff --git a/ui/mainwin.ui b/ui/mainwin.ui index 8ad2873..a73c6da 100644 --- a/ui/mainwin.ui +++ b/ui/mainwin.ui @@ -7,7 +7,7 @@ 0 0 1343 - 746 + 653 @@ -39,12 +39,57 @@ 0 - -158 + 0 261 - 818 + 878 + + + + + 239 + 0 + + + + + 239 + 16777215 + + + + GENERAL CONFIG + + + + + + + + Timestep + + + + + + + 6 + + + -99.989999999999995 + + + 0.010000000000000 + + + + + + + + @@ -268,7 +313,7 @@ 10 160 - 235 + 221 53 @@ -804,9 +849,6 @@ Time Constant - - - @@ -830,7 +872,7 @@ 0 0 279 - 633 + 548 @@ -904,6 +946,9 @@ p, li { white-space: pre-wrap; } + + + @@ -924,9 +969,6 @@ p, li { white-space: pre-wrap; } File - - - @@ -1002,6 +1044,14 @@ p, li { white-space: pre-wrap; } F1 + + + Save Options + + + Ctrl+S + + @@ -1016,12 +1066,6 @@ p, li { white-space: pre-wrap; }
widgets
1
- - TimeConstantGraph - QWidget -
widgets
- 1 -
AddedPeaksGraph QWidget @@ -1040,6 +1084,12 @@ p, li { white-space: pre-wrap; }
widgets
1
+ + TimeConstantGraphsViewer + QTabWidget +
widgets
+ 1 +
diff --git a/widgets.py b/widgets.py index e98900f..6e51e6c 100644 --- a/widgets.py +++ b/widgets.py @@ -4,7 +4,9 @@ import matplotlib matplotlib.use('Qt5Agg') from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar from matplotlib.figure import Figure -from memdb import mem +from matplotlib import colors +from matplotlib import pyplot as plt +from db import mem from crds_calc import exp_func class MplCanvas(FigureCanvasQTAgg): @@ -161,4 +163,32 @@ class FitsGraphViewer(QtWidgets.QTabWidget): # # ax.set(xlabel='x-label', ylabel='y-label') class TimeConstantGraph(BaseGraph): - pass \ No newline at end of file + + def __init__(self, x): + super().__init__(x) + self.peak_index = 0 + + def set_peak_index(self, i): + self.peak_index = i + + def plot_data(self): + data = [] + for g_i in range(len(mem['time_constants'])): + data.append(mem['time_constants'][g_i][self.peak_index]) + self.canv.axes.hist(data, bins='auto', alpha=0.8) + +class TimeConstantGraphsViewer(QtWidgets.QTabWidget): + def __init__(self, x): + super(TimeConstantGraphsViewer, self).__init__(x) + layout = QtWidgets.QGridLayout() + self.setLayout(layout) + + def plot(self): # Create tabs & plot ALL data (each individual graph) + self.clear() + + for p_i in range(len(mem['time_constants'][0])): + tab_name = str(p_i+1) + tau_graph = TimeConstantGraph(self) + tau_graph.set_peak_index(p_i) + self.addTab(tau_graph, tab_name) + tau_graph.plot()