BaseWidget for parameters gerneralized, YAFF implementation started

This commit is contained in:
Markus Rosenstihl 2014-03-20 17:02:58 +01:00
parent 4f5cdc7103
commit a8ad4b68cb
12 changed files with 963 additions and 49 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 14:46:49 2014 # Created: Thu Mar 20 16:44:40 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

@ -5,6 +5,7 @@ import ConductivityGroupBox
import PeakGroupBox import PeakGroupBox
import PowerLawGroupBox import PowerLawGroupBox
import StaticGroupBox import StaticGroupBox
import YAFFparameters
__author__ = 'markusro' __author__ = 'markusro'
@ -49,6 +50,7 @@ class ParameterWidget(QWidget):
def add(self, wdgt): def add(self, wdgt):
self.vlayout.insertWidget(self.vlayout.count()-1, wdgt) self.vlayout.insertWidget(self.vlayout.count()-1, wdgt)
self.vlayout.update() self.vlayout.update()
if __name__ == "__main__": if __name__ == "__main__":
app = QApplication([]) app = QApplication([])
@ -90,9 +92,12 @@ class BaseWidget(QGroupBox):
for i, arg in enumerate(beta): for i, arg in enumerate(beta):
self.inputs[i].setValue(arg) self.inputs[i].setValue(arg)
sd_style="" sd_style=""
if i in (0,) and sd_beta is not None:
if isinstance(self.inputs[i], LogFSpinBox) and sd_beta is not None:
#if i in (0,) and sd_beta is not None:
sd = "+/- %.3e"%(sd_beta[i]) sd = "+/- %.3e"%(sd_beta[i])
elif i in (1,) and sd_beta is not None: elif isinstance(self.inputs[i], QDoubleSpinBox) and sd_beta is not None:
#elif i in (1,) and sd_beta is not None:
sd = "+/- %.2f"%(sd_beta[i]) sd = "+/- %.2f"%(sd_beta[i])
if sd_beta is not None: if sd_beta is not None:
if 0.0 < sd_beta[i]/arg < 0.2: if 0.0 < sd_beta[i]/arg < 0.2:
@ -222,29 +227,29 @@ class PeakWidget(BaseWidget,QGroupBox):
self.setPalette(palette) self.setPalette(palette)
#
def updateTable(self, beta=None, sd_beta = None): # def updateTable(self, beta=None, sd_beta = None):
#
#
for i, arg in enumerate(beta): # for i, arg in enumerate(beta):
self.inputs[i].setValue(arg) # self.inputs[i].setValue(arg)
sd_style="" # sd_style=""
if i in (0,1) and sd_beta is not None: # if i in (0,1) and sd_beta is not None:
sd = "+/- %.3e"%(sd_beta[i]) # sd = "+/- %.3e"%(sd_beta[i])
elif i in (2,3) and sd_beta is not None: # elif i in (2,3) and sd_beta is not None:
sd = "+/- %.2f"%(sd_beta[i]) # sd = "+/- %.2f"%(sd_beta[i])
if sd_beta is not None: # if sd_beta is not None:
if 0.0 < sd_beta[i]/arg < 0.2: # if 0.0 < sd_beta[i]/arg < 0.2:
sd_style="background-color: rgba(0, 255, 0, 64);" # sd_style="background-color: rgba(0, 255, 0, 64);"
if 0.2 < sd_beta[i]/arg < 1.0: # if 0.2 < sd_beta[i]/arg < 1.0:
sd_style="background-color: rgba(255,255, 0, 64);" # sd_style="background-color: rgba(255,255, 0, 64);"
elif sd_beta[i]/arg > 1.0: # elif sd_beta[i]/arg > 1.0:
sd_style="background-color: rgba(255, 0, 0, 64);" # sd_style="background-color: rgba(255, 0, 0, 64);"
#
else: # else:
sd = "( --- )" # sd = "( --- )"
self.errors[i].setStyleSheet(sd_style) # self.errors[i].setStyleSheet(sd_style)
self.errors[i].setText(sd) # self.errors[i].setText(sd)
class StaticWidget(BaseWidget, QGroupBox): class StaticWidget(BaseWidget, QGroupBox):
@ -271,24 +276,6 @@ class StaticWidget(BaseWidget, QGroupBox):
self.ui.removeButton.clicked.connect(self.remove) self.ui.removeButton.clicked.connect(self.remove)
def updateTable(self, beta, sd_beta=None):
for i, arg in enumerate(beta):
self.inputs[i].setValue(arg)
sd_style=""
if sd_beta is not None:
sd = "+/- %.2f"%(sd_beta[i])
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 ConductivityWidget(BaseWidget, QGroupBox): class ConductivityWidget(BaseWidget, QGroupBox):
@ -345,3 +332,65 @@ class PowerLawWidget(BaseWidget, QGroupBox):
for dsb in self.inputs: for dsb in self.inputs:
dsb.valueChanged.connect(self.changeValues) dsb.valueChanged.connect(self.changeValues)
class YaffWidget(BaseWidget, QGroupBox):
def __init__(self, parent=None):
QGroupBox.__init__(self)
BaseWidget.__init__(self)
super(YaffWidget, self).__init__(parent)
self.ui = YAFFparameters.Ui_Form()
self.ui.setupUi(self)
self.ui.doubleSpinBox_1.setParent(None)
self.ui.doubleSpinBox_1 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1, 1, 1)
self.ui.doubleSpinBox_2.setParent(None)
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2, 2, 1)
self.ui.doubleSpinBox_6.setParent(None)
self.ui.doubleSpinBox_6 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_6, 6, 1)
self.ui.removeButton.clicked.connect(self.remove)
self.errors = [self.ui.label_1,
self.ui.label_2,
self.ui.label_3,
self.ui.label_4,
self.ui.label_5,
self.ui.label_6,
self.ui.label_7,
self.ui.label_8,
self.ui.label_9,
self.ui.label_10,
]
self.inputs = [self.ui.doubleSpinBox_1,
self.ui.doubleSpinBox_2,
self.ui.doubleSpinBox_3,
self.ui.doubleSpinBox_4,
self.ui.doubleSpinBox_5,
self.ui.doubleSpinBox_6,
self.ui.doubleSpinBox_7,
self.ui.doubleSpinBox_8,
self.ui.doubleSpinBox_9,
self.ui.doubleSpinBox_10,
]
self.fixedCheckBoxes = [ self.ui.checkBox_1,
self.ui.checkBox_2,
self.ui.checkBox_3,
self.ui.checkBox_4,
self.ui.checkBox_5,
self.ui.checkBox_6,
self.ui.checkBox_7,
self.ui.checkBox_8,
self.ui.checkBox_9,
self.ui.checkBox_10,
]
for dsb in self.inputs:
dsb.valueChanged.connect(self.changeValues)

View File

@ -5,3 +5,4 @@ all:
pyuic4 ConductivityGroupBox.ui -o ConductivityGroupBox.py pyuic4 ConductivityGroupBox.ui -o ConductivityGroupBox.py
pyuic4 PowerLawGroupBox.ui -o PowerLawGroupBox.py pyuic4 PowerLawGroupBox.ui -o PowerLawGroupBox.py
pyuic4 StaticGroupBox.ui -o StaticGroupBox.py pyuic4 StaticGroupBox.ui -o StaticGroupBox.py
pyuic4 YAFFparameters.ui -o YAFFparameters.py

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 14:46:49 2014 # Created: Thu Mar 20 16:44:40 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 14:46:49 2014 # Created: Thu Mar 20 16:44:40 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 'QDSMain.ui' # Form implementation generated from reading ui file 'QDSMain.ui'
# #
# Created: Thu Mar 20 14:46:49 2014 # Created: Thu Mar 20 16:44:40 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 'StaticGroupBox.ui' # Form implementation generated from reading ui file 'StaticGroupBox.ui'
# #
# Created: Thu Mar 20 14:46:49 2014 # Created: Thu Mar 20 16:44:40 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!

281
YAFFparameters.py Normal file
View File

@ -0,0 +1,281 @@
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'YAFFparameters.ui'
#
# Created: Thu Mar 20 16:44:40 2014
# by: PyQt4 UI code generator 4.10.3
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(270, 396)
self.gridLayout = QtGui.QGridLayout(Form)
self.gridLayout.setMargin(1)
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.checkBox_2 = QtGui.QCheckBox(Form)
self.checkBox_2.setText(_fromUtf8(""))
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.gridLayout.addWidget(self.checkBox_2, 3, 3, 1, 1)
self.checkBox_1 = QtGui.QCheckBox(Form)
self.checkBox_1.setText(_fromUtf8(""))
self.checkBox_1.setObjectName(_fromUtf8("checkBox_1"))
self.gridLayout.addWidget(self.checkBox_1, 2, 3, 1, 1)
self.label_4 = QtGui.QLabel(Form)
self.label_4.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_4.setObjectName(_fromUtf8("label_4"))
self.gridLayout.addWidget(self.label_4, 7, 0, 1, 1)
self.label_21 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_21.sizePolicy().hasHeightForWidth())
self.label_21.setSizePolicy(sizePolicy)
self.label_21.setObjectName(_fromUtf8("label_21"))
self.gridLayout.addWidget(self.label_21, 13, 2, 1, 1)
self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_1.setObjectName(_fromUtf8("doubleSpinBox_1"))
self.gridLayout.addWidget(self.doubleSpinBox_1, 2, 1, 1, 1)
self.doubleSpinBox_4 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_4.setSingleStep(0.05)
self.doubleSpinBox_4.setObjectName(_fromUtf8("doubleSpinBox_4"))
self.gridLayout.addWidget(self.doubleSpinBox_4, 7, 1, 1, 1)
self.label_1 = QtGui.QLabel(Form)
self.label_1.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_1.setObjectName(_fromUtf8("label_1"))
self.gridLayout.addWidget(self.label_1, 2, 0, 1, 1)
self.label_16 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_16.sizePolicy().hasHeightForWidth())
self.label_16.setSizePolicy(sizePolicy)
self.label_16.setObjectName(_fromUtf8("label_16"))
self.gridLayout.addWidget(self.label_16, 7, 2, 1, 1)
self.doubleSpinBox_6 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_6.setObjectName(_fromUtf8("doubleSpinBox_6"))
self.gridLayout.addWidget(self.doubleSpinBox_6, 9, 1, 1, 1)
self.label_18 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_18.sizePolicy().hasHeightForWidth())
self.label_18.setSizePolicy(sizePolicy)
self.label_18.setObjectName(_fromUtf8("label_18"))
self.gridLayout.addWidget(self.label_18, 8, 2, 1, 1)
self.label_5 = QtGui.QLabel(Form)
self.label_5.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_5.setObjectName(_fromUtf8("label_5"))
self.gridLayout.addWidget(self.label_5, 8, 0, 1, 1)
self.label_11 = QtGui.QLabel(Form)
self.label_11.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_11.setObjectName(_fromUtf8("label_11"))
self.gridLayout.addWidget(self.label_11, 12, 0, 1, 1)
self.label_14 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_14.sizePolicy().hasHeightForWidth())
self.label_14.setSizePolicy(sizePolicy)
self.label_14.setObjectName(_fromUtf8("label_14"))
self.gridLayout.addWidget(self.label_14, 12, 2, 1, 1)
self.label_17 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_17.sizePolicy().hasHeightForWidth())
self.label_17.setSizePolicy(sizePolicy)
self.label_17.setObjectName(_fromUtf8("label_17"))
self.gridLayout.addWidget(self.label_17, 9, 2, 1, 1)
self.label_type = QtGui.QLabel(Form)
self.label_type.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_type.setObjectName(_fromUtf8("label_type"))
self.gridLayout.addWidget(self.label_type, 0, 0, 1, 1)
self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_3.setSingleStep(0.05)
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3"))
self.gridLayout.addWidget(self.doubleSpinBox_3, 5, 1, 1, 1)
self.label_huh = QtGui.QLabel(Form)
self.label_huh.setObjectName(_fromUtf8("label_huh"))
self.gridLayout.addWidget(self.label_huh, 1, 0, 1, 1)
self.label_19 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_19.sizePolicy().hasHeightForWidth())
self.label_19.setSizePolicy(sizePolicy)
self.label_19.setObjectName(_fromUtf8("label_19"))
self.gridLayout.addWidget(self.label_19, 3, 2, 1, 1)
self.label_10 = QtGui.QLabel(Form)
self.label_10.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_10.setObjectName(_fromUtf8("label_10"))
self.gridLayout.addWidget(self.label_10, 13, 0, 1, 1)
self.label_2 = QtGui.QLabel(Form)
self.label_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout.addWidget(self.label_2, 3, 0, 1, 1)
self.label_3 = QtGui.QLabel(Form)
self.label_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 5, 0, 1, 1)
self.doubleSpinBox_9 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_9.setObjectName(_fromUtf8("doubleSpinBox_9"))
self.gridLayout.addWidget(self.doubleSpinBox_9, 12, 1, 1, 1)
self.label_13 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_13.sizePolicy().hasHeightForWidth())
self.label_13.setSizePolicy(sizePolicy)
self.label_13.setObjectName(_fromUtf8("label_13"))
self.gridLayout.addWidget(self.label_13, 11, 2, 1, 1)
self.label_22 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_22.sizePolicy().hasHeightForWidth())
self.label_22.setSizePolicy(sizePolicy)
self.label_22.setObjectName(_fromUtf8("label_22"))
self.gridLayout.addWidget(self.label_22, 2, 2, 1, 1)
self.label_15 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_15.sizePolicy().hasHeightForWidth())
self.label_15.setSizePolicy(sizePolicy)
self.label_15.setObjectName(_fromUtf8("label_15"))
self.gridLayout.addWidget(self.label_15, 5, 2, 1, 1)
self.label_8 = QtGui.QLabel(Form)
self.label_8.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_8.setObjectName(_fromUtf8("label_8"))
self.gridLayout.addWidget(self.label_8, 11, 0, 1, 1)
self.label_6 = QtGui.QLabel(Form)
self.label_6.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_6.setObjectName(_fromUtf8("label_6"))
self.gridLayout.addWidget(self.label_6, 9, 0, 1, 1)
self.doubleSpinBox_7 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_7.setSingleStep(0.05)
self.doubleSpinBox_7.setObjectName(_fromUtf8("doubleSpinBox_7"))
self.gridLayout.addWidget(self.doubleSpinBox_7, 10, 1, 1, 1)
self.label_20 = QtGui.QLabel(Form)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_20.sizePolicy().hasHeightForWidth())
self.label_20.setSizePolicy(sizePolicy)
self.label_20.setObjectName(_fromUtf8("label_20"))
self.gridLayout.addWidget(self.label_20, 10, 2, 1, 1)
self.label_7 = QtGui.QLabel(Form)
self.label_7.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_7.setObjectName(_fromUtf8("label_7"))
self.gridLayout.addWidget(self.label_7, 10, 0, 1, 1)
self.doubleSpinBox_8 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_8.setSingleStep(0.05)
self.doubleSpinBox_8.setObjectName(_fromUtf8("doubleSpinBox_8"))
self.gridLayout.addWidget(self.doubleSpinBox_8, 11, 1, 1, 1)
self.doubleSpinBox_10 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_10.setObjectName(_fromUtf8("doubleSpinBox_10"))
self.gridLayout.addWidget(self.doubleSpinBox_10, 13, 1, 1, 1)
self.doubleSpinBox_5 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_5.setSingleStep(0.05)
self.doubleSpinBox_5.setObjectName(_fromUtf8("doubleSpinBox_5"))
self.gridLayout.addWidget(self.doubleSpinBox_5, 8, 1, 1, 1)
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(Form)
self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2"))
self.gridLayout.addWidget(self.doubleSpinBox_2, 3, 1, 1, 1)
self.checkBox_4 = QtGui.QCheckBox(Form)
self.checkBox_4.setText(_fromUtf8(""))
self.checkBox_4.setObjectName(_fromUtf8("checkBox_4"))
self.gridLayout.addWidget(self.checkBox_4, 7, 3, 1, 1)
self.checkBox_3 = QtGui.QCheckBox(Form)
self.checkBox_3.setText(_fromUtf8(""))
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.gridLayout.addWidget(self.checkBox_3, 5, 3, 1, 1)
self.checkBox_5 = QtGui.QCheckBox(Form)
self.checkBox_5.setText(_fromUtf8(""))
self.checkBox_5.setObjectName(_fromUtf8("checkBox_5"))
self.gridLayout.addWidget(self.checkBox_5, 8, 3, 1, 1)
self.checkBox_6 = QtGui.QCheckBox(Form)
self.checkBox_6.setText(_fromUtf8(""))
self.checkBox_6.setObjectName(_fromUtf8("checkBox_6"))
self.gridLayout.addWidget(self.checkBox_6, 9, 3, 1, 1)
self.checkBox_7 = QtGui.QCheckBox(Form)
self.checkBox_7.setText(_fromUtf8(""))
self.checkBox_7.setObjectName(_fromUtf8("checkBox_7"))
self.gridLayout.addWidget(self.checkBox_7, 10, 3, 1, 1)
self.checkBox_8 = QtGui.QCheckBox(Form)
self.checkBox_8.setText(_fromUtf8(""))
self.checkBox_8.setObjectName(_fromUtf8("checkBox_8"))
self.gridLayout.addWidget(self.checkBox_8, 11, 3, 1, 1)
self.checkBox_9 = QtGui.QCheckBox(Form)
self.checkBox_9.setText(_fromUtf8(""))
self.checkBox_9.setObjectName(_fromUtf8("checkBox_9"))
self.gridLayout.addWidget(self.checkBox_9, 12, 3, 1, 1)
self.checkBox_10 = QtGui.QCheckBox(Form)
self.checkBox_10.setText(_fromUtf8(""))
self.checkBox_10.setObjectName(_fromUtf8("checkBox_10"))
self.gridLayout.addWidget(self.checkBox_10, 13, 3, 1, 1)
self.label_23 = QtGui.QLabel(Form)
self.label_23.setObjectName(_fromUtf8("label_23"))
self.gridLayout.addWidget(self.label_23, 1, 3, 1, 1)
self.comboBox = QtGui.QComboBox(Form)
self.comboBox.setObjectName(_fromUtf8("comboBox"))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.gridLayout.addWidget(self.comboBox, 0, 1, 1, 2)
self.comboBox_2 = QtGui.QComboBox(Form)
self.comboBox_2.setObjectName(_fromUtf8("comboBox_2"))
self.gridLayout.addWidget(self.comboBox_2, 1, 1, 1, 1)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
Form.setWindowTitle(_translate("Form", "Form", None))
self.label_4.setText(_translate("Form", "b", None))
self.label_21.setText(_translate("Form", "TextLabel", None))
self.label_1.setText(_translate("Form", "eps", None))
self.label_16.setText(_translate("Form", "TextLabel", None))
self.label_18.setText(_translate("Form", "TextLabel", None))
self.label_5.setText(_translate("Form", "lambda", None))
self.label_11.setText(_translate("Form", "TextLabel", None))
self.label_14.setText(_translate("Form", "TextLabel", None))
self.label_17.setText(_translate("Form", "TextLabel", None))
self.label_type.setText(_translate("Form", "Type", None))
self.label_huh.setText(_translate("Form", "TextLabel", None))
self.label_19.setText(_translate("Form", "TextLabel", None))
self.label_10.setText(_translate("Form", "TextLabel", None))
self.label_2.setText(_translate("Form", "tau_a", None))
self.label_3.setText(_translate("Form", "a", None))
self.label_13.setText(_translate("Form", "TextLabel", None))
self.label_22.setText(_translate("Form", "TextLabel", None))
self.label_15.setText(_translate("Form", "TextLabel", None))
self.label_8.setText(_translate("Form", "b", None))
self.label_6.setText(_translate("Form", "tau_b", None))
self.label_20.setText(_translate("Form", "TextLabel", None))
self.label_7.setText(_translate("Form", "a", None))
self.label_23.setText(_translate("Form", "Fix", None))
self.comboBox.setItemText(0, _translate("Form", "GG", None))
self.comboBox.setItemText(1, _translate("Form", "GGe", None))
self.comboBox.setItemText(2, _translate("Form", "GG + b", None))
self.comboBox.setItemText(3, _translate("Form", "GGe + b", None))

425
YAFFparameters.ui Normal file
View File

@ -0,0 +1,425 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>270</width>
<height>396</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>1</number>
</property>
<item row="3" column="3">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="checkBox_1">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>b</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="13" column="2">
<widget class="QLabel" name="label_21">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_1"/>
</item>
<item row="7" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_4">
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_1">
<property name="text">
<string>eps</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLabel" name="label_16">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_6"/>
</item>
<item row="8" column="2">
<widget class="QLabel" name="label_18">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>lambda</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QLabel" name="label_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QLabel" name="label_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_type">
<property name="text">
<string>Type</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_3">
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_huh">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLabel" name="label_19">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="13" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>tau_a</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>a</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_9"/>
</item>
<item row="11" column="2">
<widget class="QLabel" name="label_13">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_22">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_15">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>b</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>tau_b</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_7">
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item row="10" column="2">
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>a</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_8">
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_10"/>
</item>
<item row="8" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_5">
<property name="singleStep">
<double>0.050000000000000</double>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox_2"/>
</item>
<item row="7" column="3">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="3">
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="3">
<widget class="QCheckBox" name="checkBox_7">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="11" column="3">
<widget class="QCheckBox" name="checkBox_8">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="3">
<widget class="QCheckBox" name="checkBox_9">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="13" column="3">
<widget class="QCheckBox" name="checkBox_10">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="label_23">
<property name="text">
<string>Fix</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="comboBox">
<item>
<property name="text">
<string>GG</string>
</property>
</item>
<item>
<property name="text">
<string>GGe</string>
</property>
</item>
<item>
<property name="text">
<string>GG + b</string>
</property>
</item>
<item>
<property name="text">
<string>GGe + b</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBox_2"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -2,7 +2,7 @@
# Resource object code # Resource object code
# #
# Created: Do. Mär. 20 14:46:49 2014 # Created: Do. Mär. 20 16:44:40 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!

156
libyaff.py Normal file
View File

@ -0,0 +1,156 @@
__author__ = 'markusro'
from numpy import *
import mathlib
import scipy.special
import scipy.integrate
numpat = re.compile('\d+\.\d+')
NUM_PROCESSES = 8
#define norm1(a,b) exp(gammln(b/a))/(a*pow(b/a,b/a))
#define glntau1(x,t,a,b) exp( -exp( (log(x)-log(t))*a )*b/a) * pow(x/t,b)
def filon(oms, x,y):
amps = N.zeros(len(oms), dtype='complex')
for i,om in enumerate(oms):
amps[i] = sum(diff(y)/diff(x)*(cos(om*x[1:])-cos(om*x[:-1])))/om**2
amps[i] += 1j*(y[0]/om + N.sum(diff(y)/diff(x)*(sin(om*x[1:])-sin(om*x[:-1])))/om**2)
return amps
class Yaff:
def __init__(self, dist_type=0):
self.dist_x = N.logspace(-10,4,512)
self.dist_y = N.zeros(self.dist_x.size)
self.dist_type = [self.yaff,
self.yaff_gg,
][dist_type]
def gg(self, p, tau):
tau0, a, b = p
"""
Generalized Gamma function
"""
NGG = a * (b/a)**(b/a) / scipy.special.gamma(b/a)
#g = exp(-b/a*exp( (log(tau)-log(tau0))*a))*(tau/tau0)**b
g = exp(-b/a*exp( (log(tau)-log(tau0))*a))*(tau/tau0)**b
return g*NGG
def ggb(self, p, tau):
tau0,a,b = p
norm_ggb = a*(1+b)/pi *b**(b/(1+b)) * sin(pi*b/(1+b))
g = (b*exp( (log(tau)-log(tau0)) *a) + exp( (log(tau)-log(tau0))*(-a*b)))**(-1)
return norm_ggb*g
def gg_hw(self, p ,tau):
tau0, a, b, g, s = p
"""
Generalized Gamma function with HF wing.
s gives the onset of the wing in units of tau0, i.e. 100 means 100*tau0 or two decades later
g is the slope of the wing, smaller than b; if not the slope will be b
"""
NGG = a * (b/a)**(b/a) / ( scipy.special.gamma(b/a) + s**(g-b)*(a/b)**((g-b)/a)* scipy.special.gamma(g/a) )
g = exp(-b/a*exp((log(tau) - log(tau0))*a))*(tau/tau0)**b * (1 + (tau*s/tau0)**(g-b))
return g*NGG
def dist_to_eps(omegas,dist_x,dist_y):
epp = zeros(len(omegas), dtype='complex')
for i,om in enumerate(omegas):
kern_imag = dist_y*om*dist_x/(1+(om*dist_x)**2)
kern_real = dist_y/(1+(om*dist_x)**2)
epp[i] = scipy.integrate.simps(kern_real,log(dist_x))
epp[i] += 1j*scipy.integrate.simps(kern_imag,log(dist_x))
return epp
def dist_to_relax(self, ts,dist_x,dist_y):
phi = zeros(len(ts))
for i,t in enumerate(ts):
phi[i] = phi_t(t,dist_x,dist_y)
return phi
def phi_t(self, t, dist_x, dist_y):
kern = dist_y*exp(-t/dist_x)
phi = scipy.integrate.simps(kern,log(dist_x))
return phi
def williams_watts(self, phi_1, phi_2, lambd):
return phi_1 * ( (1-lambd) + lambd*phi_2)
def yaff2(self, p, x):
"""
GGe+G b ---> GG+GB - lambda determined by p
"""
delta_eps, s_c, tau1,a1,b1, g,s, tau2, a2, b2 = p
p_ggb = tau2,a2,b2
p_gghw=tau1,a1,b1,g,s
lambd = 2*g/pi*a1*(b1/a1)**(b1/a1)
lambd /= scipy.special.gamma(b1/a1)*s**(b1-g) + (a1/b1)**((g-b1)/a1)*scipy.special.gamma(g/a1)
print "LAMBDA:",lambd,a1,b1,g,s
dist_ggb = self.ggb(p_ggb, dist_t)
phi_beta = self.dist_to_relax(ts, dist_t, dist_ggb ).real
phi_alpha = self.dist_to_relax(ts, dist_t, self.gg_hw(p_gghw, dist_t)).real
phi_tot = (1-lambd) + lambd*phi_beta
phi_tot *= phi_alpha
epp = delta_eps*2*pi*x*filon(2*pi*x, ts, phi_tot ).real
epp += s_c/(2*pi*x)
return epp
def yaff(self, p,x, cb=None):
"""
GG + GB
"""
delta_eps, tau1, a1, b1, lambd, tau2, a2, b2 = p
dist_ggb = ggb(self.dist_x,tau2,a2,b2)
dist_gg = gg(self.dist_x,tau1,a1,b1)
ts = logspace(-10,5,1024)
phi_beta = self.dist_to_relax(ts, self.dist_x, dist_ggb).real
phi_alpha = self.dist_to_relax(ts, self.dist_x, dist_gg).real
# William-Watts-Ansatz
phi_tot = (1-lambd) + lambd*phi_beta
phi_tot *= phi_alpha
epp = delta_eps*2*pi*x*filon(2*pi*x, ts, phi_tot ).real
if cb != None:
cb.next(p,x,epp)
return epp
def yaff_gg(self, p,x, cb=None):
"""
GG
"""
delta_eps, s_c, tau1,a1,b1 = p
dist_gg = gg(dist_t,tau1,a1,b1)
phi_alpha = dist_to_relax(ts, dist_t, dist_gg).real
epp = delta_eps*2*pi*x*filon(2*pi*x, ts, phi_alpha ).real
# epp = dist_to_eps(2*pi*x, dist_t, dist_gg ).real
epp += s_c/(2*pi*x)
if cb != None:
cb(p,x,epp)
return epp
def show_correlations(cov, ax):
cor = zeros(cov.shape)
for i in range(cor.shape[0]):
for j in range(cor.shape[1]):
if cov[i,i] == 0 or cov[j,j]==0:
cor[i,j] = 0
else:
cor[i,j] = cov[i,j]/sqrt(cov[i,i]*cov[j,j])
ax.matshow(abs(cor), cmap=cm.RdYlGn)
ax.colorbar()

View File

@ -131,6 +131,8 @@ def tau_peak(f, a, b):
return tau return tau
### define funcs here ### define funcs here
class Functions: class Functions:
def __init__(self): def __init__(self):