diff --git a/.gitignore b/.gitignore
index c53e277..cb7d96b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -139,3 +139,4 @@ cython_debug/
# Local stuff to exclude
.vscode/
+mainwin.py
\ No newline at end of file
diff --git a/app.py b/app.py
index f470645..0394d58 100644
--- a/app.py
+++ b/app.py
@@ -1,14 +1,112 @@
import sys
-from PyQt5 import QtGui, QtWidgets, uic
+import crds_calc
+from pandas import read_csv
+from PyQt5 import QtGui, QtWidgets, QtCore
from memdb import mem
+from mainwin import Ui_MainWindow
+from widgets import BaseGraph
+import pathlib
+
+class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
+
+ csv_selected = QtCore.pyqtSignal()
+ correlation_complete = QtCore.pyqtSignal()
+ fitting_complete = QtCore.pyqtSignal()
-class AppWindow(QtWidgets.QMainWindow):
def __init__(self):
super(AppWindow, self).__init__()
- uic.loadUi('app.ui', self)
+ self.setupUi(self)
+
+ # Signals
+
+ # Graphing actions
+
+ self.csv_selected.connect(self.raw_data_graph.plot)
+ def corr_act():
+ self.groups_graph.plot()
+ self.graph_tabs.setCurrentIndex(1)
+ self.correlation_complete.connect(corr_act)
+
+ # Helpers
+
+ def display_warning(message: str):
+ msg = QtWidgets.QMessageBox()
+ msg.setIcon(QtWidgets.QMessageBox.Warning)
+ msg.setText("Warning")
+ msg.setInformativeText(message)
+ msg.setWindowTitle("Warning")
+ msg.exec_()
+
+ def display_error(message: str):
+ msg = QtWidgets.QMessageBox()
+ msg.setIcon(QtWidgets.QMessageBox.Critical)
+ msg.setText("Error")
+ msg.setInformativeText(message)
+ msg.setWindowTitle("Error")
+ msg.exec_()
+
+ def select_csv():
+ filename, _ = QtWidgets.QFileDialog.getOpenFileName(self)
+ data = None
+ try:
+ data = read_csv(filename, comment="%", delimiter=";").to_numpy()
+ except:
+ return
+ mem['x_data'] = data.transpose()[0]
+ mem['y_data'] = data.transpose()[1]
+ try:
+ mem['v_data'] = data.transpose()[2]
+ except IndexError:
+ display_warning('No voltage column detected. VThreshold algo will not work.')
+ self.csv_selected.emit()
+
+
+ # Universal Actions stuff
+
+ self.actionOpen_CSV_File.triggered.connect(select_csv)
+ self.actionGithub_Repository.triggered.connect(lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl('https://github.com/turtlebasket/crds_analyze')))
+
+ # Inputs
+
+ def init_correlate():
+ groups_raw = None
+ algo = self.combo_grouping_algo.currentIndex()
+ try:
+ if algo == 0:
+ display_error('VThreshold not yet implemented.')
+ return
+ elif algo == 1:
+ groups_raw = crds_calc.spaced_groups(
+ mem['x_data'],
+ mem['y_data'],
+ self.spin_group_len.value(),
+ self.spin_min_peakheight.value(),
+ self.spin_min_peakprominence.value(),
+ self.spin_moving_average_denom.value()
+ )
+
+ mem['groups_correlated'] = crds_calc.correlate_groups(groups_raw)
+ self.correlation_complete.emit()
+
+ except KeyError:
+ display_error('Failed to correlate. Did you import a data file & set parameters?')
+ self.correlate_button.pressed.connect(init_correlate)
+
+ # Show equation
+
+ pix = QtGui.QPixmap(f"{pathlib.Path(__file__).parent.resolve()}/assets/eq3.png")
+ item = QtWidgets.QGraphicsPixmapItem(pix)
+ item.setScale(0.38)
+ scene = QtWidgets.QGraphicsScene()
+ scene.addItem(item)
+ self.equation_view.setScene(scene)
+
+ # Show self
+
self.show()
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
window = AppWindow()
+ window.show()
sys.exit(app.exec_())
\ No newline at end of file
diff --git a/app.ui b/archive/app.ui
similarity index 80%
rename from app.ui
rename to archive/app.ui
index ad17675..f8799bb 100644
--- a/app.ui
+++ b/archive/app.ui
@@ -7,7 +7,7 @@
0
0
1091
- 580
+ 611
@@ -84,9 +84,9 @@
10
- 70
+ 120
241
- 141
+ 111
@@ -103,9 +103,9 @@
10
- 20
+ 50
221
- 111
+ 31
@@ -118,7 +118,7 @@
0
0
221
- 71
+ 21
@@ -148,8 +148,8 @@
0
0
- 221
- 103
+ 211
+ 21
@@ -170,64 +170,52 @@
- -
-
-
- Min peak height
-
-
-
- -
-
-
- 6
-
-
- 0.000400000000000
-
-
-
- -
-
-
- Min peak prominence
-
-
-
- -
-
-
- 6
-
-
- 0.001200000000000
-
-
-
- -
-
-
- Moving average size
-
-
-
- -
-
-
- 20
-
-
-
+
+
+
+ 10
+ 20
+ 221
+ 19
+
+
+ -
+
+ VThreshold (Voltage column required)
+
+
+ -
+
+ SpacedGroups
+
+
+
+
+
+
+ 10
+ 80
+ 221
+ 20
+
+
+
+ Every other group (MIRRORED)
+
+
+ true
+
+
60
- 220
+ 250
151
28
@@ -248,9 +236,9 @@
10
- 320
+ 350
241
- 171
+ 181
@@ -267,9 +255,9 @@
10
- 80
+ 90
221
- 89
+ 81
@@ -323,7 +311,7 @@
10
20
221
- 51
+ 61
@@ -332,7 +320,7 @@
60
- 500
+ 540
151
28
@@ -349,51 +337,11 @@
Fit
-
-
-
- 10
- 10
- 241
- 51
-
-
-
-
- 8
- 75
- true
-
-
-
- Grouping Algorithm
-
-
-
-
- 10
- 20
- 221
- 21
-
-
- -
-
- VThreshold (V column required)
-
-
- -
-
- SpacedGroups
-
-
-
-
10
- 260
+ 290
241
51
@@ -406,7 +354,7 @@
- Peak Isolation Config
+ Peak Isolation Config (timescale: ticks)
false
@@ -424,15 +372,101 @@
-
- Individual Peak Range
+ Overlapped Peak Range
-
-
+
+
+ 100000
+
+
+ 100
+
+
+ 5000
+
+
+
+
+
+
+
+
+
+ 10
+ 10
+ 241
+ 101
+
+
+
+
+ 8
+ 75
+ true
+
+
+
+ Peak Detection Config
+
+
+
+
+ 10
+ 20
+ 221
+ 74
+
+
+
+ -
+
+
+ Min peak height
+
+
+
+ -
+
6
+
+ 0.000400000000000
+
+
+
+ -
+
+
+ Min peak prominence
+
+
+
+ -
+
+
+ 6
+
+
+ 0.001200000000000
+
+
+
+ -
+
+
+ Moving average size
+
+
+
+ -
+
+
+ 20
+
@@ -445,7 +479,7 @@
0
0
1091
- 26
+ 21