diff --git a/app.py b/app.py
index e88b087..e7ebaf2 100644
--- a/app.py
+++ b/app.py
@@ -1,6 +1,6 @@
import sys
import crds_calc
-from pandas import read_csv
+from pandas import read_csv, DataFrame
from PyQt5 import QtGui, QtWidgets, QtCore
from db import mem
from mainwin import Ui_MainWindow
@@ -11,7 +11,8 @@ from varname.core import nameof
from hashlib import md5
from sqlitedict import SqliteDict
from pprint import PrettyPrinter
-import numpy as np
+from numpy import average as np_average
+from pyperclip import copy as pycopy
class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
@@ -264,11 +265,11 @@ class AppWindow(QtWidgets.QMainWindow, Ui_MainWindow):
tau_out = ""
for p_i in range(len(mem['time_constants'][0])):
- tau_avg = np.average(mem['time_constants'][0:len(mem['time_constants'])][p_i])
+ tau_avg = np_average(mem['time_constants'][0:len(mem['time_constants'])][p_i])
pp = PrettyPrinter(indent=2)
tau_out += f"""
-Tooth: {p_i+1}
+Tooth: {p_i}
Tau Average: {tau_avg}
"""
# NOTE: Insert above inside fstring to see raw data;
@@ -289,6 +290,16 @@ Tau Average: {tau_avg}
scene.addItem(item)
self.equation_view.setScene(scene)
+ # Tau output actions
+ self.copy_results_button.pressed.connect(lambda: pycopy(self.tau_output.toPlainText()))
+ def export_csv():
+ try:
+ filename, _ = QtWidgets.QFileDialog.getSaveFileName(self)
+ DataFrame(mem['time_constants']).to_csv(filename, index=False)
+ except KeyError:
+ display_error("No tau data to export.")
+ self.export_csv_button.pressed.connect(export_csv)
+
# Show self
self.show()
diff --git a/requirements.txt b/requirements.txt
index a7c11b9..59dafba 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,6 +3,7 @@ pandas
matplotlib
numpy
pyinstaller==4.4
+pyperclip
sqlitedict
scipy
varname
diff --git a/ui/mainwin.ui b/ui/mainwin.ui
index d6f4e21..05d9134 100644
--- a/ui/mainwin.ui
+++ b/ui/mainwin.ui
@@ -41,7 +41,7 @@
0
0
267
- 917
+ 897
@@ -95,13 +95,13 @@
248
- 306
+ 286
248
- 306
+ 286
@@ -845,7 +845,7 @@ p, li { white-space: pre-wrap; }
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:7.8pt;"><br /></p></body></html>
-
+
20
@@ -858,7 +858,7 @@ p, li { white-space: pre-wrap; }
Copy
-
+
20
@@ -868,7 +868,7 @@ p, li { white-space: pre-wrap; }
- Export Text
+ Export CSV
diff --git a/widgets.py b/widgets.py
index 6e51e6c..cc36b2c 100644
--- a/widgets.py
+++ b/widgets.py
@@ -175,7 +175,7 @@ class TimeConstantGraph(BaseGraph):
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)
+ self.canv.axes.hist(data, bins='auto', edgecolor='black')
class TimeConstantGraphsViewer(QtWidgets.QTabWidget):
def __init__(self, x):
@@ -187,7 +187,7 @@ class TimeConstantGraphsViewer(QtWidgets.QTabWidget):
self.clear()
for p_i in range(len(mem['time_constants'][0])):
- tab_name = str(p_i+1)
+ tab_name = str(p_i)
tau_graph = TimeConstantGraph(self)
tau_graph.set_peak_index(p_i)
self.addTab(tau_graph, tab_name)