Copying & exporting tau data, touch up UI & histogram display

master
michael 2021-08-11 15:07:11 -07:00
parent 1c409ed2c6
commit 918944e39e
4 changed files with 24 additions and 12 deletions

19
app.py
View File

@ -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()

View File

@ -3,6 +3,7 @@ pandas
matplotlib
numpy
pyinstaller==4.4
pyperclip
sqlitedict
scipy
varname

View File

@ -41,7 +41,7 @@
<x>0</x>
<y>0</y>
<width>267</width>
<height>917</height>
<height>897</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@ -95,13 +95,13 @@
<property name="minimumSize">
<size>
<width>248</width>
<height>306</height>
<height>286</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>248</width>
<height>306</height>
<height>286</height>
</size>
</property>
<property name="font">
@ -845,7 +845,7 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot;-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;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QPushButton" name="copyResultsButton">
<widget class="QPushButton" name="copy_results_button">
<property name="geometry">
<rect>
<x>20</x>
@ -858,7 +858,7 @@ p, li { white-space: pre-wrap; }
<string>Copy</string>
</property>
</widget>
<widget class="QPushButton" name="exportPlaintextButton">
<widget class="QPushButton" name="export_csv_button">
<property name="geometry">
<rect>
<x>20</x>
@ -868,7 +868,7 @@ p, li { white-space: pre-wrap; }
</rect>
</property>
<property name="text">
<string>Export Text</string>
<string>Export CSV</string>
</property>
</widget>
</widget>

View File

@ -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)