* moved math functions (fit, hn, etc.) to mathlib.py

* fitresults are stored in a better format
* started gracedriver to sva data in grace file
This commit is contained in:
Markus Rosenstihl 2014-09-17 09:46:14 +02:00
parent 784393a21a
commit 9ce80f13b5
14 changed files with 873 additions and 1226 deletions

View File

@ -2,8 +2,7 @@
__author__ = 'markusro'
from PyQt4.QtGui import QColor
from PyQt4.QtCore import QObject,pyqtSignal,QThread,pyqtSlot
from PyQt4.QtCore import QObject, pyqtSignal, QThread, pyqtSlot
import numpy as np
from scipy import optimize as opt, odr
@ -11,58 +10,56 @@ from scipy import optimize as opt, odr
import libyaff
def id_to_color(id):
def id_to_color( id ):
colors = [
QColor(54,22,115),
QColor(160,16,36),
QColor(45,142,15),
QColor(168,149,17),
QColor(36,10,85),
QColor(118,8,23),
QColor(31,105,7),
QColor(124,109,8),
QColor(54, 22, 115),
QColor(160, 16, 36),
QColor(45, 142, 15),
QColor(168, 149, 17),
QColor(36, 10, 85),
QColor(118, 8, 23),
QColor(31, 105, 7),
QColor(124, 109, 8),
]
return colors[id % len(colors)]
return colors[id%len(colors)]
class FitFunctionCreator(QObject):
new_data = pyqtSignal(np.ndarray, np.ndarray)
def __init__(self):
super(FitFunctionCreator,self).__init__()
def __init__( self ):
super(FitFunctionCreator, self).__init__()
self.data = None
self.functions = Functions()
def fitfcn(self, p0, x, *funcs):
def fitfcn( self, p0, x, *funcs ):
if x.ndim == 2:
self.data = np.zeros( x.shape )
self.data = np.zeros(x.shape)
else:
self.data = np.zeros( (2,x.size) )
self.data = np.zeros((2, x.size))
ndx = 0
for fn in funcs: # loop over functions and add the results
f, num_p = fn.function, fn.param_number
p = p0[ndx:ndx + num_p]
p = p0[ndx:ndx+num_p]
if x.ndim == 2:
x = x[0]
result = f(p, x)
#fn.widget.updateTable(p)
# fn.widget.updateTable(p)
self.data += result # fit functions take only 1-dim x
ndx += num_p
self.new_data.emit(x, self.data)
return self.data
def fitfcn_imag(self, p0, x, *funcs):
def fitfcn_imag( self, p0, x, *funcs ):
if x.ndim == 2:
self.data = np.zeros( x.shape )
self.data = np.zeros(x.shape)
else:
self.data = np.zeros( (2,x.size) )
self.data = np.zeros((2, x.size))
ndx = 0
for fn in funcs: # loop over functions and add the results
f, num_p = fn.function, fn.param_number
p = p0[ndx:ndx + num_p]
p = p0[ndx:ndx+num_p]
if x.ndim == 2:
x = x[0]
result = f(p, x)
@ -76,34 +73,36 @@ class FitRoutine(QObject):
finished_fit = pyqtSignal()
data_ready = pyqtSignal(np.ndarray, np.ndarray)
def __init__(self):
super(FitRoutine,self).__init__()
def __init__( self ):
super(FitRoutine, self).__init__()
self.f = FitFunctionCreator()
self.f.new_data.connect(self.data_ready.emit)
self._fitter = self.fit_odr_cmplx
self._odr_fit = None
self._start_parameter = None
@property
def start_parameter(self):
def start_parameter( self ):
return self._start_parameter
@start_parameter.setter
def start_paramter(self, p0):
def start_paramter( self, p0 ):
self._start_parameter = p0
@property
def fitter(self):
def fitter( self ):
return self._fitter
@fitter.setter
def fitter(self, f):
def fitter( self, f ):
self._fitter = f
def fit_odr_cmplx(self, x, y, p0, fixed, fcns):
def fit_odr_cmplx( self, x, y, p0, fixed, fcns ):
self._start_parameter = p0
if np.iscomplexobj(y) and y.ndim == 1:
weights = 1/np.abs(y)**2
we = np.resize(weights, (2, weights.size))
#we = 1/N.array([y.real**2, y.imag**2])
# we = 1/N.array([y.real**2, y.imag**2])
y = np.array([y.real, y.imag])
else:
raise NotImplementedError, "need complex input for now"
@ -111,7 +110,7 @@ class FitRoutine(QObject):
mod = odr.Model(self.f.fitfcn, extra_args=fcns)
self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800)
def fit_odr_imag(self, x, y, p0, fixed, fcns):
def fit_odr_imag( self, x, y, p0, fixed, fcns ):
self._start_parameter = p0
if np.iscomplexobj(y) and y.ndim == 1:
we = 1/np.imag(y)**2
@ -122,49 +121,47 @@ class FitRoutine(QObject):
self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800)
@pyqtSlot()
def fit(self):
#print "TID in FitRoutine", QThread.thread()
def fit( self ):
try:
self._odr_fit.run()
except RuntimeError:
print "muh"
self.finished_fit.emit()
def result(self):
def result( self ):
if self._odr_fit.output is None:
self._odr_fit.output = odr.Output([self.start_parameter, None, None ])
self._odr_fit.output = odr.Output([self.start_parameter, None, None])
self._odr_fit.output.stopreason = ["Aborted by user"]
return self._odr_fit.output
class FunctionRegister:
def __init__(self):
self.registry = {}
def __init__( self ):
self.registry = { }
def register_function(self, obj):
#print "FR: Registering:",obj
def register_function( self, obj ):
# print "FR: Registering:",obj
id_string = obj.id_label
if self.registry.has_key(obj):
raise AssertionError,"The object is already registered! This should NOT happen"
self.registry[obj]=id_string
raise AssertionError, "The object is already registered! This should NOT happen"
self.registry[obj] = id_string
#print "FR: ",self.registry
def unregister_function(self, obj):
#print "FR: UnRegistering:",obj
def unregister_function( self, obj ):
# print "FR: UnRegistering:",obj
if self.registry.has_key(obj):
self.registry.pop(obj)
else:
obj.deleteLater()
raise AssertionError,"The object is not in the registry! This should NOT happen"
raise AssertionError, "The object is not in the registry! This should NOT happen"
#print "FR: ",self.registry
def get_registered_functions(self):
def get_registered_functions( self ):
return self.registry
############## deprecated #####################
def fit_odr_cmplx(x, y, p0, fixed, fcns):
# ############# deprecated #####################
def fit_odr_cmplx( x, y, p0, fixed, fcns ):
f = FitFunctionCreator()
#if x.ndim < 2:
# x = N.resize(x, (2,x.size))
@ -182,65 +179,66 @@ def fit_odr_cmplx(x, y, p0, fixed, fcns):
#print fit.output.pprint()
return fit.output
### define funcs here
class Functions(QObject):
def __init__(self):
super(Functions,self).__init__()
def __init__( self ):
super(Functions, self).__init__()
self.list = {
# provides functions: "id_string":(function, number_of_parameters)
"hn":(self.hn_cmplx, 4),
"conductivity":(self.cond_cmplx, 3),
"power":(self.power_cmplx, 2),
"static":(self.static_cmplx, 1),
"yaff":(self.yaff, 8)
"hn": (self.hn_cmplx, 4),
"conductivity": (self.cond_cmplx, 3),
"power": (self.power_cmplx, 2),
"static": (self.static_cmplx, 1),
"yaff": (self.yaff, 8)
}
self.YAFF = libyaff.Yaff()
def hn_cmplx(self, p, x):
def hn_cmplx( self, p, x ):
om = 2*np.pi*x
#hn = om*1j
eps,t,a,b = p
eps, t, a, b = p
hn = eps/(1+(1j*om*t)**a)**b
cplx = np.array([hn.real, -hn.imag])
return cplx
def cond_cmplx(self, p, x):
def cond_cmplx( self, p, x ):
om = 2*np.pi*x
sgma, isgma, n = p
cond = sgma/(om**n) + isgma/(1j*om**n) # Jonscher (Universal Dielectric Response: e",e' prop sigma/omega**n
cond = sgma/(om**n)+isgma/(1j*om**n) # Jonscher (Universal Dielectric Response: e",e' prop sigma/omega**n
cplx = np.array([cond.real, -cond.imag])
return cplx
def power_cmplx(self, p, x):
def power_cmplx( self, p, x ):
om = 2*np.pi*x
sgma,n = p
sgma, n = p
power = sgma/(om*1j)**n
cplx = np.array([power.real, -power.imag])
return cplx
def static_cmplx(self, p, x):
def static_cmplx( self, p, x ):
eps_inf = p[0]
static = np.ones( (2,x.size) )*eps_inf
static[1,:] *= 0 # set imag part zero
static = np.ones((2, x.size))*eps_inf
static[1, :] *= 0 # set imag part zero
#cplx = N.array([static.real, static.imag])
return static
def yaff(self,p,x):
ya = self.YAFF.yaff(p[:8],x)
def yaff( self, p, x ):
ya = self.YAFF.yaff(p[:8], x)
cplx = np.array([ya.imag, ya.real])
return cplx
def get(self,name):
def get( self, name ):
return self.list[name]
def get_function(self,name):
def get_function( self, name ):
return self.list[name][0]
def fit_anneal(x, y, p0, fixed, funcs):
def fit_anneal( x, y, p0, fixed, funcs ):
raise NotImplementedError
bounds = [(0, 1e14), (0, 1)]
for i in xrange(len(p0[2:]) / 4):
for i in xrange(len(p0[2:])/4):
bounds.append((1e-4, 1e12)) # delta_eps
bounds.append((1e-12, 1e3)) # tau
bounds.append((0.1, 1)) # a
@ -268,11 +266,11 @@ def fit_anneal(x, y, p0, fixed, funcs):
return ret[0]
def fit_lbfgsb(x, y, p0, fixed, funcs):
def fit_lbfgsb( x, y, p0, fixed, funcs ):
raise NotImplementedError
# TODO fixed parameters…
bounds = [(0, None), (0, 1)]
for i in xrange(len(p0[3:]) / 4):
for i in xrange(len(p0[3:])/4):
bounds.append((1e-4, 1e12)) # delta_eps
bounds.append((1e-12, 1e3)) # tau
bounds.append((0.1, 1)) # a
@ -300,48 +298,47 @@ def fit_lbfgsb(x, y, p0, fixed, funcs):
# return fit.output.beta
def hn(p, nu):
def hn( p, nu ):
delta_eps, tau, a, b = p
om = 2 * np.pi * nu
Phi = np.arctan((om * tau) ** a * np.sin(np.pi * a / 2.) / (1. + (om * tau) ** a * np.cos(np.pi * a / 2.)))
e_loss = delta_eps * (1 + 2 * (om * tau) ** a * np.cos(np.pi * a / 2.) + (om * tau) ** (2. * a) ) ** (
-b / 2.) * np.sin(b * Phi)
e_stor = delta_eps * (1 + 2 * (om * tau) ** a * np.cos(np.pi * a / 2.) + (om * tau) ** (2. * a) ) ** (
-b / 2.) * np.cos(b * Phi)
om = 2*np.pi*nu
Phi = np.arctan((om*tau)**a*np.sin(np.pi*a/2.)/(1.+(om*tau)**a*np.cos(np.pi*a/2.)))
e_loss = delta_eps*(1+2*(om*tau)**a*np.cos(np.pi*a/2.)+(om*tau)**(2.*a) )**(
-b/2.)*np.sin(b*Phi)
e_stor = delta_eps*(1+2*(om*tau)**a*np.cos(np.pi*a/2.)+(om*tau)**(2.*a) )**(
-b/2.)*np.cos(b*Phi)
return e_loss # 2* oder nicht?
def mini_func(p, x, y):
res = y - multi_hn(p, x)
def mini_func( p, x, y ):
res = y-multi_hn(p, x)
# apply weights
res /= 1 / y
res /= 1/y
return np.sqrt(np.dot(res, res))
def multi_hn(p, nu):
def multi_hn( p, nu ):
conductivity = p[1]
cond_beta = p[2]
om = 2 * np.pi * nu
e_loss = conductivity / om ** cond_beta
om = 2*np.pi*nu
e_loss = conductivity/om**cond_beta
e_loss += p[0]
#for key, igroup in groupby(p[3:], lambda x: x//4):
for i in xrange(len(p[3:]) / 4):
delta_eps, tau, a, b = p[3 + i * 4:3 + (i + 1) * 4]
for i in xrange(len(p[3:])/4):
delta_eps, tau, a, b = p[3+i*4:3+(i+1)*4]
#delta_eps, tau, a, b = list(igroup)
#print delta_eps,tau,a,b
#a = 0.5 *(1 + N.tanh(a))
#b = 0.5 *(1 + N.tanh(b))
Phi = np.arctan((om * tau) ** a * np.sin(np.pi * a / 2.) / (1. + (om * tau) ** a * np.cos(np.pi * a / 2.)))
e_loss += 2 * delta_eps * (1 + 2 * (om * tau) ** a * np.cos(np.pi * a / 2.) + (om * tau) ** (2. * a) ) ** (
-b / 2.) * np.sin(b * Phi)
Phi = np.arctan((om*tau)**a*np.sin(np.pi*a/2.)/(1.+(om*tau)**a*np.cos(np.pi*a/2.)))
e_loss += 2*delta_eps*(1+2*(om*tau)**a*np.cos(np.pi*a/2.)+(om*tau)**(2.*a) )**(
-b/2.)*np.sin(b*Phi)
#e_stor = delta_eps * (1+ 2*(om*tau)**a * N.cos(N.pi*a/2.) + (om*tau)**(2.*a) )**(-b/2.)*N.cos(b*Phi)
return e_loss
def tau_peak(f, a, b):
tau = (np.sin(np.pi * a / 2. / (b + 1)) / np.sin(np.pi * a * b / 2. / (b + 1))) ** (1 / a)
tau /= 2 * np.pi * f
def tau_peak( f, a, b ):
tau = (np.sin(np.pi*a/2./(b+1))/np.sin(np.pi*a*b/2./(b+1)))**(1/a)
tau /= 2*np.pi*f
return tau

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'ConductivityGroupBox.ui'
#
# Created: Mon Jun 2 19:55:32 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:48 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_ConductivityGroupBox(object):
def setupUi(self, ConductivityGroupBox):
def setupUi( self, ConductivityGroupBox ):
ConductivityGroupBox.setObjectName(_fromUtf8("ConductivityGroupBox"))
ConductivityGroupBox.resize(253, 156)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@ -61,7 +63,7 @@ class Ui_ConductivityGroupBox(object):
self.checkBox_3.setText(_fromUtf8(""))
self.checkBox_3.setChecked(True)
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.gridLayout.addWidget(self.checkBox_3, 3, 3, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.checkBox_3, 3, 3, 1, 1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.label_2 = QtGui.QLabel(ConductivityGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@ -135,18 +137,25 @@ class Ui_ConductivityGroupBox(object):
QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), ConductivityGroupBox.hide)
QtCore.QMetaObject.connectSlotsByName(ConductivityGroupBox)
def retranslateUi(self, ConductivityGroupBox):
def retranslateUi( self, ConductivityGroupBox ):
ConductivityGroupBox.setWindowTitle(_translate("ConductivityGroupBox", "GroupBox", None))
ConductivityGroupBox.setTitle(_translate("ConductivityGroupBox", "Conductivity", None))
self.pwrSigma_sd.setText(_translate("ConductivityGroupBox", "TextLabel", None))
self.label_2.setText(_translate("ConductivityGroupBox", "<html><head/><body><p>σ\'<span style=\" vertical-align:sub;\">(DC)</span></p></body></html>", None))
self.label_2.setText(_translate("ConductivityGroupBox",
"<html><head/><body><p>σ\'<span style=\" vertical-align:sub;\">(DC)</span></p></body></html>",
None))
self.label.setText(_translate("ConductivityGroupBox", "Fix", None))
self.removeButton.setText(_translate("ConductivityGroupBox", "Remove", None))
self.label_4.setText(_translate("ConductivityGroupBox", "α", None))
self.rSigma_sd.setText(_translate("ConductivityGroupBox", "TextLabel", None))
self.rSigma.setToolTip(_translate("ConductivityGroupBox", "<html><head/><body><p>DC conductivity, should only be seen in the imaginary permitivity. If there is a Jonscher type of U<span style=\" font-style:italic;\">niversal Dielectric Response, </span>the ratio of σ&quot;/σ\'<span style=\" vertical-align:sub;\">(DC)</span> is a constant</p></body></html>", None))
self.rSigma.setToolTip(_translate("ConductivityGroupBox",
"<html><head/><body><p>DC conductivity, should only be seen in the imaginary permitivity. If there is a Jonscher type of U<span style=\" font-style:italic;\">niversal Dielectric Response, </span>the ratio of σ&quot;/σ\'<span style=\" vertical-align:sub;\">(DC)</span> is a constant</p></body></html>",
None))
self.subtractConductivityButton.setText(_translate("ConductivityGroupBox", "Hide", None))
self.label_3.setText(_translate("ConductivityGroupBox", "<html><head/><body><p>σ&quot;</p></body></html>", None))
self.iSigma.setToolTip(_translate("ConductivityGroupBox", "<html><head/><body><p>If there is a Jonscher type of U<span style=\" font-style:italic;\">niversal Dielectric Response, </span>the ratio of σ&quot;/σ\'<span style=\" vertical-align:sub;\">(DC)</span> is a constant</p></body></html>", None))
self.label_3.setText(
_translate("ConductivityGroupBox", "<html><head/><body><p>σ&quot;</p></body></html>", None))
self.iSigma.setToolTip(_translate("ConductivityGroupBox",
"<html><head/><body><p>If there is a Jonscher type of U<span style=\" font-style:italic;\">niversal Dielectric Response, </span>the ratio of σ&quot;/σ\'<span style=\" vertical-align:sub;\">(DC)</span> is a constant</p></body></html>",
None))
self.iSigma_sd.setText(_translate("ConductivityGroupBox", "TextLabel", None))

View File

@ -6,7 +6,7 @@ import numpy as np
import pyqtgraph as pg
import ContainerWidgets
import libyaff
from Mathlib import Functions, id_to_color
from BDSMathlib import Functions, id_to_color
__author__ = 'markusro'

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'PeakGroupBox.ui'
#
# Created: Mon Jun 2 19:55:32 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:47 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_PeakGroupBox(object):
def setupUi(self, PeakGroupBox):
def setupUi( self, PeakGroupBox ):
PeakGroupBox.setObjectName(_fromUtf8("PeakGroupBox"))
PeakGroupBox.setEnabled(True)
PeakGroupBox.resize(269, 179)
@ -71,7 +73,7 @@ class Ui_PeakGroupBox(object):
self.removeButton.setSizePolicy(sizePolicy)
self.removeButton.setMinimumSize(QtCore.QSize(0, 0))
self.removeButton.setObjectName(_fromUtf8("removeButton"))
self.gridLayout.addWidget(self.removeButton, 0, 1, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.removeButton, 0, 1, 1, 1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.label_1 = QtGui.QLabel(PeakGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
@ -153,14 +155,14 @@ class Ui_PeakGroupBox(object):
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.comboBox.addItem(_fromUtf8(""))
self.gridLayout.addWidget(self.comboBox, 0, 2, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.comboBox, 0, 2, 1, 1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.retranslateUi(PeakGroupBox)
QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), PeakGroupBox.hide)
QtCore.QMetaObject.connectSlotsByName(PeakGroupBox)
def retranslateUi(self, PeakGroupBox):
def retranslateUi( self, PeakGroupBox ):
PeakGroupBox.setWindowTitle(_translate("PeakGroupBox", "GroupBox", None))
PeakGroupBox.setTitle(_translate("PeakGroupBox", "GroupBox", None))
self.label.setText(_translate("PeakGroupBox", "Fix", None))
@ -169,9 +171,13 @@ class Ui_PeakGroupBox(object):
self.label_6.setText(_translate("PeakGroupBox", "TextLabel", None))
self.removeButton.setText(_translate("PeakGroupBox", "Remove", None))
self.label_1.setText(_translate("PeakGroupBox", "Δε", None))
self.label_3.setText(_translate("PeakGroupBox", "<html><head/><body><p>γ<span style=\" vertical-align:sub;\">CC</span></p></body></html>", None))
self.label_3.setText(_translate("PeakGroupBox",
"<html><head/><body><p>γ<span style=\" vertical-align:sub;\">CC</span></p></body></html>",
None))
self.label_8.setText(_translate("PeakGroupBox", "TextLabel", None))
self.label_4.setText(_translate("PeakGroupBox", "<html><head/><body><p>β<span style=\" vertical-align:sub;\">CD</span></p></body></html>", None))
self.label_4.setText(_translate("PeakGroupBox",
"<html><head/><body><p>β<span style=\" vertical-align:sub;\">CD</span></p></body></html>",
None))
self.label_2.setText(_translate("PeakGroupBox", "τ", None))
self.comboBox.setItemText(0, _translate("PeakGroupBox", "H-N", None))
self.comboBox.setItemText(1, _translate("PeakGroupBox", "C-C", None))

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'PowerLawGroupBox.ui'
#
# Created: Mon Jun 2 19:55:33 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:48 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_PowerLawGroupBox(object):
def setupUi(self, PowerLawGroupBox):
def setupUi( self, PowerLawGroupBox ):
PowerLawGroupBox.setObjectName(_fromUtf8("PowerLawGroupBox"))
PowerLawGroupBox.resize(206, 129)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@ -61,7 +63,7 @@ class Ui_PowerLawGroupBox(object):
self.checkBox_3.setText(_fromUtf8(""))
self.checkBox_3.setChecked(True)
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3"))
self.gridLayout.addWidget(self.checkBox_3, 2, 3, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.checkBox_3, 2, 3, 1, 1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.label_6 = QtGui.QLabel(PowerLawGroupBox)
self.label_6.setObjectName(_fromUtf8("label_6"))
self.gridLayout.addWidget(self.label_6, 2, 2, 1, 1)
@ -119,7 +121,7 @@ class Ui_PowerLawGroupBox(object):
QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), PowerLawGroupBox.hide)
QtCore.QMetaObject.connectSlotsByName(PowerLawGroupBox)
def retranslateUi(self, PowerLawGroupBox):
def retranslateUi( self, PowerLawGroupBox ):
PowerLawGroupBox.setWindowTitle(_translate("PowerLawGroupBox", "GroupBox", None))
PowerLawGroupBox.setTitle(_translate("PowerLawGroupBox", "Power Law", None))
self.label.setText(_translate("PowerLawGroupBox", "Fix", None))

61
QDS.py
View File

@ -19,20 +19,18 @@ import pyqtgraph as pg
from Container import Conductivity, PowerComplex, Static, Peak, YAFF
from ContainerWidgets import ParameterWidget
from Mathlib import FunctionRegister, FitRoutine
from BDSMathlib import FunctionRegister, FitRoutine
from Data import Data
import QDSMain
import ExtraDifferentialWidget
class AppWindow(QMainWindow):
def __init__(self, files=[], parent=None):
super(AppWindow, self).__init__(parent)
self.ui = QDSMain.Ui_MainWindow()
self.ui.setupUi(self)
self._file_paths = QStringList(files)
self._file_paths = self._sortInputFiles(files)
self._last_written_header = None
actions = {
@ -69,8 +67,8 @@ class AppWindow(QMainWindow):
self.ui.pgPlotWidget_imag.addItem(self.fit_boundary_imag)
self.ui.pgPlotWidget_real.addItem(self.fit_boundary_real)
self.fit_boundary_imag.sigRegionChanged.connect(self._update_fit_boundary_real)
self.fit_boundary_real.sigRegionChanged.connect(self._update_fit_boundary_imag)
self.fit_boundary_imag.sigRegionChanged.connect(self._update_fit_boundary)
self.fit_boundary_real.sigRegionChanged.connect(self._update_fit_boundary)
for pltwidgt in (self.ui.pgPlotWidget_real, self.ui.pgPlotWidget_imag):
pltwidgt.setLogMode(x=True, y=True)
@ -89,10 +87,6 @@ class AppWindow(QMainWindow):
sc_imag.sigMouseClicked.connect(self.mousePress)
sc_imag.sigMouseMoved.connect(self.updateCrosshair)
# process cmd line args
if files != []:
self.openFile(files[0])
self._current_file_index = 0
self._fit_thread = QThread()
self._fit_method = FitRoutine()
@ -101,6 +95,12 @@ class AppWindow(QMainWindow):
self._fit_method.data_ready.connect(self.updateIntermediatePlot)
self._fit_thread.started.connect(self._fit_method.fit)
# finally process cmd line args
if files != []:
self.openFile(unicode(self._file_paths[0]))
self._current_file_index = 0
def _init_menu(self):
fileMenu = self.menuBar().addMenu("File")
@ -242,14 +242,17 @@ class AppWindow(QMainWindow):
# prepare header
header="# T "
header = "{n1:13}{n2:13}".format(n1="# 0T", n2="1invT")
pars = []
bname = os.path.splitext(self.filepath)[0]
# print "Registered Functions (saveFitResult): ",self.function_registry.get_registered_functions()
varnum = 2 # T, invT are the first two columns
for i_fcn, fcn in enumerate(self.function_registry.get_registered_functions()):
for name in fcn.widget.names: # get variable names
header += "{n:11}{n_sd:11}".format(n=name, n_sd=name+"_sd")
for i, name in enumerate(fcn.widget.names): # get variable names
header += "{n:13}{n_sd:13}".format(n="%i%s"%(varnum, name), n_sd="%i%s_sd"%(varnum+1, name))
varnum += 2
# write for each function extra file
name_fcn = "%s_%i.fit"%(bname,i_fcn)
name_fcn = "%s_%i.fit"%(bname, i_fcn)
f_fcn = open(name_fcn, 'w')
f_fcn.write("# %s\n"%(fcn.id_string))
f_fcn.flush()
@ -264,7 +267,8 @@ class AppWindow(QMainWindow):
pars.extend([par])
pars.extend([fcn._sd_beta[i]])
header += "%-11s%-11s\n"%("fit_xlow","fit_xhigh")
# append fit limits header
header += "%-13s%-13s\n"%("fit_xlow", "fit_xhigh")
# write new header if fit model changed
if self._last_written_header != header:
@ -275,10 +279,11 @@ class AppWindow(QMainWindow):
pass
pars.insert(0, self.data.meta["T"])
pars.insert(1, 1e3/self.data.meta["T"])
pars.append(self.data.fit_limits[0])
pars.append(self.data.fit_limits[1])
pars = np.array([pars])
np.savetxt(f, pars, fmt = '%-10.3e', delimiter=" ")
np.savetxt(f, pars, fmt='%-12.3e', delimiter=" ")
f.close()
def _saveFitFigure(self):
@ -308,7 +313,7 @@ class AppWindow(QMainWindow):
#pyplot.savefig(os.path.splitext(self.filepath)[0]+".png")
pyplot.savefig(os.path.splitext(self.filepath)[0]+".pdf")
fig.clear()
fig.close()
del (fig)
def _saveFitFigureGrace(self):
#agrtemplate = open('template.agr').read()
@ -316,6 +321,8 @@ class AppWindow(QMainWindow):
"""
#TODO: need interface/method for adding function blocks, this is too repetitive
def addYaff(self, pos):
_yaff = YAFF(plt_real=self.ui.pgPlotWidget_real,
plt_imag=self.ui.pgPlotWidget_imag,
@ -343,7 +350,7 @@ class AppWindow(QMainWindow):
cond_par = [0.0, 10**(pos.y() + pos.x())*2*np.pi , 1.0]
_conductivity.setParameter(beta=cond_par)
self.parameterWidget.add(_conductivity.widget)
self.function_registry.register_function(_conductivity) ##todo
self.function_registry.register_function(_conductivity)
self.updatePlot()
_conductivity.blockSignals(False)
@ -479,6 +486,10 @@ class AppWindow(QMainWindow):
self.openFile(path)
self.fit_boundary_imag.setRegion(lim)
def _sortInputFiles( self, files ):
return QStringList(sorted(files, key=lambda x: re.findall("\d+\.\d+K", x)))
def openFile(self,path):
print "opening: %s"%path
self.filepath=path
@ -534,7 +545,6 @@ class AppWindow(QMainWindow):
p0,funcs = [],[]
for fcn in self.function_registry.get_registered_functions():
print fcn
p0.extend(fcn.getParameter())
funcs.append(fcn)
# calculate parametrized curve
@ -543,26 +553,25 @@ class AppWindow(QMainWindow):
# replot data and fit, TODO: replot only if measurement data changed
self.data.data_curve_real.setData(self.data.frequency, self.data.epsilon.real)
self.data.data_curve_imag.setData(self.data.frequency, self.data.epsilon.imag)
print "updatePlot: ",self.data.frequency_fit, self.data.epsilon_fit
#print "updatePlot: ",self.data.frequency_fit, self.data.epsilon_fit
if len(funcs) > 0:
print "funcs > 0:",self.data.frequency_fit, self.data.epsilon_fit
#print "funcs > 0:",self.data.frequency_fit, self.data.epsilon_fit
self.data.fitted_curve_real.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.real)
self.data.fitted_curve_imag.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.imag)
else:
self.data.fitted_curve_real.setData(x=np.array([np.nan]),y=np.array([np.nan]))
self.data.fitted_curve_imag.setData(x=np.array([np.nan]),y=np.array([np.nan]))
self.data.fitted_curve_real.setData(x=np.array([np.nan]), y=np.array([np.nan]))
self.data.fitted_curve_imag.setData(x=np.array([np.nan]), y=np.array([np.nan]))
def updateIntermediatePlot(self, freq, intermediate_data):
self.data.fitted_curve_real.setData(freq, intermediate_data[0])
self.data.fitted_curve_imag.setData(freq, intermediate_data[1])
def _update_fit_boundary_real(self):
def _update_fit_boundary( self ):
self.fit_boundary_real.setRegion(self.fit_boundary_imag.getRegion())
def _update_fit_boundary_imag(self):
self.fit_boundary_imag.setRegion(self.fit_boundary_real.getRegion())
def sigint_handler(*args):
"""
Handler for the SIGINT signal (CTRL + C).

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'QDSMain.ui'
#
# Created: Mon Jun 2 19:55:32 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:47 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
def setupUi( self, MainWindow ):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(956, 699)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
@ -77,7 +79,7 @@ class Ui_MainWindow(object):
self.toolBar.setObjectName(_fromUtf8("toolBar"))
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
self.dockWidget_3 = QtGui.QDockWidget(MainWindow)
self.dockWidget_3.setFeatures(QtGui.QDockWidget.DockWidgetFloatable|QtGui.QDockWidget.DockWidgetMovable)
self.dockWidget_3.setFeatures(QtGui.QDockWidget.DockWidgetFloatable | QtGui.QDockWidget.DockWidgetMovable)
self.dockWidget_3.setObjectName(_fromUtf8("dockWidget_3"))
self.dockWidgetContents_4 = QtGui.QWidget()
self.dockWidgetContents_4.setObjectName(_fromUtf8("dockWidgetContents_4"))
@ -138,7 +140,7 @@ class Ui_MainWindow(object):
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
def retranslateUi( self, MainWindow ):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.menuExtras.setTitle(_translate("MainWindow", "Extras", None))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
@ -157,5 +159,6 @@ class Ui_MainWindow(object):
self.actionActionAbortFit.setShortcut(_translate("MainWindow", "Ctrl+C", None))
self.actionShow_Derivative.setText(_translate("MainWindow", "Show Derivative", None))
from pyqtgraph import PlotWidget
import images_rc

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'StaticGroupBox.ui'
#
# Created: Mon Jun 2 19:55:33 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:48 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_StaticGroupBox(object):
def setupUi(self, StaticGroupBox):
def setupUi( self, StaticGroupBox ):
StaticGroupBox.setObjectName(_fromUtf8("StaticGroupBox"))
StaticGroupBox.resize(218, 102)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
@ -83,18 +85,20 @@ class Ui_StaticGroupBox(object):
self.checkBox_1.setText(_fromUtf8(""))
self.checkBox_1.setChecked(True)
self.checkBox_1.setObjectName(_fromUtf8("checkBox_1"))
self.gridLayout.addWidget(self.checkBox_1, 1, 3, 1, 1, QtCore.Qt.AlignHCenter|QtCore.Qt.AlignVCenter)
self.gridLayout.addWidget(self.checkBox_1, 1, 3, 1, 1, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.retranslateUi(StaticGroupBox)
QtCore.QObject.connect(self.removeButton, QtCore.SIGNAL(_fromUtf8("clicked()")), StaticGroupBox.hide)
QtCore.QMetaObject.connectSlotsByName(StaticGroupBox)
def retranslateUi(self, StaticGroupBox):
def retranslateUi( self, StaticGroupBox ):
StaticGroupBox.setWindowTitle(_translate("StaticGroupBox", "GroupBox", None))
StaticGroupBox.setTitle(_translate("StaticGroupBox", "e\'_infty", None))
self.label.setText(_translate("StaticGroupBox", "Fix", None))
self.removeButton.setText(_translate("StaticGroupBox", "Remove", None))
self.label_4.setText(_translate("StaticGroupBox", "TextLabel", None))
self.label_1.setText(_translate("StaticGroupBox", "<html><head/><body><p>ε<span style=\" vertical-align:sub;\">infty</span></p></body></html>", None))
self.label_1.setText(_translate("StaticGroupBox",
"<html><head/><body><p>ε<span style=\" vertical-align:sub;\">infty</span></p></body></html>",
None))

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'YAFFConfig.ui'
#
# Created: Mon Jun 2 19:55:33 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:48 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog(object):
def setupUi(self, Dialog):
def setupUi( self, Dialog ):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(250, 229)
self.gridLayout_3 = QtGui.QGridLayout(Dialog)
@ -85,7 +87,7 @@ class Ui_Dialog(object):
self.gridLayout_3.addWidget(self.groupBox_tau, 1, 0, 1, 1)
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel | QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.gridLayout_3.addWidget(self.buttonBox, 2, 0, 1, 1)
@ -94,14 +96,22 @@ class Ui_Dialog(object):
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
def retranslateUi( self, Dialog ):
Dialog.setWindowTitle(_translate("Dialog", "YAFF Configuration", None))
self.groupBox_time.setTitle(_translate("Dialog", "Time values (log10[t])", None))
self.label.setText(_translate("Dialog", "<html><head/><body><p>t<span style=\" vertical-align:sub;\">min</span></p></body></html>", None))
self.label_2.setText(_translate("Dialog", "<html><head/><body><p>t<span style=\" vertical-align:sub;\">max</span></p></body></html>", None))
self.label.setText(_translate("Dialog",
"<html><head/><body><p>t<span style=\" vertical-align:sub;\">min</span></p></body></html>",
None))
self.label_2.setText(_translate("Dialog",
"<html><head/><body><p>t<span style=\" vertical-align:sub;\">max</span></p></body></html>",
None))
self.label_3.setText(_translate("Dialog", "N", None))
self.groupBox_tau.setTitle(_translate("Dialog", "τ-Distribution (log10[τ])", None))
self.label_7.setText(_translate("Dialog", "<html><head/><body><p>t<span style=\" vertical-align:sub;\">min</span></p></body></html>", None))
self.label_8.setText(_translate("Dialog", "<html><head/><body><p>t<span style=\" vertical-align:sub;\">max</span></p></body></html>", None))
self.label_7.setText(_translate("Dialog",
"<html><head/><body><p>t<span style=\" vertical-align:sub;\">min</span></p></body></html>",
None))
self.label_8.setText(_translate("Dialog",
"<html><head/><body><p>t<span style=\" vertical-align:sub;\">max</span></p></body></html>",
None))
self.label_9.setText(_translate("Dialog", "N", None))

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'YAFFparameters.ui'
#
# Created: Mon Jun 2 19:55:33 2014
# by: PyQt4 UI code generator 4.10.4
# Created: Tue Jul 29 08:56:48 2014
# by: PyQt4 UI code generator 4.11.1
#
# WARNING! All changes made in this file will be lost!
@ -12,19 +12,21 @@ from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
def _fromUtf8( s ):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
def _translate( context, text, disambig ):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Form(object):
def setupUi(self, Form):
def setupUi( self, Form ):
Form.setObjectName(_fromUtf8("Form"))
Form.resize(300, 322)
self.gridLayout = QtGui.QGridLayout(Form)
@ -40,7 +42,7 @@ class Ui_Form(object):
self.checkBox_1.setObjectName(_fromUtf8("checkBox_1"))
self.gridLayout.addWidget(self.checkBox_1, 2, 3, 1, 1)
self.label_422 = QtGui.QLabel(Form)
self.label_422.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_422.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_422.setObjectName(_fromUtf8("label_422"))
self.gridLayout.addWidget(self.label_422, 7, 0, 1, 1)
self.label_10 = QtGui.QLabel(Form)
@ -60,7 +62,7 @@ class Ui_Form(object):
self.doubleSpinBox_4.setObjectName(_fromUtf8("doubleSpinBox_4"))
self.gridLayout.addWidget(self.doubleSpinBox_4, 7, 1, 1, 1)
self.label_111 = QtGui.QLabel(Form)
self.label_111.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_111.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_111.setObjectName(_fromUtf8("label_111"))
self.gridLayout.addWidget(self.label_111, 2, 0, 1, 1)
self.label_4 = QtGui.QLabel(Form)
@ -83,11 +85,11 @@ class Ui_Form(object):
self.label_5.setObjectName(_fromUtf8("label_5"))
self.gridLayout.addWidget(self.label_5, 8, 2, 1, 1)
self.label_522 = QtGui.QLabel(Form)
self.label_522.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_522.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_522.setObjectName(_fromUtf8("label_522"))
self.gridLayout.addWidget(self.label_522, 8, 0, 1, 1)
self.label_112 = QtGui.QLabel(Form)
self.label_112.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_112.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_112.setObjectName(_fromUtf8("label_112"))
self.gridLayout.addWidget(self.label_112, 12, 0, 1, 1)
self.label_9 = QtGui.QLabel(Form)
@ -107,7 +109,7 @@ class Ui_Form(object):
self.label_6.setObjectName(_fromUtf8("label_6"))
self.gridLayout.addWidget(self.label_6, 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.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)
@ -127,15 +129,15 @@ class Ui_Form(object):
self.label_2.setObjectName(_fromUtf8("label_2"))
self.gridLayout.addWidget(self.label_2, 3, 2, 1, 1)
self.label_102 = QtGui.QLabel(Form)
self.label_102.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_102.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_102.setObjectName(_fromUtf8("label_102"))
self.gridLayout.addWidget(self.label_102, 13, 0, 1, 1)
self.label_222 = QtGui.QLabel(Form)
self.label_222.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_222.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_222.setObjectName(_fromUtf8("label_222"))
self.gridLayout.addWidget(self.label_222, 3, 0, 1, 1)
self.label_322 = QtGui.QLabel(Form)
self.label_322.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_322.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_322.setObjectName(_fromUtf8("label_322"))
self.gridLayout.addWidget(self.label_322, 5, 0, 1, 1)
self.doubleSpinBox_9 = QtGui.QDoubleSpinBox(Form)
@ -168,11 +170,11 @@ class Ui_Form(object):
self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 5, 2, 1, 1)
self.label_82 = QtGui.QLabel(Form)
self.label_82.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_82.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_82.setObjectName(_fromUtf8("label_82"))
self.gridLayout.addWidget(self.label_82, 11, 0, 1, 1)
self.label_622 = QtGui.QLabel(Form)
self.label_622.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_622.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_622.setObjectName(_fromUtf8("label_622"))
self.gridLayout.addWidget(self.label_622, 9, 0, 1, 1)
self.doubleSpinBox_7 = QtGui.QDoubleSpinBox(Form)
@ -189,7 +191,7 @@ class Ui_Form(object):
self.label_7.setObjectName(_fromUtf8("label_7"))
self.gridLayout.addWidget(self.label_7, 10, 2, 1, 1)
self.label_72 = QtGui.QLabel(Form)
self.label_72.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
self.label_72.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter)
self.label_72.setObjectName(_fromUtf8("label_72"))
self.gridLayout.addWidget(self.label_72, 10, 0, 1, 1)
self.doubleSpinBox_8 = QtGui.QDoubleSpinBox(Form)
@ -266,7 +268,7 @@ class Ui_Form(object):
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
def retranslateUi( self, Form ):
Form.setWindowTitle(_translate("Form", "Form", None))
self.label_422.setText(_translate("Form", "β", None))
self.label_10.setText(_translate("Form", "TextLabel", None))
@ -281,13 +283,17 @@ class Ui_Form(object):
self.label_huh.setText(_translate("Form", "TextLabel", None))
self.label_2.setText(_translate("Form", "TextLabel", None))
self.label_102.setText(_translate("Form", "g", None))
self.label_222.setText(_translate("Form", "<html><head/><body><p>τ<span style=\" vertical-align:sub;\">α</span></p></body></html>", None))
self.label_222.setText(
_translate("Form", "<html><head/><body><p>τ<span style=\" vertical-align:sub;\">α</span></p></body></html>",
None))
self.label_322.setText(_translate("Form", "α", None))
self.label_8.setText(_translate("Form", "TextLabel", None))
self.label_1.setText(_translate("Form", "TextLabel", None))
self.label_3.setText(_translate("Form", "TextLabel", None))
self.label_82.setText(_translate("Form", "b", None))
self.label_622.setText(_translate("Form", "<html><head/><body><p>τ<span style=\" vertical-align:sub;\">β</span></p></body></html>", None))
self.label_622.setText(
_translate("Form", "<html><head/><body><p>τ<span style=\" vertical-align:sub;\">β</span></p></body></html>",
None))
self.label_7.setText(_translate("Form", "TextLabel", None))
self.label_72.setText(_translate("Form", "a", None))
self.label_23.setText(_translate("Form", "Fix", None))

View File

@ -3,9 +3,7 @@ from PyQt4.QtGui import QColor
import numpy as np
import pyqtgraph as pg
from Mathlib import FitFunctionCreator
from BDSMathlib import FitFunctionCreator
class Data:
def __init__(self, frequency=np.zeros(1), die_real=np.zeros(1), die_imag=np.zeros(1)):
@ -35,7 +33,7 @@ class Data:
self.hide_funcs = []
self.fit_param = param
fit_real, fit_imag = FitFunctionCreator().fitfcn(param, self.frequency_fit, *funcs)
self.epsilon_fit = fit_real + 1j*fit_imag
self.epsilon_fit = fit_real+1j*fit_imag
def set_data(self,f,e_real,e_imag):
self.frequency = f

19
gracedriver.py Normal file
View File

@ -0,0 +1,19 @@
__author__ = 'markusro'
import numpy as np
def plot( x, y, **kwds ):
pass
def xlabel( label ):
pass
def ylabel( label ):
pass
def legend( ):
pass

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

File diff suppressed because it is too large Load Diff