UI refinements, show real and imag part seperately

This commit is contained in:
Markus Rosenstihl 2014-03-20 14:30:19 +01:00
parent 98d533d828
commit 62a8d0fb9d
12 changed files with 222 additions and 217 deletions

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'ConductivityGroupBox.ui' # Form implementation generated from reading ui file 'ConductivityGroupBox.ui'
# #
# Created: Thu Mar 20 00:40:00 2014 # Created: Thu Mar 20 13:41:01 2014
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

View File

@ -78,7 +78,7 @@ class BaseWidget(QGroupBox):
def getTable(self): def getTable(self):
tmp = [i.value() # selects the number, ignores the status tmp = [i.value() # selects the number, ignores the status
for i in self.inputs] for i in self.inputs]
#print "peakParams:", tmp #print "getTable:", tmp
return tmp return tmp
def update(self): def update(self):
@ -116,9 +116,8 @@ class PeakWidget(BaseWidget,QGroupBox):
BaseWidget.__init__(self) BaseWidget.__init__(self)
super(PeakWidget, self).__init__(parent) super(PeakWidget, self).__init__(parent)
self.ui = PeakGroupBox.Ui_PeakGroupBox() self.ui = PeakGroupBox.Ui_PeakGroupBox()
# replace eps and tau with LogFSpinBox
self.ui.setupUi(self) self.ui.setupUi(self)
# replace eps and tau with LogFSpinBox
self.ui.doubleSpinBox_1.setParent(None) self.ui.doubleSpinBox_1.setParent(None)
self.ui.doubleSpinBox_1 = LogFSpinBox(self) self.ui.doubleSpinBox_1 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1,1,1) self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1,1,1)
@ -126,6 +125,8 @@ class PeakWidget(BaseWidget,QGroupBox):
self.ui.doubleSpinBox_2 = LogFSpinBox(self) self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,2,1) self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,2,1)
self.ui.removeButton.clicked.connect(self.remove)
self.inputs = [ self.inputs = [
self.ui.doubleSpinBox_1, self.ui.doubleSpinBox_1,
self.ui.doubleSpinBox_2, self.ui.doubleSpinBox_2,
@ -153,7 +154,6 @@ class PeakWidget(BaseWidget,QGroupBox):
# self.ui.checkBox_4.stateChanged.connect(self._distrib_cd) # self.ui.checkBox_4.stateChanged.connect(self._distrib_cd)
self.ui.comboBox.currentIndexChanged.connect(self._distrib_select) self.ui.comboBox.currentIndexChanged.connect(self._distrib_select)
self.ui.removeButton.clicked.connect(self.remove)
def _distrib_select(self, dist): def _distrib_select(self, dist):
if dist == 0: # hav-neg: if dist == 0: # hav-neg:
@ -245,93 +245,6 @@ class PeakWidget(BaseWidget,QGroupBox):
self.errors[i].setText(sd) self.errors[i].setText(sd)
class ConductivityWidgetDeprecated( BaseWidget, QGroupBox):
def __init__(self, parent=None):
QGroupBox.__init__(self)
BaseWidget.__init__(self)
super(ConductivityWidget, self).__init__(parent)
self.setTitle(u"Conductivity …")
self.ui = ConductivityGroupBox.Ui_ConductivityGroupBox()
self.ui.setupUi(self)
# eps_static
#self.ui.doubleSpinBox_1.setParent(None)
#self.ui.doubleSpinBox_1 = LogFSpinBox(self)
#self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1,1,1)
# dc_conductivity
self.ui.doubleSpinBox_2.setParent(None)
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,2,1)
self.errors = [
self.ui.label_4,
self.ui.label_5,
self.ui.label_6,
]
self.inputs = [self.ui.doubleSpinBox_1,
self.ui.doubleSpinBox_2,
self.ui.doubleSpinBox_3]
self.fixedCheckBoxes = [self.ui.checkBox_1,
self.ui.checkBox_2,
self.ui.checkBox_3]
for dsb in self.inputs:
dsb.valueChanged.connect(self.changeValues)
self.ui.removeButton.clicked.connect(self.remove)
def remove(self):
self.removeMe.emit()
def changeValues(self, num):
self.changedTable.emit()
def fixedParameter(self):
return [0 if cb.isChecked() else 1 for cb in self.fixedCheckBoxes]
def setColor(self, color):
r, g, b = color
palette = self.palette()
palette.setColor(QPalette.Foreground, QColor(r, g, b))
self.setPalette(palette)
def getTable(self):
tmp = [i.value() # selects the number, ignores the status
for i in self.inputs]
#print "peakParams:", tmp
return tmp
def update(self):
self.changedTable.emit()
def updateTable(self, beta, sd_beta=None):
for i, arg in enumerate(beta):
self.inputs[i].setValue(arg)
sd_style=""
if i in (1,) and sd_beta is not None:
sd = "+/- %.3e"%(sd_beta[i])
elif i in (0,2) and sd_beta is not None:
sd = "+/- %.2f"%(sd_beta[i])
if sd_beta is not None:
if 0.0 < sd_beta[i]/arg < 0.2:
sd_style="background-color: rgba(0, 255, 0, 64);"
if 0.2 < sd_beta[i]/arg < 1.0:
sd_style="background-color: rgba(255,255, 0, 64);"
elif sd_beta[i]/arg > 1.0:
sd_style="background-color: rgba(255, 0, 0, 64);"
else:
sd = "( --- )"
self.errors[i].setStyleSheet(sd_style)
self.errors[i].setText(sd)
class StaticWidget(BaseWidget, QGroupBox): class StaticWidget(BaseWidget, QGroupBox):
def __init__(self, parent=None): def __init__(self, parent=None):
@ -383,13 +296,13 @@ class ConductivityWidget( BaseWidget, QGroupBox):
BaseWidget.__init__(self) BaseWidget.__init__(self)
super(ConductivityWidget, self).__init__(parent) super(ConductivityWidget, self).__init__(parent)
self.setTitle(u"Conductivity …")
self.ui = ConductivityGroupBox.Ui_ConductivityGroupBox() self.ui = ConductivityGroupBox.Ui_ConductivityGroupBox()
self.ui.setupUi(self) self.ui.setupUi(self)
self.ui.doubleSpinBox_2.setParent(None) self.ui.doubleSpinBox_2.setParent(None)
self.ui.doubleSpinBox_2 = LogFSpinBox(self) self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1) self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1)
self.ui.removeButton.clicked.connect(self.remove)
self.errors = [self.ui.label_5, self.errors = [self.ui.label_5,
@ -403,7 +316,6 @@ class ConductivityWidget( BaseWidget, QGroupBox):
for dsb in self.inputs: for dsb in self.inputs:
dsb.valueChanged.connect(self.changeValues) dsb.valueChanged.connect(self.changeValues)
self.ui.removeButton.clicked.connect(self.remove)
class PowerLawWidget(BaseWidget, QGroupBox): class PowerLawWidget(BaseWidget, QGroupBox):
@ -418,7 +330,7 @@ class PowerLawWidget( BaseWidget, QGroupBox):
self.ui.doubleSpinBox_2.setParent(None) self.ui.doubleSpinBox_2.setParent(None)
self.ui.doubleSpinBox_2 = LogFSpinBox(self) self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1) self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1)
self.ui.removeButton.clicked.connect(self.remove)
self.errors = [self.ui.label_5, self.errors = [self.ui.label_5,
self.ui.label_6] self.ui.label_6]
@ -431,4 +343,3 @@ class PowerLawWidget( BaseWidget, QGroupBox):
for dsb in self.inputs: for dsb in self.inputs:
dsb.valueChanged.connect(self.changeValues) dsb.valueChanged.connect(self.changeValues)
self.ui.removeButton.clicked.connect(self.remove)

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'PeakGroupBox.ui' # Form implementation generated from reading ui file 'PeakGroupBox.ui'
# #
# Created: Thu Mar 20 00:40:00 2014 # Created: Thu Mar 20 13:41:01 2014
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'PowerLawGroupBox.ui' # Form implementation generated from reading ui file 'PowerLawGroupBox.ui'
# #
# Created: Thu Mar 20 00:40:00 2014 # Created: Thu Mar 20 13:41:01 2014
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

141
QDS.py
View File

@ -106,10 +106,11 @@ class AppWindow(QMainWindow):
self.data = Data() self.data = Data()
self.fit_boundary = pg.LinearRegionItem(brush=QColor(0,127,254,15)) self.fit_boundary = pg.LinearRegionItem(brush=QColor(0,127,254,15))
self.ui.graphicsView.addItem(self.data.data_curve_imag)
self.ui.graphicsView.addItem(self.data.data_curve_real) self.ui.pgPlotWidget_imag.addItem(self.data.data_curve_imag)
self.ui.graphicsView.addItem(self.data.fitted_curve_imag) self.ui.pgPlotWidget_real.addItem(self.data.data_curve_real)
self.ui.graphicsView.addItem(self.data.fitted_curve_real) self.ui.pgPlotWidget_imag.addItem(self.data.fitted_curve_imag)
self.ui.pgPlotWidget_real.addItem(self.data.fitted_curve_real)
# cross hair # cross hair
if USE_CROSSH: if USE_CROSSH:
@ -117,30 +118,50 @@ class AppWindow(QMainWindow):
self.horizontalLine = pg.InfiniteLine(angle=0) self.horizontalLine = pg.InfiniteLine(angle=0)
self.verticalLine = pg.InfiniteLine(angle=90) self.verticalLine = pg.InfiniteLine(angle=90)
#self.ui.graphicsView.plotItem.addItem(self.poslabel) #self.ui.pgPlotWidget_imag.plotItem.addItem(self.poslabel)
self.ui.graphicsView.addItem(self.horizontalLine) self.ui.pgPlotWidget_imag.addItem(self.horizontalLine)
self.ui.graphicsView.addItem(self.verticalLine) self.ui.pgPlotWidget_imag.addItem(self.verticalLine)
self.ui.graphicsView.addItem(self.fit_boundary) self.ui.pgPlotWidget_imag.addItem(self.fit_boundary)
self.ui.graphicsView.setLogMode(x=True, y=True)
self.ui.graphicsView.showGrid(x=True, y=True) for pltwidgt in (self.ui.pgPlotWidget_real, self.ui.pgPlotWidget_imag):
self.ui.graphicsView.setLabel("bottom","Frequency",units="Hz") pltwidgt.setLogMode(x=True, y=True)
self.ui.graphicsView.setLabel("left", "Dielectric loss", units="Debye") pltwidgt.showGrid(x=True, y=True)
self.ui.graphicsView.disableAutoRange() pltwidgt.disableAutoRange()
pltwidgt.setLabel("bottom","Frequency",units="Hz")
self.ui.pgPlotWidget_imag.setLabel("left", "(I) Dielectric loss", units="Debye")
self.ui.pgPlotWidget_real.setLabel("left", "(R) Dielectric loss", units="Debye")
#self.peak_box_layout = QGridLayout() #self.peak_box_layout = QGridLayout()
#self.ui.scrollAreaWidgetContents.setLayout(self.peak_box_layout) #self.ui.scrollAreaWidgetContents.setLayout(self.peak_box_layout)
##self.huh = pg.SignalProxy(, slot=self.mPE) ##self.huh = pg.SignalProxy(, slot=self.mPE)
sc = self.ui.graphicsView.scene() sc_real = self.ui.pgPlotWidget_real.scene()
sc.sigMouseClicked.connect(self.mousePress) sc_real.sigMouseClicked.connect(self.mousePress)
sc_real.sigMouseMoved.connect(self.updateCrosshair)
sc_imag = self.ui.pgPlotWidget_imag.scene()
sc_imag.sigMouseClicked.connect(self.mousePress)
sc_imag.sigMouseMoved.connect(self.updateCrosshair)
sc.sigMouseMoved.connect(self.updateCrosshair)
def updateCrosshair(self,evt): def updateCrosshair(self,evt):
vb = self.ui.graphicsView.getPlotItem().vb
pos = vb.mapSceneToView(evt) vb_real = self.ui.pgPlotWidget_real.getPlotItem().vb
vb_imag = self.ui.pgPlotWidget_imag.getPlotItem().vb
if self.ui.pgPlotWidget_imag.underMouse():
pos = vb_imag.mapSceneToView(evt)
elif self.ui.pgPlotWidget_real.underMouse():
pos = vb_real.mapSceneToView(evt)
else:
pos = QPointF(1.0,1.0)
self.last_pos = pos self.last_pos = pos
if USE_CROSSH: if USE_CROSSH:
self.horizontalLine.setBounds([self.data.frequency.min(), self.data.frequency.max()]) self.horizontalLine.setBounds([self.data.frequency.min(), self.data.frequency.max()])
self.horizontalLine.setPos(pos.y()) self.horizontalLine.setPos(pos.y())
@ -151,21 +172,43 @@ class AppWindow(QMainWindow):
def mousePress(self, evt): def mousePress(self, evt):
data_pos = self.last_pos data_pos = self.last_pos
mouse_in_imag = self.ui.pgPlotWidget_imag.underMouse()
mouse_in_real = self.ui.pgPlotWidget_real.underMouse()
msgBox = QMessageBox()
if self.ui.actionAdd_Peak.isChecked(): if self.ui.actionAdd_Peak.isChecked():
if mouse_in_imag:
self.addPeak(data_pos) self.addPeak(data_pos)
self.ui.actionAdd_Peak.setChecked(False) self.ui.actionAdd_Peak.setChecked(False)
else:
msgBox.setText("Click in imaginary part")
msgBox.exec_()
if self.ui.actionAdd_Cond.isChecked(): if self.ui.actionAdd_Cond.isChecked():
if mouse_in_imag:
self.addCond(data_pos) self.addCond(data_pos)
self.ui.actionAdd_Cond.setChecked(False) self.ui.actionAdd_Cond.setChecked(False)
else:
msgBox.setText("Click in imaginary part")
msgBox.exec_()
if self.ui.actionAdd_PowerLaw.isChecked(): if self.ui.actionAdd_PowerLaw.isChecked():
if mouse_in_imag:
self.addPowerComplex(data_pos) self.addPowerComplex(data_pos)
self.ui.actionAdd_PowerLaw.setChecked(False) self.ui.actionAdd_PowerLaw.setChecked(False)
else:
msgBox.setText("Click in imaginary part")
msgBox.exec_()
if self.ui.actionAdd_Eps_Infty.isChecked(): if self.ui.actionAdd_Eps_Infty.isChecked():
if mouse_in_real:
self.addEpsInfty(data_pos) self.addEpsInfty(data_pos)
self.ui.actionAdd_Eps_Infty.setChecked(False) self.ui.actionAdd_Eps_Infty.setChecked(False)
else:
msgBox.setText("Click in real part")
msgBox.exec_()
def saveFitResult(self): def saveFitResult(self):
@ -234,8 +277,9 @@ class AppWindow(QMainWindow):
def addCond(self, pos): def addCond(self, pos):
self.statusBar().showMessage("Click on graph") _conductivity = Conductivity(plt_real=self.ui.pgPlotWidget_real,
_conductivity = Conductivity(pgPlotWidget=self.ui.graphicsView, limits=self.data.fit_limits) plt_imag=self.ui.pgPlotWidget_imag,
limits=self.data.fit_limits)
_conductivity.changedData.connect(self.updatePlot) _conductivity.changedData.connect(self.updatePlot)
_conductivity.removeObj.connect(self.delParamterObject) _conductivity.removeObj.connect(self.delParamterObject)
@ -247,9 +291,26 @@ class AppWindow(QMainWindow):
self.parameterWidget.vlayout.update() self.parameterWidget.vlayout.update()
self.updatePlot() self.updatePlot()
def addPowerComplex(self, pos):
_power_complex = PowerComplex(plt_imag=self.ui.pgPlotWidget_imag,
plt_real=self.ui.pgPlotWidget_real,
limits=self.data.fit_limits)
_power_complex.changedData.connect(self.updatePlot)
_power_complex.removeObj.connect(self.delParamterObject)
cond_par = [10**(pos.y() + pos.x())*2*N.pi , 1.0]
_power_complex.setParameter(beta=cond_par)
self.parameterWidget.vlayout.insertWidget(1,_power_complex.widget)
self.function_registry.register_function(_power_complex)
self.parameterWidget.vlayout.update()
self.updatePlot()
def addEpsInfty(self, pos): def addEpsInfty(self, pos):
self.statusBar().showMessage("Click on graph") _eps_infty = Static(plt_imag=self.ui.pgPlotWidget_imag,
_eps_infty = Static(pgPlotWidget=self.ui.graphicsView, limits=self.data.fit_limits) plt_real=self.ui.pgPlotWidget_real,
limits=self.data.fit_limits)
_eps_infty.changedData.connect(self.updatePlot) _eps_infty.changedData.connect(self.updatePlot)
_eps_infty.removeObj.connect(self.delParamterObject) _eps_infty.removeObj.connect(self.delParamterObject)
@ -262,23 +323,9 @@ class AppWindow(QMainWindow):
self.updatePlot() self.updatePlot()
def addPowerComplex(self, pos):
self.statusBar().showMessage("Click on graph")
_power_complex = PowerComplex(pgPlotWidget=self.ui.graphicsView, limits=self.data.fit_limits)
_power_complex.changedData.connect(self.updatePlot)
_power_complex.removeObj.connect(self.delParamterObject)
cond_par = [10**(pos.y() + pos.x())*2*N.pi , 1.0]
_power_complex.setParameter(beta=cond_par)
self.parameterWidget.vlayout.insertWidget(1,_power_complex.widget)
self.function_registry.register_function(_power_complex)
self.parameterWidget.vlayout.update()
self.updatePlot()
def delParamterObject(self, obj): def delParamterObject(self, obj):
print "unregister",obj print "unregister",obj
#self.ui.graphicsView.removeItem(self.PowerComplex.data_curve_real)
self.function_registry.unregister_function(obj) self.function_registry.unregister_function(obj)
self.updatePlot() self.updatePlot()
@ -286,15 +333,16 @@ class AppWindow(QMainWindow):
def addPeak(self, pos): def addPeak(self, pos):
self.statusBar().showMessage("Select Peak Position") id_list = [ key.id_num for key in
self.function_registry.get_registered_functions().keys()
if key.id_string == 'hn']
id_list = [ self.peakBoxes[key] for key in self.peakBoxes.keys()]
self.peakId = 1 self.peakId = 1
while self.peakId in id_list: while self.peakId in id_list:
self.peakId += 1 self.peakId += 1
_peak = Peak(id_num=self.peakId, plt_real=self.ui.pgPlotWidget_real, plt_imag=self.ui.pgPlotWidget_imag,
_peak = Peak(id=self.peakId, mpl=self.ui.graphicsView, limits=self.data.fit_limits) limits=self.data.fit_limits)
_peak.changedData.connect(self.updatePlot) _peak.changedData.connect(self.updatePlot)
_peak.removeObj.connect(self.delParamterObject) _peak.removeObj.connect(self.delParamterObject)
@ -314,7 +362,7 @@ class AppWindow(QMainWindow):
def delPeak(self): def delPeak(self):
for i, peak in enumerate(self.peakBoxes.keys()): for i, peak in enumerate(self.peakBoxes.keys()):
if peak.widget.isHidden(): if peak.widget.isHidden():
self.ui.graphicsView.removeItem(peak.mpl_line) self.ui.pgPlotWidget_imag.removeItem(peak.mpl_line)
self.parameterWidget.vlayout.removeWidget(peak.widget) self.parameterWidget.vlayout.removeWidget(peak.widget)
self.function_registry.unregister_function(peak) self.function_registry.unregister_function(peak)
@ -327,8 +375,6 @@ class AppWindow(QMainWindow):
self.data.set_fit_xlimits(10**log10fmin, 10**log10fmax) self.data.set_fit_xlimits(10**log10fmin, 10**log10fmax)
fit_methods = [fit_odr_cmplx, fit_lbfgsb, fit_anneal] fit_methods = [fit_odr_cmplx, fit_lbfgsb, fit_anneal]
# print "Limits (xmin, xmax, ymin, ymax)", self.data.fit_limits
# build function list # build function list
p0,funcs,fixed_params = [],[],[] p0,funcs,fixed_params = [],[],[]
for fcn in self.function_registry.get_registered_functions(): for fcn in self.function_registry.get_registered_functions():
@ -379,9 +425,11 @@ class AppWindow(QMainWindow):
self.data.set_data(_freq, _die_stor, _die_loss) self.data.set_data(_freq, _die_stor, _die_loss)
self.data.meta["T"] = Temp self.data.meta["T"] = Temp
self.fit_boundary.setRegion([N.log10(_freq.min()), N.log10(_freq.max())]) self.fit_boundary.setRegion([N.log10(_freq.min()), N.log10(_freq.max())])
self.ui.graphicsView.enableAutoRange() self.ui.pgPlotWidget_imag.enableAutoRange()
self.ui.pgPlotWidget_real.enableAutoRange()
self.updatePlot() self.updatePlot()
self.ui.graphicsView.disableAutoRange() self.ui.pgPlotWidget_imag.disableAutoRange()
self.ui.pgPlotWidget_real.disableAutoRange()
def updatePlot(self): def updatePlot(self):
@ -400,6 +448,9 @@ class AppWindow(QMainWindow):
self.data.fitted_curve_real.setData(self.data.frequency, self.data.epsilon_fit.real) self.data.fitted_curve_real.setData(self.data.frequency, self.data.epsilon_fit.real)
self.data.fitted_curve_imag.setData(self.data.frequency, self.data.epsilon_fit.imag) self.data.fitted_curve_imag.setData(self.data.frequency, self.data.epsilon_fit.imag)
else:
self.data.fitted_curve_real.setData([N.nan],[N.nan])
self.data.fitted_curve_imag.setData([N.nan],[N.nan])
def sigint_handler(*args): def sigint_handler(*args):
"""Handler for the SIGINT signal (CTRL + C). """Handler for the SIGINT signal (CTRL + C).
""" """

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'QDSMain.ui' # Form implementation generated from reading ui file 'QDSMain.ui'
# #
# Created: Thu Mar 20 00:39:59 2014 # Created: Thu Mar 20 13:41:01 2014
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -41,14 +41,26 @@ class Ui_MainWindow(object):
self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.graphicsView = PlotWidget(self.centralwidget) self.splitter = QtGui.QSplitter(self.centralwidget)
self.splitter.setOrientation(QtCore.Qt.Horizontal)
self.splitter.setObjectName(_fromUtf8("splitter"))
self.pgPlotWidget_imag = PlotWidget(self.splitter)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(3) sizePolicy.setHorizontalStretch(3)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.graphicsView.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(self.pgPlotWidget_imag.sizePolicy().hasHeightForWidth())
self.graphicsView.setSizePolicy(sizePolicy) self.pgPlotWidget_imag.setSizePolicy(sizePolicy)
self.graphicsView.setObjectName(_fromUtf8("graphicsView")) self.pgPlotWidget_imag.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
self.verticalLayout.addWidget(self.graphicsView) self.pgPlotWidget_imag.setObjectName(_fromUtf8("pgPlotWidget_imag"))
self.pgPlotWidget_real = PlotWidget(self.splitter)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(3)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pgPlotWidget_real.sizePolicy().hasHeightForWidth())
self.pgPlotWidget_real.setSizePolicy(sizePolicy)
self.pgPlotWidget_real.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.CrossCursor))
self.pgPlotWidget_real.setObjectName(_fromUtf8("pgPlotWidget_real"))
self.verticalLayout.addWidget(self.splitter)
MainWindow.setCentralWidget(self.centralwidget) MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow) self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 956, 22)) self.menubar.setGeometry(QtCore.QRect(0, 0, 956, 22))

View File

@ -26,15 +26,34 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="PlotWidget" name="graphicsView"> <widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="PlotWidget" name="pgPlotWidget_imag">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>3</horstretch> <horstretch>3</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="cursor" stdset="0">
<cursorShape>CrossCursor</cursorShape>
</property>
</widget>
<widget class="PlotWidget" name="pgPlotWidget_real">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="cursor" stdset="0">
<cursorShape>CrossCursor</cursorShape>
</property>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>

View File

@ -2,7 +2,7 @@
# Form implementation generated from reading ui file 'StaticGroupBox.ui' # Form implementation generated from reading ui file 'StaticGroupBox.ui'
# #
# Created: Thu Mar 20 00:40:00 2014 # Created: Thu Mar 20 13:41:01 2014
# by: PyQt4 UI code generator 4.10.3 # by: PyQt4 UI code generator 4.10.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -92,7 +92,7 @@ class Ui_StaticGroupBox(object):
def retranslateUi(self, StaticGroupBox): def retranslateUi(self, StaticGroupBox):
StaticGroupBox.setWindowTitle(_translate("StaticGroupBox", "GroupBox", None)) StaticGroupBox.setWindowTitle(_translate("StaticGroupBox", "GroupBox", None))
StaticGroupBox.setTitle(_translate("StaticGroupBox", "Static", None)) StaticGroupBox.setTitle(_translate("StaticGroupBox", "e\'_infty", None))
self.label.setText(_translate("StaticGroupBox", "Fix", None)) self.label.setText(_translate("StaticGroupBox", "Fix", None))
self.removeButton.setText(_translate("StaticGroupBox", "Remove", None)) self.removeButton.setText(_translate("StaticGroupBox", "Remove", None))
self.label_4.setText(_translate("StaticGroupBox", "TextLabel", None)) self.label_4.setText(_translate("StaticGroupBox", "TextLabel", None))

View File

@ -26,7 +26,7 @@
<string>GroupBox</string> <string>GroupBox</string>
</property> </property>
<property name="title"> <property name="title">
<string>Static</string> <string>e'_infty</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">

100
data.py
View File

@ -16,7 +16,8 @@ class Data:
self.epsilon = die_real + 1j * die_imag self.epsilon = die_real + 1j * die_imag
self.epsilon_fit = die_real*0 + 1j * die_imag*0 self.epsilon_fit = die_real*0 + 1j * die_imag*0
myPen_imag = pg.mkPen(width=3, color=(255,255,127)) myPen_imag = pg.mkPen(width=3, color=(255,255,127))
myPen_real = pg.mkPen(width=3, color=(255,127,127)) myPen_real = pg.mkPen(width=3, color=(51,255,127))
#33FF00
self.data_curve_imag = pg.PlotDataItem(x=[N.nan], y=[N.nan],pen=QColor(0,0,0,0), symbol='o', self.data_curve_imag = pg.PlotDataItem(x=[N.nan], y=[N.nan],pen=QColor(0,0,0,0), symbol='o',
symbolBrush=(255,127,0,127)) symbolBrush=(255,127,0,127))
@ -79,21 +80,26 @@ class Data:
class Conductivity(QObject): class Conductivity(QObject):
changedData = pyqtSignal() changedData = pyqtSignal()
removeObj = pyqtSignal(QObject) removeObj = pyqtSignal(QObject)
def __init__(self, pgPlotWidget=None, limits=None):
def __init__( self, plt_imag=None, plt_real=None, limits=None ):
QObject.__init__(self) QObject.__init__(self)
super(Conductivity, self) super(Conductivity, self)
self.widget = CustomWidgets.ConductivityWidget() self.widget = CustomWidgets.ConductivityWidget()
self.widget.changedTable.connect(self.updateData) self.widget.changedTable.connect(self.updateData)
self.widget.removeMe.connect(self.removeMe)
self.f=Functions() self.f=Functions()
myPen = pg.mkPen( style=Qt.DashLine, width=1) myPen = pg.mkPen( style=Qt.DashLine, width=2.5)
self.color=QColor("black") self.color=QColor("black")
self.plt_imag = plt_imag
self.plt_real = plt_real
self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen)
self.data_curve_imag = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen) self.data_curve_imag = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen)
self.pgPlotWidget = pgPlotWidget self.plt_imag.addItem(self.data_curve_imag)
self.pgPlotWidget.addItem(self.data_curve_imag) self.plt_real.addItem(self.data_curve_real)
self.limits = limits self.limits = limits
self.frequency = None self.frequency = None
@ -117,14 +123,15 @@ class Conductivity(QObject):
def updateData(self): def updateData(self):
# get current axis limits # get current axis limits
x_min, x_max, y_min, y_max = self.limits x_min, x_max, y_min, y_max = self.limits
self.frequency = N.logspace(N.log10(x_min), N.log10(x_max), 1024) self.frequency = N.logspace(N.log10(x_min), N.log10(x_max), 254)
sigma, sigma_N = self.getParameter() p = self.getParameter()
y = self.f.cond_cmplx([sigma, sigma_N], self.frequency) y = self.f.cond_cmplx(p, self.frequency)
print p
self.conductivity = y # imaginary part
self.conductivity = y[1] # imaginary part self.data_curve_real.setData(x=self.frequency, y=self.conductivity[0], label="Cond.")
self.data_curve_imag.setData(x=self.frequency, y=self.conductivity[1], label="Cond.")
self.data_curve_imag.setData(x=self.frequency, y=self.conductivity, label="Cond.")
self.changedData.emit() self.changedData.emit()
@ -138,7 +145,8 @@ class Conductivity(QObject):
return self.frequency, self.epsilon_static return self.frequency, self.epsilon_static
def removeMe(self): def removeMe(self):
self.pg_plot_widget.removeItem(self.data_curve_imag) self.plt_imag.removeItem(self.data_curve_imag)
self.plt_real.removeItem(self.data_curve_real)
self.removeObj.emit(self) self.removeObj.emit(self)
self.changedData.emit() self.changedData.emit()
@ -147,18 +155,21 @@ class PowerComplex(QObject):
changedData = pyqtSignal() changedData = pyqtSignal()
removeObj = pyqtSignal(QObject) removeObj = pyqtSignal(QObject)
def __init__(self, pgPlotWidget=None, limits=None): def __init__( self, plt_real=None, plt_imag=None, limits=None ):
QObject.__init__(self) QObject.__init__(self)
super(PowerComplex, self) super(PowerComplex, self)
self.widget = CustomWidgets.PowerLawWidget() self.widget = CustomWidgets.PowerLawWidget()
self.widget.changedTable.connect(self.updateData) self.widget.changedTable.connect(self.updateData)
self.widget.removeMe.connect(self.removeMe) self.widget.removeMe.connect(self.removeMe)
myPen = pg.mkPen( style=Qt.DashLine, width=1.5) myPen = pg.mkPen( style=Qt.DashLine, width=2.5)
self.color=QColor("black") self.color=QColor("black")
self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen) self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen)
self.pg_plot_widget = pgPlotWidget self.data_curve_imag = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen)
self.pg_plot_widget.addItem(self.data_curve_real) self.plt_imag = plt_imag
self.plt_real = plt_real
self.plt_imag.addItem(self.data_curve_imag)
self.plt_real.addItem(self.data_curve_real)
self.limits = limits self.limits = limits
@ -169,7 +180,8 @@ class PowerComplex(QObject):
self.id_string = 'power' self.id_string = 'power'
def removeMe(self): def removeMe(self):
self.pg_plot_widget.removeItem(self.data_curve_real) self.plt_real.removeItem(self.data_curve_real)
self.plt_imag.removeItem(self.data_curve_imag)
self.removeObj.emit(self) self.removeObj.emit(self)
self.changedData.emit() self.changedData.emit()
@ -192,8 +204,9 @@ class PowerComplex(QObject):
p = self.getParameter() p = self.getParameter()
self.frequency = N.logspace(N.log10(x_min), N.log10(x_max), 1024) self.frequency = N.logspace(N.log10(x_min), N.log10(x_max), 1024)
self.powerlaw = self.f.power_cmplx(p, self.frequency) [1] # imaginary part self.powerlaw = self.f.power_cmplx(p, self.frequency) # imaginary part
self.data_curve_real.setData(x=self.frequency, y=self.powerlaw, label="Power Law") self.data_curve_real.setData(x=self.frequency, y=self.powerlaw[0], label="Power Law")
self.data_curve_imag.setData(x=self.frequency, y=self.powerlaw[1], label="Power Law")
self.changedData.emit() self.changedData.emit()
@ -209,18 +222,19 @@ class Static(QObject):
changedData = pyqtSignal() changedData = pyqtSignal()
removeObj = pyqtSignal(QObject) removeObj = pyqtSignal(QObject)
def __init__(self, pgPlotWidget=None, limits=None): def __init__( self, plt_real=None, plt_imag=None, limits=None ):
QObject.__init__(self) QObject.__init__(self)
super(Static, self) super(Static, self)
self.plt_real = plt_real
self.plt_imag = plt_imag
self.widget = CustomWidgets.StaticWidget() self.widget = CustomWidgets.StaticWidget()
self.widget.changedTable.connect(self.updateData) self.widget.changedTable.connect(self.updateData)
self.widget.removeMe.connect(self.removeMe) self.widget.removeMe.connect(self.removeMe)
myPen = pg.mkPen( style=Qt.DashLine, width=1.5) myPen = pg.mkPen( style=Qt.DashLine, width=2.5)
self.color=QColor("black") self.color=QColor("black")
self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen) self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]), y=N.array([N.nan]), pen=myPen)
self.pg_plot_widget = pgPlotWidget self.plt_real.addItem(self.data_curve_real)
self.pg_plot_widget.addItem(self.data_curve_real)
self.limits = limits self.limits = limits
@ -231,7 +245,7 @@ class Static(QObject):
self.id_string = 'static' self.id_string = 'static'
def removeMe(self): def removeMe(self):
self.pg_plot_widget.removeItem(self.data_curve_real) self.plt_real.removeItem(self.data_curve_real)
self.removeObj.emit(self) self.removeObj.emit(self)
self.changedData.emit() self.changedData.emit()
@ -275,23 +289,28 @@ class Peak(QObject):
changedData = pyqtSignal() changedData = pyqtSignal()
removeObj = pyqtSignal(QObject) removeObj = pyqtSignal(QObject)
def __init__(self, id=None, mpl=None, limits=None): def __init__( self, id_num=None, plt_real=None, plt_imag=None, limits=None ):
QObject.__init__(self) QObject.__init__(self)
super(Peak, self).__init__() super(Peak, self).__init__()
self.widget = CustomWidgets.PeakWidget() self.widget = CustomWidgets.PeakWidget()
self.widget.setId(id) self.widget.setId(id_num)
self.color = id_to_color(id) self.color = id_to_color(id_num)
self.id_num = id_num
self.widget.setColor(self.color) self.widget.setColor(self.color)
self.widget.changedTable.connect(self.updatePeak) self.widget.changedTable.connect(self.updatePeak)
self.widget.removeMe.connect(self.removeMe) self.widget.removeMe.connect(self.removeMe)
self.pg_plot_widget = mpl self.plt_real = plt_real
self.plt_imag = plt_imag
self.limits = limits self.limits = limits
myPen = pg.mkPen( style=Qt.DashLine, width=2, color=self.color) myPen = pg.mkPen( style=Qt.DashLine, width=3, color=self.color)
self.data_curve_imag = pg.PlotDataItem(x=N.array([N.nan]),y=N.array([N.nan]), pen=myPen) self.data_curve_imag = pg.PlotDataItem(x=N.array([N.nan]),y=N.array([N.nan]), pen=myPen)
self.pg_plot_widget.addItem(self.data_curve_imag) self.data_curve_real = pg.PlotDataItem(x=N.array([N.nan]),y=N.array([N.nan]), pen=myPen)
self.plt_imag.addItem(self.data_curve_imag)
self.plt_real.addItem(self.data_curve_real)
self.frequency = None self.frequency = None
self.epsilon = None self.epsilon = None
self.f = Functions()
self.id_string = "hn" self.id_string = "hn"
def getParameter(self): def getParameter(self):
@ -308,19 +327,11 @@ class Peak(QObject):
self.updatePeak() self.updatePeak()
def updatePeak(self): def updatePeak(self):
# get current axis limits
# x_min, x_max = self.mpl.canvas.axes.get_xlim()
# y_min, y_max = self.mpl.canvas.axes.get_ylim()
x_min,x_max, y_min, y_max = self.limits x_min,x_max, y_min, y_max = self.limits
nu = N.logspace(N.log10(x_min), N.log10(x_max), 1024) self.frequency = N.logspace(N.log10(x_min), N.log10(x_max), 1024)
y = hn(self.getParameter(), nu) self.epsilon = self.f.hn_cmplx(self.getParameter(), self.frequency)
# clip data to axes limits self.data_curve_imag.setData(x=self.frequency, y=self.epsilon[1])
#mask = (y < y_max) & (y > y_min) self.data_curve_real.setData(x=self.frequency, y=self.epsilon[0])
#y = y[mask]
#nu = nu[mask]
self.frequency = nu[:]
self.epsilon = y[:]
self.data_curve_imag.setData(x=nu, y=y)
self.changedData.emit() self.changedData.emit()
def get_color(self): def get_color(self):
@ -330,6 +341,7 @@ class Peak(QObject):
return self.frequency,self.epsilon return self.frequency,self.epsilon
def removeMe(self): def removeMe(self):
self.pg_plot_widget.removeItem(self.data_curve_imag) self.plt_imag.removeItem(self.data_curve_imag)
self.plt_real.removeItem(self.data_curve_real)
self.removeObj.emit(self) self.removeObj.emit(self)
self.changedData.emit() self.changedData.emit()

View File

@ -2,7 +2,7 @@
# Resource object code # Resource object code
# #
# Created: Do. Mär. 20 00:39:59 2014 # Created: Do. Mär. 20 13:41:01 2014
# by: The Resource Compiler for PyQt (Qt v4.8.5) # by: The Resource Compiler for PyQt (Qt v4.8.5)
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!

View File

@ -137,7 +137,7 @@ class Functions:
self.list = { self.list = {
# provides functions: "id_string":(function, number_of_parameters) # provides functions: "id_string":(function, number_of_parameters)
"hn":(self.hn_cmplx,4), "hn":(self.hn_cmplx,4),
"conductivity":(self.cond_cmplx,1), "conductivity":(self.cond_cmplx,2),
"power":(self.power_cmplx,2), "power":(self.power_cmplx,2),
"static":(self.static_cmplx,1), "static":(self.static_cmplx,1),
} }
@ -152,8 +152,8 @@ class Functions:
def cond_cmplx(self, p, x): def cond_cmplx(self, p, x):
om = 2*N.pi*x om = 2*N.pi*x
sgma = p[0] sgma, n = p
cond = sgma/(1j*om) cond = sgma/(1j*om)**n
cplx = N.array([cond.real, -cond.imag]) cplx = N.array([cond.real, -cond.imag])
return cplx return cplx