Tau histograms for each comb tooth
parent
04b549d106
commit
3239ac2a2c
15
app.py
15
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
|
||||
|
|
|
@ -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()
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1343</width>
|
||||
<height>746</height>
|
||||
<height>653</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -39,12 +39,57 @@
|
|||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>-158</y>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<height>818</height>
|
||||
<height>878</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>239</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>239</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>GENERAL CONFIG</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
<item row="0" column="0">
|
||||
<layout class="QFormLayout" name="formLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_18">
|
||||
<property name="text">
|
||||
<string>Timestep</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="spin_timestep">
|
||||
<property name="decimals">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-99.989999999999995</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="minimumSize">
|
||||
|
@ -268,7 +313,7 @@
|
|||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>235</width>
|
||||
<width>221</width>
|
||||
<height>53</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -804,9 +849,6 @@
|
|||
<string>Time Constant</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_7">
|
||||
<item row="0" column="0">
|
||||
<widget class="TimeConstantGraph" name="tau_graph" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QScrollArea" name="scrollArea_2">
|
||||
<property name="minimumSize">
|
||||
|
@ -830,7 +872,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>279</width>
|
||||
<height>633</height>
|
||||
<height>548</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
|
@ -904,6 +946,9 @@ p, li { white-space: pre-wrap; }
|
|||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="TimeConstantGraphsViewer" name="tau_viewer"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -924,9 +969,6 @@ p, li { white-space: pre-wrap; }
|
|||
<string>File</string>
|
||||
</property>
|
||||
<addaction name="actionOpen_CSV_File"/>
|
||||
<addaction name="actionOpen_MATLAB_File"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExport_Binary"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit_2"/>
|
||||
</widget>
|
||||
|
@ -1002,6 +1044,14 @@ p, li { white-space: pre-wrap; }
|
|||
<string>F1</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSave_Options">
|
||||
<property name="text">
|
||||
<string>Save Options</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -1016,12 +1066,6 @@ p, li { white-space: pre-wrap; }
|
|||
<header>widgets</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TimeConstantGraph</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AddedPeaksGraph</class>
|
||||
<extends>QWidget</extends>
|
||||
|
@ -1040,6 +1084,12 @@ p, li { white-space: pre-wrap; }
|
|||
<header>widgets</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TimeConstantGraphsViewer</class>
|
||||
<extends>QTabWidget</extends>
|
||||
<header>widgets</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
34
widgets.py
34
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
|
||||
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue