ParameterWidgets inside ScrollbarArea;

moved menus to .ui files;
removed some spaces and empty lines
This commit is contained in:
Dominik Demuth 2017-03-15 12:28:28 +01:00
parent a6109c65b9
commit 5e76c419dc
16 changed files with 649 additions and 535 deletions

View File

@ -15,5 +15,6 @@ setup(
'hello': ['*.msg'], 'hello': ['*.msg'],
}, },
license="BSD", license="BSD",
url="https://chaos3.fkp.physik.tu-darmstadt.de/diffusion/QD/QDSfit/" url="https://chaos3.fkp.physik.tu-darmstadt.de/diffusion/QD/QDSfit/", requires=['matplotlib', 'numpy', 'pyqtgraph',
'scipy']
) )

View File

@ -10,9 +10,9 @@ from container_base import BaseContainer
import gui.container_widgets import gui.container_widgets
__author__ = 'markusro' __author__ = 'markusro'
class Conductivity(BaseContainer): class Conductivity(BaseContainer):
def __init__(self, plt_imag=None, plt_real=None, limits=None): def __init__(self, plt_imag=None, plt_real=None, limits=None):
super(Conductivity, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits) super(Conductivity, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits)
@ -22,7 +22,6 @@ class Conductivity(BaseContainer):
self.id_string = "cond" self.id_string = "cond"
self.param_number = 3 self.param_number = 3
def function(self, p, x): def function(self, p, x):
if self._abort: if self._abort:
raise StopIteration raise StopIteration
@ -70,6 +69,7 @@ class Static(BaseContainer):
cond_par = [10 ** position.y()] cond_par = [10 ** position.y()]
self.set_parameter(beta=cond_par) self.set_parameter(beta=cond_par)
class Peak(BaseContainer): class Peak(BaseContainer):
def __init__(self, plt_real=None, plt_imag=None, limits=None): def __init__(self, plt_real=None, plt_imag=None, limits=None):
super(Peak, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits) super(Peak, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits)
@ -98,6 +98,7 @@ class Peak(BaseContainer):
new_peak_beta0 = [2 * 10 ** pos.y(), 1 / (2 * np.pi * 10 ** pos.x()), 1, 1] new_peak_beta0 = [2 * 10 ** pos.y(), 1 / (2 * np.pi * 10 ** pos.x()), 1, 1]
self.set_parameter(beta=new_peak_beta0) self.set_parameter(beta=new_peak_beta0)
class YAFF(BaseContainer): class YAFF(BaseContainer):
def __init__(self, plt_real=None, plt_imag=None, limits=None): def __init__(self, plt_real=None, plt_imag=None, limits=None):
super(YAFF, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits) super(YAFF, self).__init__(plt_real=plt_real, plt_imag=plt_imag, limits=limits)

View File

@ -6,6 +6,7 @@ import abc
__author__ = 'markusro' __author__ = 'markusro'
class QABCMeta(abc.ABCMeta, QObject.__class__): class QABCMeta(abc.ABCMeta, QObject.__class__):
""" """
Allows us to use abstract base class module to fixate the container API. Allows us to use abstract base class module to fixate the container API.
@ -170,5 +171,3 @@ class BaseContainer(QObject):
if self._abort: if self._abort:
raise StopIteration raise StopIteration
raise NotImplementedError("This needs to be implemented in your container subclass") raise NotImplementedError("This needs to be implemented in your container subclass")

View File

@ -69,5 +69,3 @@ class Data:
# if self.data_curve is not None: self.data_curve.remove() # if self.data_curve is not None: self.data_curve.remove()
print "remove fitted_curve" print "remove fitted_curve"
# if self.fitted_curve is not None: self.fitted_curve.remove() # if self.fitted_curve is not None: self.fitted_curve.remove()

View File

@ -3,29 +3,31 @@ import re
from PyQt4.QtGui import QInputDialog from PyQt4.QtGui import QInputDialog
from PyQt4 import QtCore from PyQt4 import QtCore
class FileReader: class FileReader:
@staticmethod @staticmethod
def read_datafile(path): def read_datafile(path):
# TODO analyze file (LF,MF, HF) and act accordingly # TODO analyze file (LF,MF, HF) and act accordingly
print "Skipping first 4 lines!" # print "Skipping first 4 lines!"
data = np.loadtxt(path, skiprows=4, comments="#") data = np.loadtxt(path, skiprows=4, comments="#")
numpat = re.compile('\d+\.\d+') numpat = re.compile('\d+\.\d+')
print "successfully read %s"%path # print "successfully read %s" % path
try: try:
Temp = None Temp = None
print "Searching for temperature in %s (any line with 'Fixed or 'Temp', with float, i.e. 273.15K or 273.15)" % path # print "Searching for temperature in %s (any line with 'Fixed or 'Temp', with float, i.e. 273.15K or 273.15)" % path
for i, line in enumerate(open(path).readlines()): for i, line in enumerate(open(path).readlines()):
if re.search("Fixed", line) or re.search("Temp", line): if re.search("Fixed", line) or re.search("Temp", line):
print "Found line containing 'Fixed' or 'Temp' (line %i):"%i # print "Found line containing 'Fixed' or 'Temp' (line %i):" % i
print line # print line
Temp = float(re.search(numpat, line).group()) Temp = float(re.search(numpat, line).group())
print "Temperature found in file:", Temp print "Temperature found in file:", Temp
break break
print "Search temperature in file name %s (float +'K')"%path # print "Search temperature in file name %s (float +'K')" % path
search_temp_in_filename = re.search('\d+\.\d+K', path) search_temp_in_filename = re.search('\d+\.\d+K', path)
if search_temp_in_filename: if search_temp_in_filename:
Temp = float(search_temp_in_filename.group()[:-1]) Temp = float(search_temp_in_filename.group()[:-1])
if Temp == None: raise ValueError if Temp is None:
raise ValueError
except: except:
Temp = QInputDialog.getDouble(None, "No temperature found in data set", "Temperature/K:", value=0.00)[0] Temp = QInputDialog.getDouble(None, "No temperature found in data set", "Temperature/K:", value=0.00)[0]
# mask the data to values > 0 (loglog plot) # mask the data to values > 0 (loglog plot)

View File

@ -1,8 +1,4 @@
import re from PyQt4 import QtGui
import PyQt4.QtGui
__author__ = 'markusro'
import tempfile, os import tempfile, os
import numpy as np import numpy as np
@ -37,43 +33,42 @@ class GracePlot(object):
np.savetxt(tmp_name, np.array([x, y]).T) np.savetxt(tmp_name, np.array([x, y]).T)
# read data from temporary file # read data from temporary file
self.cmds.append('READ NXY "%s"\n'%tmp_name) self.cmds.append('READ NXY "{}"\n'.format(tmp_name))
self.cmds.append('S%i SYMBOL SIZE 0.5\n'%(self.data_counter)) self.cmds.append('S{} SYMBOL SIZE 0.5\n'.format(self.data_counter))
self.cmds.append('S%i SYMBOL FILL PATTERN 1\n'%(self.data_counter)) self.cmds.append('S{} SYMBOL FILL PATTERN 1\n'.format(self.data_counter))
self.cmds.append('S%i SYMBOL 1\n'%(self.data_counter)) # No line self.cmds.append('S{} SYMBOL 1\n'.format(self.data_counter)) # No line
if "label" in kwds.keys(): if "label" in kwds.keys():
# TODO: implement at least greek symbols and lower upper case (_ and ^)? # TODO: implement at least greek symbols and lower upper case (_ and ^)?
# with translate method? # with translate method?
label = unicode(kwds["label"]).encode('ascii', 'ignore') label = unicode(kwds["label"]).encode('ascii', 'ignore')
self.cmds.append('S%i LEGEND "%s"\n'%(self.data_counter, label)) self.cmds.append('S{} LEGEND "{}"\n'.format(self.data_counter, label))
if "ls" in kwds.keys(): if "ls" in kwds.keys():
ls = kwds["ls"] ls = kwds["ls"]
if ls in self.ls_map.keys(): if ls in self.ls_map.keys():
self.cmds.append('S%i LINE LINESTYLE %i\n'%(self.data_counter, self.ls_map[ls])) # Line self.cmds.append('S{} LINE LINESTYLE {}\n'.format(self.data_counter, self.ls_map[ls])) # Line
if "sym" in kwds.keys(): if "sym" in kwds.keys():
sym = kwds["sym"] sym = kwds["sym"]
if sym in self.sym_map.keys(): if sym in self.sym_map.keys():
self.cmds.append('S%i SYMBOL %i\n'%(self.data_counter, self.sym_map[sym])) self.cmds.append('S{} SYMBOL {}\n'.format(self.data_counter, self.sym_map[sym]))
if sym in ['+', 'x', '*']: if sym in ['+', 'x', '*']:
self.cmds.append('S%i SYMBOL COLOR %i\n'%(self.data_counter, self.data_counter)) self.cmds.append('S{} SYMBOL COLOR {}\n'.format(self.data_counter, self.data_counter))
else: else:
self.cmds.append('S%i SYMBOL COLOR %i\n' % (self.data_counter, 1)) # vlack symbol outline self.cmds.append('S{} SYMBOL COLOR {}\n'.format(self.data_counter, 1)) # vlack symbol outline
else: else:
print "Symbol not known: %s"%sym print "Symbol not known: {}".format(sym)
if "color" in kwds.keys(): if "color" in kwds.keys():
color = str(PyQt4.QtGui.QColor(kwds["color"]).getRgb()[:3]) color = str(QtGui.QColor(*kwds["color"]).getRgb()[:3])
if color in self.color_map.keys(): if color in self.color_map.keys():
color_id = self.color_map[color][0] color_id = self.color_map[color][0]
else: else:
self.color_map[color] = [ self.color_map[color] = [
self.color_counter, self.color_counter,
"@MAP COLOR %i TO %s, \"qds%i\" \n"% (self.color_counter, color, self.color_counter) "@MAP COLOR {} TO {}, \"qds{}\" \n".format(self.color_counter, color, self.color_counter)
] ]
color_id = self.color_counter color_id = self.color_counter
self.color_counter += 1 self.color_counter += 1
@ -83,7 +78,6 @@ class GracePlot(object):
self.data_counter += 1 self.data_counter += 1
def loglog(self, x, y, **kwds): def loglog(self, x, y, **kwds):
self.cmds.append('YAXES SCALE LOGARITHMIC\n') self.cmds.append('YAXES SCALE LOGARITHMIC\n')
self.cmds.append("YAXIS TICKLABEL FORMAT POWER\n") self.cmds.append("YAXIS TICKLABEL FORMAT POWER\n")
@ -105,24 +99,20 @@ class GracePlot(object):
self.cmds.append("YAXIS TICKLABEL PREC 0\n") self.cmds.append("YAXIS TICKLABEL PREC 0\n")
self.plot(x, y, **kwds) self.plot(x, y, **kwds)
def xlabel(self, label): def xlabel(self, label):
self.cmds.append('XAXIS LABEL "%s"\n'%label) self.cmds.append('XAXIS LABEL "%s"\n'%label)
pass pass
def ylabel(self, label): def ylabel(self, label):
self.cmds.append('YAXIS LABEL "%s"\n'%label) self.cmds.append('YAXIS LABEL "%s"\n'%label)
pass pass
def legend(self, on=True): def legend(self, on=True):
if on: if on:
self.cmds.append('LEGEND ON\n') self.cmds.append('LEGEND ON\n')
else: else:
self.cmds.append('LEGEND OFF\n') self.cmds.append('LEGEND OFF\n')
def save(self): def save(self):
self.cmds.append('AUTOSCALE\n') self.cmds.append('AUTOSCALE\n')
self.cmds.append('SAVEALL "%s"\n'%self.fname) self.cmds.append('SAVEALL "%s"\n'%self.fname)

View File

@ -20,9 +20,9 @@ class ParameterWidget(QWidget):
self.vlayout.update() self.vlayout.update()
class LogFSpinBox(QDoubleSpinBox): class LogFSpinBox(QDoubleSpinBox):
scientificNotationValidator = QRegExpValidator(QRegExp("[+-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?")) scientificNotationValidator = QRegExpValidator(QRegExp("[+-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?"))
def __init__(self, parent=None): def __init__(self, parent=None):
super(LogFSpinBox, self).__init__(parent) super(LogFSpinBox, self).__init__(parent)
self.setRange(0.0, 1e18) self.setRange(0.0, 1e18)
@ -44,7 +44,6 @@ class LogFSpinBox(QDoubleSpinBox):
return self.scientificNotationValidator.validate(str_value, p_int) return self.scientificNotationValidator.validate(str_value, p_int)
class BaseWidget(QGroupBox): class BaseWidget(QGroupBox):
changedTable = pyqtSignal() changedTable = pyqtSignal()
removeMe = pyqtSignal() removeMe = pyqtSignal()
@ -67,7 +66,6 @@ class BaseWidget(QGroupBox):
self.subtract.emit(self._subtracted) self.subtract.emit(self._subtracted)
self._subtracted = not self._subtracted # Toggle state self._subtracted = not self._subtracted # Toggle state
def change_values(self, num): def change_values(self, num):
self.changedTable.emit() self.changedTable.emit()
@ -172,7 +170,6 @@ class PeakWidget(BaseWidget,QGroupBox):
self.ui.checkBox_4] self.ui.checkBox_4]
self.ui.comboBox.currentIndexChanged.connect(self._distrib_select) self.ui.comboBox.currentIndexChanged.connect(self._distrib_select)
def _distrib_select(self, dist): def _distrib_select(self, dist):
self._distrib_hn(1) self._distrib_hn(1)
if dist == 0: # hav-neg: if dist == 0: # hav-neg:
@ -222,7 +219,6 @@ class PeakWidget(BaseWidget,QGroupBox):
self.ui.doubleSpinBox_4.setDisabled(False) self.ui.doubleSpinBox_4.setDisabled(False)
self.func_type = "HN" self.func_type = "HN"
def _distrib_cc(self, state): def _distrib_cc(self, state):
if state: if state:
self.ui.doubleSpinBox_4.setValue(1.0) self.ui.doubleSpinBox_4.setValue(1.0)
@ -237,8 +233,6 @@ class PeakWidget(BaseWidget,QGroupBox):
self.ui.doubleSpinBox_4.setDisabled(False) self.ui.doubleSpinBox_4.setDisabled(False)
self.func_type = "HN" self.func_type = "HN"
def setId(self, id): def setId(self, id):
self.id = id self.id = id
self.setTitle("Peak %i" % id) self.setTitle("Peak %i" % id)
@ -275,7 +269,6 @@ class PeakWidget(BaseWidget,QGroupBox):
class StaticWidget(BaseWidget, QGroupBox): class StaticWidget(BaseWidget, QGroupBox):
def __init__(self, parent=None): def __init__(self, parent=None):
QGroupBox.__init__(self) QGroupBox.__init__(self)
BaseWidget.__init__(self) BaseWidget.__init__(self)
@ -300,9 +293,7 @@ class StaticWidget(BaseWidget, QGroupBox):
self.func_type = r"$\epsilon_\infty$" self.func_type = r"$\epsilon_\infty$"
class ConductivityWidget(BaseWidget, QGroupBox): class ConductivityWidget(BaseWidget, QGroupBox):
def __init__(self, parent=None): def __init__(self, parent=None):
QGroupBox.__init__(self) QGroupBox.__init__(self)
BaseWidget.__init__(self) BaseWidget.__init__(self)
@ -344,9 +335,7 @@ class ConductivityWidget(BaseWidget, QGroupBox):
dsb.valueChanged.connect(self.change_values) dsb.valueChanged.connect(self.change_values)
class PowerLawWidget(BaseWidget): class PowerLawWidget(BaseWidget):
def __init__(self, parent=None): def __init__(self, parent=None):
# QGroupBox.__init__(self) # QGroupBox.__init__(self)
BaseWidget.__init__(self) BaseWidget.__init__(self)
@ -475,6 +464,7 @@ class YaffWidget(BaseWidget):
qd.configuration_changed.connect(self._store_config) qd.configuration_changed.connect(self._store_config)
qd.exec_() qd.exec_()
# qd.show() # qd.show()
def _store_config(self, t_list, tau_list): def _store_config(self, t_list, tau_list):
self._t_list = t_list self._t_list = t_list
self._tau_list = tau_list self._tau_list = tau_list
@ -513,6 +503,7 @@ class YaffWidget(BaseWidget):
self.selector_mask = [not i for i in mask[ndx]] self.selector_mask = [not i for i in mask[ndx]]
self.on_model_changed.emit() self.on_model_changed.emit()
class YaffConfigWidget(QDialog): class YaffConfigWidget(QDialog):
configuration_changed = pyqtSignal(list, list) configuration_changed = pyqtSignal(list, list)
@ -534,8 +525,6 @@ class YaffConfigWidget(QDialog):
self.ui.doubleSpinBox_tmin.setParent(None) self.ui.doubleSpinBox_tmin.setParent(None)
self.ui.doubleSpinBox_tmin = LogFSpinBox(self) self.ui.doubleSpinBox_tmin = LogFSpinBox(self)
self.ui.gridLayout_time.addWidget(self.ui.doubleSpinBox_tmin, row, column) self.ui.gridLayout_time.addWidget(self.ui.doubleSpinBox_tmin, row, column)
ndx = self.ui.gridLayout_time.indexOf(self.ui.doubleSpinBox_tmax) ndx = self.ui.gridLayout_time.indexOf(self.ui.doubleSpinBox_tmax)
@ -586,4 +575,3 @@ class YaffConfigWidget(QDialog):
self.ui.doubleSpinBox_taumax.value(), self.ui.doubleSpinBox_taumax.value(),
self.ui.spinBox_taun.value()] self.ui.spinBox_taun.value()]
self.configuration_changed.emit(t_list, tau_list) self.configuration_changed.emit(t_list, tau_list)

View File

@ -47,7 +47,6 @@ class Graph(object):
gr.setSymbol(s) gr.setSymbol(s)
gr.setStyle(0) gr.setStyle(0)
def update_graph_data(self, x, y_real, y_imag): def update_graph_data(self, x, y_real, y_imag):
""" """
Update Graph data. Update Graph data.
@ -59,8 +58,9 @@ class Graph(object):
self.graph_real.setData(x, y_real) self.graph_real.setData(x, y_real)
self.graph_imag.setData(x, y_imag) self.graph_imag.setData(x, y_imag)
class DataGraph(Graph): class DataGraph(Graph):
def __init__(self): def __init__(self, x, y):
super(DataGraph, self).__init__() super(DataGraph, self).__init__()
self._pen = pg.mkPen(QColor(0, 0, 0, 0)) self._pen = pg.mkPen(QColor(0, 0, 0, 0))
self.graph_real = pg.PlotDataItem(x=x, y=y, pen=self._pen, symbol="o", symbolBrush=(255, 127, 0, 127)) self.graph_real = pg.PlotDataItem(x=x, y=y, pen=self._pen, symbol="o", symbolBrush=(255, 127, 0, 127))
@ -69,6 +69,7 @@ class DataGraph(Graph):
class GraphObject(Graph, Daten, ModelFunction): class GraphObject(Graph, Daten, ModelFunction):
parameter_changed_signal = pyqtSignal(list) parameter_changed_signal = pyqtSignal(list)
def __init__(self): def __init__(self):
super(GraphObject, self).__init__(self) super(GraphObject, self).__init__(self)
self.data_changed_signal.connect(self.update_graph_data) self.data_changed_signal.connect(self.update_graph_data)

View File

@ -1,8 +1,6 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import yafflib import yafflib
__author__ = 'markusro'
from PyQt4.QtGui import QColor from PyQt4.QtGui import QColor
from PyQt4.QtCore import QObject, pyqtSignal, pyqtSlot from PyQt4.QtCore import QObject, pyqtSignal, pyqtSlot
@ -34,7 +32,6 @@ class FitFunctionCreator(QObject):
self.data = None self.data = None
self.functions = Functions() self.functions = Functions()
def fitfcn(self, p0, x, *funcs): def fitfcn(self, p0, x, *funcs):
if x.ndim == 2: if x.ndim == 2:
self.data = np.zeros(x.shape) self.data = np.zeros(x.shape)
@ -88,7 +85,7 @@ class FitRoutine(QObject):
return self._start_parameter return self._start_parameter
@start_parameter.setter @start_parameter.setter
def start_paramter( self, p0 ): def start_parameter(self, p0):
self._start_parameter = p0 self._start_parameter = p0
@property @property
@ -107,7 +104,7 @@ class FitRoutine(QObject):
# 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]) y = np.array([y.real, y.imag])
else: else:
raise NotImplementedError, "need complex input for now" raise NotImplementedError("need complex input for now")
dat = odr.Data(x, y, we=we) dat = odr.Data(x, y, we=we)
mod = odr.Model(self.f.fitfcn, extra_args=fcns) mod = odr.Model(self.f.fitfcn, extra_args=fcns)
self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800) self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800)
@ -117,7 +114,7 @@ class FitRoutine(QObject):
if np.iscomplexobj(y) and y.ndim == 1: if np.iscomplexobj(y) and y.ndim == 1:
we = 1 / np.imag(y) ** 2 we = 1 / np.imag(y) ** 2
else: else:
raise NotImplementedError, "need complex input for now" raise NotImplementedError("need complex input for now")
dat = odr.Data(x, y.imag, we=we) dat = odr.Data(x, y.imag, we=we)
mod = odr.Model(self.f.fitfcn_imag, extra_args=fcns) mod = odr.Model(self.f.fitfcn_imag, extra_args=fcns)
self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800) self._odr_fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=800)
@ -145,7 +142,7 @@ class FunctionRegister:
# print "FR: Registering:",obj # print "FR: Registering:",obj
id_string = obj.id_label id_string = obj.id_label
if self.registry.has_key(obj): if self.registry.has_key(obj):
raise AssertionError, "The object is already registered! This should NOT happen" raise AssertionError("The object is already registered! This should NOT happen")
self.registry[obj] = id_string self.registry[obj] = id_string
# print "FR: ",self.registry # print "FR: ",self.registry
@ -155,7 +152,7 @@ class FunctionRegister:
self.registry.pop(obj) self.registry.pop(obj)
else: else:
obj.deleteLater() 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 # print "FR: ",self.registry
def get_registered_functions(self): def get_registered_functions(self):
@ -198,7 +195,7 @@ def fit_odr_cmplx( x, y, p0, fixed, fcns ):
# 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]) y = np.array([y.real, y.imag])
else: else:
raise NotImplementedError, "need complex input for now" raise NotImplementedError("need complex input for now")
dat = odr.Data(x, y, we=we) dat = odr.Data(x, y, we=we)
mod = odr.Model(f.fitfcn, extra_args=fcns) mod = odr.Model(f.fitfcn, extra_args=fcns)
fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=8000) fit = odr.ODR(dat, mod, p0, ifixx=(0,), ifixb=fixed, maxit=8000)
@ -207,7 +204,7 @@ def fit_odr_cmplx( x, y, p0, fixed, fcns ):
return fit.output return fit.output
### define funcs here # define funcs here
class Functions(QObject): class Functions(QObject):
def __init__(self): def __init__(self):
super(Functions, self).__init__() super(Functions, self).__init__()
@ -221,7 +218,8 @@ class Functions(QObject):
} }
self.YAFF = yafflib.Yaff() self.YAFF = yafflib.Yaff()
def hn_cmplx( self, p, x ): @staticmethod
def hn_cmplx(p, x):
om = 2 * np.pi * x om = 2 * np.pi * x
# hn = om*1j # hn = om*1j
eps, t, a, b = p eps, t, a, b = p
@ -229,21 +227,25 @@ class Functions(QObject):
cplx = np.array([hn.real, -hn.imag]) cplx = np.array([hn.real, -hn.imag])
return cplx return cplx
def cond_cmplx( self, p, x ): @staticmethod
def cond_cmplx(p, x):
om = 2 * np.pi * x om = 2 * np.pi * x
sgma, isgma, n = p 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]) cplx = np.array([cond.real, -cond.imag])
return cplx return cplx
def power_cmplx( self, p, x ): @staticmethod
def power_cmplx(p, x):
om = 2 * np.pi * x om = 2 * np.pi * x
sgma, n = p sgma, n = p
power = sgma / (om * 1j) ** n power = sgma / (om * 1j) ** n
cplx = np.array([power.real, -power.imag]) cplx = np.array([power.real, -power.imag])
return cplx return cplx
def static_cmplx( self, p, x ): @staticmethod
def static_cmplx(p, x):
eps_inf = p[0] eps_inf = p[0]
static = np.ones((2, x.size)) * eps_inf static = np.ones((2, x.size)) * eps_inf
static[1, :] *= 0 # set imag part zero static[1, :] *= 0 # set imag part zero
@ -367,6 +369,3 @@ 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 = (np.sin(np.pi * a / 2. / (b + 1)) / np.sin(np.pi * a * b / 2. / (b + 1))) ** (1 / a)
tau /= 2 * np.pi * f tau /= 2 * np.pi * f
return tau return tau

View File

@ -7,8 +7,6 @@ __author__ = 'markusro'
class Function(object): class Function(object):
def __init__(self): def __init__(self):
super(Function, self).__init__() super(Function, self).__init__()
self._id_string = None self._id_string = None
@ -16,27 +14,33 @@ class Function(object):
self._pretty_name = "" self._pretty_name = ""
self._function = None self._function = None
@classmethod
def get_id_string(cls): def get_id_string(cls):
if cls._id_string is None: if cls._id_string is None:
raise NotImplementedError("You need to set the id_string") raise NotImplementedError("You need to set the id_string")
return cls._id_string return cls._id_string
@classmethod
def set_id_string(cls, s): def set_id_string(cls, s):
cls._id_string = s cls._id_string = s
@classmethod
def get_num_paramters(cls): def get_num_paramters(cls):
if cls._num_paramters is None: if cls._num_paramters is None:
raise NotImplementedError("You need to set the num_paramters") raise NotImplementedError("You need to set the num_paramters")
return cls._num_paramters return cls._num_paramters
@classmethod
def set_num_paramters(cls, s): def set_num_paramters(cls, s):
cls._num_paramters = s cls._num_paramters = s
@classmethod
def get_function(cls): def get_function(cls):
if cls._function is None: if cls._function is None:
raise NotImplementedError("You need to set f") raise NotImplementedError("You need to set f")
return cls._function return cls._function
@classmethod
def set_function(cls, f): def set_function(cls, f):
cls._function = f cls._function = f
@ -110,7 +114,6 @@ def static_cmplx(p, x ):
return static return static
class YaffCmplx(Function): class YaffCmplx(Function):
def __init__(self): def __init__(self):
super(YaffCmplx, self).__init__() super(YaffCmplx, self).__init__()

View File

@ -1,14 +1,14 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
import fileio.gracedriver from __future__ import division
import hashlib
_author_ = "Markus Rosenstihl"
import hashlib, uuid
import time
import os, sys, re, signal
import matplotlib import matplotlib
import os
import re
import signal
import sys
import time
import uuid
matplotlib.use('agg') matplotlib.use('agg')
@ -16,7 +16,6 @@ from matplotlib import pyplot
from matplotlib.colors import hex2color from matplotlib.colors import hex2color
# matplotlib.rc_file("default.mplrc") # matplotlib.rc_file("default.mplrc")
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
@ -24,14 +23,18 @@ import numpy as np
import pyqtgraph as pg import pyqtgraph as pg
from data.Container import Conductivity, PowerComplex, Static, Peak, YAFF from data.Container import Conductivity, PowerComplex, Static, Peak, YAFF
from gui.container_widgets import ParameterWidget from data.experimental import Data
from ui import QDSMain
from libmath.BDSlib import FunctionRegister, FitRoutine from libmath.BDSlib import FunctionRegister, FitRoutine
from data.experimental import Data from gui.container_widgets import ParameterWidget
from gui import ExtraDifferentialWidget from gui import ExtraDifferentialWidget
from ui import QDSMain
from fileio import bds_file_reader from fileio import bds_file_reader
import fileio.gracedriver
__author__ = "Markus Rosenstihl"
class AppWindow(QMainWindow): class AppWindow(QMainWindow):
@ -42,18 +45,6 @@ class AppWindow(QMainWindow):
self._file_paths = self._sortInputFiles(files) self._file_paths = self._sortInputFiles(files)
self._last_written_header = None self._last_written_header = None
# create action group
actions = {
self.ui.actionAdd_Peak: True,
self.ui.actionAdd_Cond: True,
self.ui.actionAdd_PowerLaw: True,
self.ui.actionAdd_Eps_Infty: True,
self.ui.actionYAFF: True,
}
self.myActionGroup = QActionGroup(self)
for a in actions.keys(): self.myActionGroup.addAction(a)
self._init_menu() self._init_menu()
self.function_registry = FunctionRegister() self.function_registry = FunctionRegister()
@ -61,7 +52,12 @@ class AppWindow(QMainWindow):
self.peakId = 0 self.peakId = 0
self.parameterWidget = ParameterWidget() self.parameterWidget = ParameterWidget()
self.ui.dockWidget_3.setWidget(self.parameterWidget)
# if too many widgets are added some of them are outside the display and inaccessible
# so we need a scrollbar
self.ui.scrollArea.setMinimumWidth(278)
self.ui.scrollArea.setWidget(self.parameterWidget)
self.ui.dockWidget_3.hide()
self.data = Data() self.data = Data()
@ -82,6 +78,9 @@ class AppWindow(QMainWindow):
self.fit_boundary_real.sigRegionChanged.connect(self._update_fit_boundary_real) self.fit_boundary_real.sigRegionChanged.connect(self._update_fit_boundary_real)
self.fit_boundary_real.sigRegionChangeFinished.connect(self.update_plot) self.fit_boundary_real.sigRegionChangeFinished.connect(self.update_plot)
# x axis of real and imag are changed together
self.ui.pgPlotWidget_real.setXLink(self.ui.pgPlotWidget_imag)
for pltwidgt in (self.ui.pgPlotWidget_real, self.ui.pgPlotWidget_imag): for pltwidgt in (self.ui.pgPlotWidget_real, self.ui.pgPlotWidget_imag):
pltwidgt.setLogMode(x=True, y=True) pltwidgt.setLogMode(x=True, y=True)
pltwidgt.showGrid(x=True, y=True) pltwidgt.showGrid(x=True, y=True)
@ -106,72 +105,30 @@ class AppWindow(QMainWindow):
self._fit_method.data_ready.connect(self.updateIntermediatePlot) self._fit_method.data_ready.connect(self.updateIntermediatePlot)
self._fit_thread.started.connect(self._fit_method.fit) self._fit_thread.started.connect(self._fit_method.fit)
# finally process cmd line args # finally process cmd line args
if files != []: if files:
self.openFile(unicode(self._file_paths[0])) self.openFile(unicode(self._file_paths[0]))
self._current_file_index = 0 self._current_file_index = 0
def _init_menu(self): def _init_menu(self):
fileMenu = self.menuBar().addMenu("File")
openFile = QAction("&Open", self)
openFile.setShortcut(QKeySequence.Open)
openFile.triggered.connect(self.getFileNames)
fileMenu.addAction(openFile)
nextFile = QAction("Next", self)
nextFile.setShortcut(QKeySequence("Ctrl+k"))
nextFile.triggered.connect(self.nextFile)
fileMenu.addAction(nextFile)
previousFile = QAction("Previous", self)
previousFile.setShortcut(QKeySequence("Ctrl+j"))
previousFile.triggered.connect(self.previousFile)
fileMenu.addAction(previousFile)
saveFile = QAction("&Save Fit Result (Data)", self)
saveFile.setShortcut(QKeySequence.Save)
saveFile.triggered.connect(self.saveFitResult)
fileMenu.addAction(saveFile)
self.ui.actionSave_FitResult.triggered.connect(lambda: self._saveFitFigure(mode="w")) self.ui.actionSave_FitResult.triggered.connect(lambda: self._saveFitFigure(mode="w"))
self.ui.actionAppend_Fit.triggered.connect(lambda: self._saveFitFigure(mode="a")) self.ui.actionAppend_Fit.triggered.connect(lambda: self._saveFitFigure(mode="a"))
# fitting methods # fitting methods
fitMenu = self.menuBar().addMenu("Standard Fits") self.ui.action_fit_lm.triggered.connect(lambda: self.fitData_start(0))
# lm self.ui.action_NLS_imag.triggered.connect(lambda: self.fitData_start(1))
fit_lmAction = QAction("Complex NLS", self) self.ui.actionSimulated_Annealing.triggered.connect(lambda: self.fitData_start(2))
fit_lmAction.setShortcut(QKeySequence("Ctrl+F"))
fitMenu.addAction(fit_lmAction)
# lbfgsb
fit_lbfgsbAction = QAction("NLS (Imag.)", self)
fitMenu.addAction(fit_lbfgsbAction)
# Simulated Annealing
fit_annealAction = QAction("&Simulated Annealing", self)
fitMenu.addAction(fit_annealAction)
self.ui.actionActionAbortFit.triggered.connect(self.abortFit)
self.signalMapper = QSignalMapper(self)
for i, fit_action in enumerate([fit_lmAction, fit_lbfgsbAction, fit_annealAction
]):
self.signalMapper.setMapping(fit_action, i)
fit_action.triggered.connect(self.signalMapper.map)
self.signalMapper.mapped.connect(self.fitData_start)
self.ui.actionShow_Derivative.triggered.connect(self.show_derivative)
self.ui.menuConfiguration.triggered.connect(self.conf)
@pyqtSlot(name='on_menuConfiguration_triggered')
def conf(self): def conf(self):
pass pass
@pyqtSlot(name='on_actionShow_Derivative_triggered')
def show_derivative(self): def show_derivative(self):
self.xtra_wdgt = ExtraDifferentialWidget.DifferentialWidget() self.xtra_wdgt = ExtraDifferentialWidget.DifferentialWidget()
# self.xtra_wdgt.set # self.xtra_wdgt.set
deriv_r = np.diff(np.log10(self.data.epsilon.real)) deriv_r = np.diff(np.log10(self.data.epsilon.real))
deriv_i = np.diff(np.log10(self.data.epsilon.imag))*0 # deriv_i = np.diff(np.log10(self.data.epsilon.imag)) * 0
deriv_i = -np.pi / 2 * np.diff(np.log10(self.data.epsilon.real)) / np.diff(np.log10(self.data.frequency)) deriv_i = -np.pi / 2 * np.diff(np.log10(self.data.epsilon.real)) / np.diff(np.log10(self.data.frequency))
self.xtra_wdgt.plot(self.data.frequency[:-1], deriv_r, deriv_i) self.xtra_wdgt.plot(self.data.frequency[:-1], deriv_r, deriv_i)
# self.xtra_wdgt.plot([0,1], [0,1], [0,1]) # self.xtra_wdgt.plot([0,1], [0,1], [0,1])
@ -180,9 +137,7 @@ class AppWindow(QMainWindow):
# self.xtra_wdgt.showCenterd() # self.xtra_wdgt.showCenterd()
self.xtra_wdgt.raise_() self.xtra_wdgt.raise_()
def updateCrosshair(self, evt): def updateCrosshair(self, evt):
vb_real = self.ui.pgPlotWidget_real.getPlotItem().vb vb_real = self.ui.pgPlotWidget_real.getPlotItem().vb
vb_imag = self.ui.pgPlotWidget_imag.getPlotItem().vb vb_imag = self.ui.pgPlotWidget_imag.getPlotItem().vb
if self.ui.pgPlotWidget_imag.underMouse(): if self.ui.pgPlotWidget_imag.underMouse():
@ -247,21 +202,19 @@ class AppWindow(QMainWindow):
msgBox.setText("Click in real part") msgBox.setText("Click in real part")
msgBox.exec_() msgBox.exec_()
@pyqtSlot(name='on_actionActionAbortFit_triggered')
def abortFit(self): def abortFit(self):
for container in self.function_registry.get_registered_functions(): for container in self.function_registry.get_registered_functions():
container.abort(True) container.abort(True)
self._fit_thread.terminate() self._fit_thread.terminate()
@pyqtSlot(name='on_action_saveFile_triggered')
def saveFitResult(self): def saveFitResult(self):
""" """
Saving fit parameters to fitresults.log Saving fit parameters to fitresults.log
including temperature including temperature
""" """
self._saveFitFigure() self._saveFitFigure()
if not os.path.exists("fitresults.log"):
f = open("fitresults.log", "w")
else:
f = open("fitresults.log", "a")
# prepare header # prepare header
file_id = hashlib.md5(open(self._file_paths[self._current_file_index]).read()).hexdigest() file_id = hashlib.md5(open(self._file_paths[self._current_file_index]).read()).hexdigest()
@ -281,6 +234,7 @@ class AppWindow(QMainWindow):
# write for each function an extra file # write for each function an extra file
fit_filename = "%s_%i.fit" % (base_filename, i_fcn) fit_filename = "%s_%i.fit" % (base_filename, i_fcn)
f_fcn = open(fit_filename, 'w') f_fcn = open(fit_filename, 'w')
print 'Save to {}'.format(fit_filename)
# retrieve correct function type peak # retrieve correct function type peak
# if fit_function_name == "hn": # if fit_function_name == "hn":
f_fcn.write("# type=%s\n" % fcn.widget.func_type) f_fcn.write("# type=%s\n" % fcn.widget.func_type)
@ -306,6 +260,13 @@ class AppWindow(QMainWindow):
# append fit limits header # append fit limits header
header += "%-13s%-13s\n" % ("fit_xlow", "fit_xhigh") header += "%-13s%-13s\n" % ("fit_xlow", "fit_xhigh")
fpath = os.path.split(self.filepath)[0]
save_fname = os.path.join(fpath, "fitresults.log")
if not os.path.exists(save_fname):
f = open(save_fname, "w")
else:
f = open(save_fname, "a")
print 'Save fitresults to {}'.format(save_fname)
# write new header if fit model changed TODO: more robust detection # write new header if fit model changed TODO: more robust detection
if self._last_written_header != header: if self._last_written_header != header:
f.write(pre_header) f.write(pre_header)
@ -342,7 +303,8 @@ class AppWindow(QMainWindow):
color = hex2color(str(fcn.color.name())) color = hex2color(str(fcn.color.name()))
pyplot.loglog(f, eps[1], ls=":", color=color, lw=1, dashes=(1, 1), label=label) pyplot.loglog(f, eps[1], ls=":", color=color, lw=1, dashes=(1, 1), label=label)
for i in (0, 1): pyplot.axvline(x=self.data.fit_limits[i], color='b', ls="-", lw=0.5) for i in (0, 1):
pyplot.axvline(x=self.data.fit_limits[i], color='b', ls="-", lw=0.5)
pyplot.legend(title="T=%.1f K" % (self.data.meta["T"])) pyplot.legend(title="T=%.1f K" % (self.data.meta["T"]))
pyplot.xlabel('f/Hz') pyplot.xlabel('f/Hz')
pyplot.ylabel(u'ε"') pyplot.ylabel(u'ε"')
@ -350,7 +312,7 @@ class AppWindow(QMainWindow):
# pyplot.savefig(os.path.splitext(self.filepath)[0]+".png") # pyplot.savefig(os.path.splitext(self.filepath)[0]+".png")
pyplot.savefig(os.path.splitext(self.filepath)[0] + ".pdf") pyplot.savefig(os.path.splitext(self.filepath)[0] + ".pdf")
fig.clear() fig.clear()
del (fig) del fig
self._saveFitFigureGrace(mode) self._saveFitFigureGrace(mode)
def _saveFitFigureGrace(self, mode="w"): def _saveFitFigureGrace(self, mode="w"):
@ -379,11 +341,12 @@ class AppWindow(QMainWindow):
self.grace_plot.legend(True) self.grace_plot.legend(True)
self.grace_plot.xlabel("f / Hz") self.grace_plot.xlabel("f / Hz")
self.grace_plot.ylabel("eps") self.grace_plot.ylabel("eps")
print self.grace_plot.cmds # print self.grace_plot.cmds
self.grace_plot.save() self.grace_plot.save()
def addContainer(self, selected_container, pos): def addContainer(self, selected_container, pos):
if not self.ui.dockWidget_3.isVisible():
self.ui.dockWidget_3.show()
_cont = selected_container(plt_real=self.ui.pgPlotWidget_real, _cont = selected_container(plt_real=self.ui.pgPlotWidget_real,
plt_imag=self.ui.pgPlotWidget_imag, plt_imag=self.ui.pgPlotWidget_imag,
limits=self.data.fit_limits) limits=self.data.fit_limits)
@ -427,6 +390,7 @@ class AppWindow(QMainWindow):
else: else:
self.ui.statusbar.showMessage("Still fitting ...") self.ui.statusbar.showMessage("Still fitting ...")
@pyqtSlot()
def fitData_update(self): def fitData_update(self):
self._fit_thread.quit() self._fit_thread.quit()
odr_result = self._fit_method.result() odr_result = self._fit_method.result()
@ -455,14 +419,16 @@ class AppWindow(QMainWindow):
self.fit_boundary_real.show() self.fit_boundary_real.show()
self.fit_boundary_imag.show() self.fit_boundary_imag.show()
@pyqtSlot(name='on_action_openFile_triggered')
def getFileNames(self): def getFileNames(self):
tmp = QFileDialog.getOpenFileNames(self, "Open file", "", '*.dat *.TXT') tmp = QFileDialog().getOpenFileNames(self, "Open file", "", '*.dat *.TXT')
if len(tmp) != 0: if len(tmp) != 0:
self._file_paths = tmp self._file_paths = tmp
self._current_file_index = 0 self._current_file_index = 0
path = unicode(self._file_paths[self._current_file_index]) path = unicode(self._file_paths[self._current_file_index])
self.openFile(path) self.openFile(path)
@pyqtSlot(name='on_action_nextFile_triggered')
def nextFile(self): def nextFile(self):
lim = self.fit_boundary_imag.getRegion() # store limits lim = self.fit_boundary_imag.getRegion() # store limits
if len(self._file_paths) > self._current_file_index + 1: # wrap around if len(self._file_paths) > self._current_file_index + 1: # wrap around
@ -473,6 +439,7 @@ class AppWindow(QMainWindow):
self.openFile(path) self.openFile(path)
self.fit_boundary_imag.setRegion(lim) self.fit_boundary_imag.setRegion(lim)
@pyqtSlot(name='on_action_previousFile_triggered')
def previousFile(self): def previousFile(self):
lim = self.fit_boundary_imag.getRegion() # store limits lim = self.fit_boundary_imag.getRegion() # store limits
if self._current_file_index == 0: # wrap around if self._current_file_index == 0: # wrap around
@ -486,7 +453,6 @@ class AppWindow(QMainWindow):
def _sortInputFiles(self, files): def _sortInputFiles(self, files):
return QStringList(sorted(files, key=lambda x: re.findall("\d+\.\d+K", x))) return QStringList(sorted(files, key=lambda x: re.findall("\d+\.\d+K", x)))
def openFile(self, path): def openFile(self, path):
print "opening: %s" % path print "opening: %s" % path
self.filepath = path self.filepath = path
@ -506,14 +472,12 @@ class AppWindow(QMainWindow):
self.ui.pgPlotWidget_real.setXRange(np.log10(_freq.min()), np.log10(_freq.max())) self.ui.pgPlotWidget_real.setXRange(np.log10(_freq.min()), np.log10(_freq.max()))
self.ui.pgPlotWidget_real.setYRange(np.log10(_die_stor.min()), np.log10(_die_stor.max())) self.ui.pgPlotWidget_real.setYRange(np.log10(_die_stor.min()), np.log10(_die_stor.max()))
# self.ui.pgPlotWidget_real.setRange(xRange=(_freq.min(), _freq.max()), # self.ui.pgPlotWidget_real.setRange(xRange=(_freq.min(), _freq.max()),
# yRange=(_die_stor.min(), _die_stor.max()) ) # yRange=(_die_stor.min(), _die_stor.max()) )
self.update_plot() self.update_plot()
def update_plot(self): def update_plot(self):
print "redrawing plot", self.sender() # print "redrawing plot", self.sender()
log10fmin, log10fmax = self.fit_boundary_imag.getRegion() log10fmin, log10fmax = self.fit_boundary_imag.getRegion()
self.data.set_fit_xlimits(10 ** log10fmin, 10 ** log10fmax) self.data.set_fit_xlimits(10 ** log10fmin, 10 ** log10fmax)
@ -522,11 +486,9 @@ class AppWindow(QMainWindow):
p0.extend(fcn.get_parameter()) p0.extend(fcn.get_parameter())
funcs.append(fcn) funcs.append(fcn)
# calculate parametrized curve # calculate parametrized curve
self.data.set_fit(p0, funcs) self.data.set_fit(p0, funcs)
# replot data and fit, TODO: replot only if measurement data changed # replot data and fit, TODO: replot only if measurement data changed
self.data.experimental_curve_real.setData(self.data.frequency, self.data.epsilon.real) self.data.experimental_curve_real.setData(self.data.frequency, self.data.epsilon.real)
self.data.experimental_curve_imag.setData(self.data.frequency, self.data.epsilon.imag) self.data.experimental_curve_imag.setData(self.data.frequency, self.data.epsilon.imag)
@ -535,11 +497,11 @@ class AppWindow(QMainWindow):
# print "funcs > 0:",self.data.frequency_fit, self.data.epsilon_fit # print "funcs > 0:",self.data.frequency_fit, self.data.epsilon_fit
self.data.model_curve_real.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.real) self.data.model_curve_real.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.real)
self.data.model_curve_imag.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.imag) self.data.model_curve_imag.setData(x=self.data.frequency_fit, y=self.data.epsilon_fit.imag)
else: # else:
self.data.model_curve_real.setData(x=np.array([np.nan]), y=np.array([np.nan])) # self.data.model_curve_real.setData(x=np.array([np.nan]), y=np.array([np.nan]))
self.data.model_curve_imag.setData(x=np.array([np.nan]), y=np.array([np.nan])) # self.data.model_curve_imag.setData(x=np.array([np.nan]), y=np.array([np.nan]))
@pyqtSlot(object, object)
def updateIntermediatePlot(self, freq, intermediate_data): def updateIntermediatePlot(self, freq, intermediate_data):
self.data.model_curve_real.setData(freq, intermediate_data[0]) self.data.model_curve_real.setData(freq, intermediate_data[0])
self.data.model_curve_imag.setData(freq, intermediate_data[1]) self.data.model_curve_imag.setData(freq, intermediate_data[1])
@ -570,6 +532,7 @@ class AppWindow(QMainWindow):
def sigint_handler(*args): def sigint_handler(*args):
""" """
Handler for the SIGINT signal (CTRL + C). Handler for the SIGINT signal (CTRL + C).
Does this really work?
""" """
sys.stderr.write('\r') sys.stderr.write('\r')
if QMessageBox.question(None, '', "Are you sure you want to quit?", if QMessageBox.question(None, '', "Are you sure you want to quit?",

View File

@ -2,8 +2,7 @@
# Form implementation generated from reading ui file 'ui/PeakGroupBox.ui' # Form implementation generated from reading ui file 'ui/PeakGroupBox.ui'
# #
# Created: Wed Sep 24 21:21:48 2014 # Created by: PyQt4 UI code generator 4.11.4
# by: PyQt4 UI code generator 4.11.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -27,13 +26,13 @@ class Ui_PeakGroupBox(object):
def setupUi(self, PeakGroupBox): def setupUi(self, PeakGroupBox):
PeakGroupBox.setObjectName(_fromUtf8("PeakGroupBox")) PeakGroupBox.setObjectName(_fromUtf8("PeakGroupBox"))
PeakGroupBox.setEnabled(True) PeakGroupBox.setEnabled(True)
PeakGroupBox.resize(269, 179) PeakGroupBox.resize(269, 218)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(PeakGroupBox.sizePolicy().hasHeightForWidth()) sizePolicy.setHeightForWidth(PeakGroupBox.sizePolicy().hasHeightForWidth())
PeakGroupBox.setSizePolicy(sizePolicy) PeakGroupBox.setSizePolicy(sizePolicy)
PeakGroupBox.setMinimumSize(QtCore.QSize(0, 0)) PeakGroupBox.setMinimumSize(QtCore.QSize(269, 0))
PeakGroupBox.setAutoFillBackground(False) PeakGroupBox.setAutoFillBackground(False)
PeakGroupBox.setFlat(False) PeakGroupBox.setFlat(False)
PeakGroupBox.setCheckable(False) PeakGroupBox.setCheckable(False)
@ -42,8 +41,8 @@ class Ui_PeakGroupBox(object):
self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2"))
self.gridLayout = QtGui.QGridLayout() self.gridLayout = QtGui.QGridLayout()
self.gridLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) self.gridLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize)
self.gridLayout.setSpacing(1)
self.gridLayout.setContentsMargins(0, 0, -1, -1) self.gridLayout.setContentsMargins(0, 0, -1, -1)
self.gridLayout.setSpacing(1)
self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
self.label = QtGui.QLabel(PeakGroupBox) self.label = QtGui.QLabel(PeakGroupBox)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum)

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>269</width> <width>269</width>
<height>179</height> <height>218</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -21,7 +21,7 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>269</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>

View File

@ -2,8 +2,7 @@
# Form implementation generated from reading ui file 'ui/QDSMain.ui' # Form implementation generated from reading ui file 'ui/QDSMain.ui'
# #
# Created: Fri Jan 9 21:17:26 2015 # Created by: PyQt4 UI code generator 4.11.4
# by: PyQt4 UI code generator 4.11.3
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -26,7 +25,7 @@ except AttributeError:
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow")) MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(956, 699) MainWindow.resize(956, 687)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Maximum)
sizePolicy.setHorizontalStretch(0) sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0) sizePolicy.setVerticalStretch(0)
@ -40,6 +39,7 @@ class Ui_MainWindow(object):
self.centralwidget.setSizePolicy(sizePolicy) self.centralwidget.setSizePolicy(sizePolicy)
self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
self.verticalLayout.setMargin(0)
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
self.splitter = QtGui.QSplitter(self.centralwidget) self.splitter = QtGui.QSplitter(self.centralwidget)
self.splitter.setOrientation(QtCore.Qt.Horizontal) self.splitter.setOrientation(QtCore.Qt.Horizontal)
@ -63,12 +63,16 @@ class Ui_MainWindow(object):
self.verticalLayout.addWidget(self.splitter) 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, 30))
self.menubar.setObjectName(_fromUtf8("menubar")) self.menubar.setObjectName(_fromUtf8("menubar"))
self.menuExtras = QtGui.QMenu(self.menubar) self.menuExtras = QtGui.QMenu(self.menubar)
self.menuExtras.setObjectName(_fromUtf8("menuExtras")) self.menuExtras.setObjectName(_fromUtf8("menuExtras"))
self.menuConfiguration = QtGui.QMenu(self.menubar) self.menuConfiguration = QtGui.QMenu(self.menubar)
self.menuConfiguration.setObjectName(_fromUtf8("menuConfiguration")) self.menuConfiguration.setObjectName(_fromUtf8("menuConfiguration"))
self.fileMenu = QtGui.QMenu(self.menubar)
self.fileMenu.setObjectName(_fromUtf8("fileMenu"))
self.menuStandard_Fits = QtGui.QMenu(self.menubar)
self.menuStandard_Fits.setObjectName(_fromUtf8("menuStandard_Fits"))
MainWindow.setMenuBar(self.menubar) MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow) self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar")) self.statusbar.setObjectName(_fromUtf8("statusbar"))
@ -83,6 +87,18 @@ class Ui_MainWindow(object):
self.dockWidget_3.setObjectName(_fromUtf8("dockWidget_3")) self.dockWidget_3.setObjectName(_fromUtf8("dockWidget_3"))
self.dockWidgetContents_4 = QtGui.QWidget() self.dockWidgetContents_4 = QtGui.QWidget()
self.dockWidgetContents_4.setObjectName(_fromUtf8("dockWidgetContents_4")) self.dockWidgetContents_4.setObjectName(_fromUtf8("dockWidgetContents_4"))
self.verticalLayout_2 = QtGui.QVBoxLayout(self.dockWidgetContents_4)
self.verticalLayout_2.setMargin(0)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
self.scrollArea = QtGui.QScrollArea(self.dockWidgetContents_4)
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
self.scrollAreaWidgetContents = QtGui.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 82, 512))
self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.verticalLayout_2.addWidget(self.scrollArea)
self.dockWidget_3.setWidget(self.dockWidgetContents_4) self.dockWidget_3.setWidget(self.dockWidgetContents_4)
MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget_3) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.dockWidget_3)
self.actionAdd_Peak = QtGui.QAction(MainWindow) self.actionAdd_Peak = QtGui.QAction(MainWindow)
@ -130,7 +146,30 @@ class Ui_MainWindow(object):
icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/append_save_fit.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon6.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/append_save_fit.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionAppend_Fit.setIcon(icon6) self.actionAppend_Fit.setIcon(icon6)
self.actionAppend_Fit.setObjectName(_fromUtf8("actionAppend_Fit")) self.actionAppend_Fit.setObjectName(_fromUtf8("actionAppend_Fit"))
self.action_openFile = QtGui.QAction(MainWindow)
self.action_openFile.setObjectName(_fromUtf8("action_openFile"))
self.action_nextFile = QtGui.QAction(MainWindow)
self.action_nextFile.setObjectName(_fromUtf8("action_nextFile"))
self.action_previousFile = QtGui.QAction(MainWindow)
self.action_previousFile.setObjectName(_fromUtf8("action_previousFile"))
self.action_saveFile = QtGui.QAction(MainWindow)
self.action_saveFile.setObjectName(_fromUtf8("action_saveFile"))
self.action_fit_lm = QtGui.QAction(MainWindow)
self.action_fit_lm.setObjectName(_fromUtf8("action_fit_lm"))
self.action_NLS_imag = QtGui.QAction(MainWindow)
self.action_NLS_imag.setObjectName(_fromUtf8("action_NLS_imag"))
self.actionSimulated_Annealing = QtGui.QAction(MainWindow)
self.actionSimulated_Annealing.setObjectName(_fromUtf8("actionSimulated_Annealing"))
self.menuExtras.addAction(self.actionShow_Derivative) self.menuExtras.addAction(self.actionShow_Derivative)
self.fileMenu.addAction(self.action_openFile)
self.fileMenu.addAction(self.action_nextFile)
self.fileMenu.addAction(self.action_previousFile)
self.fileMenu.addAction(self.action_saveFile)
self.menuStandard_Fits.addAction(self.action_fit_lm)
self.menuStandard_Fits.addAction(self.action_NLS_imag)
self.menuStandard_Fits.addAction(self.actionSimulated_Annealing)
self.menubar.addAction(self.fileMenu.menuAction())
self.menubar.addAction(self.menuStandard_Fits.menuAction())
self.menubar.addAction(self.menuExtras.menuAction()) self.menubar.addAction(self.menuExtras.menuAction())
self.menubar.addAction(self.menuConfiguration.menuAction()) self.menubar.addAction(self.menuConfiguration.menuAction())
self.toolBar.addAction(self.actionAdd_Peak) self.toolBar.addAction(self.actionAdd_Peak)
@ -152,16 +191,22 @@ class Ui_MainWindow(object):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None)) MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.menuExtras.setTitle(_translate("MainWindow", "Extras", None)) self.menuExtras.setTitle(_translate("MainWindow", "Extras", None))
self.menuConfiguration.setTitle(_translate("MainWindow", "Configuration", None)) self.menuConfiguration.setTitle(_translate("MainWindow", "Configuration", None))
self.fileMenu.setTitle(_translate("MainWindow", "File", None))
self.menuStandard_Fits.setTitle(_translate("MainWindow", "Standard Fits", None))
self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None)) self.toolBar.setWindowTitle(_translate("MainWindow", "toolBar", None))
self.actionAdd_Peak.setText(_translate("MainWindow", "Add Peak", None)) self.actionAdd_Peak.setText(_translate("MainWindow", "Add Peak", None))
self.actionAdd_Peak.setShortcut(_translate("MainWindow", "Alt+1", None))
self.actionAdd_Cond.setText(_translate("MainWindow", "Add Cond.", None)) self.actionAdd_Cond.setText(_translate("MainWindow", "Add Cond.", None))
self.actionAdd_Cond.setToolTip(_translate("MainWindow", "Added Conductivity Term", None)) self.actionAdd_Cond.setToolTip(_translate("MainWindow", "Added Conductivity Term", None))
self.actionAdd_Cond.setShortcut(_translate("MainWindow", "Alt+2", None))
self.actionSave_FitResult.setText(_translate("MainWindow", "Save Fit", None)) self.actionSave_FitResult.setText(_translate("MainWindow", "Save Fit", None))
self.actionSave_FitResult.setToolTip(_translate("MainWindow", "Save Fit Result", None)) self.actionSave_FitResult.setToolTip(_translate("MainWindow", "Save Fit Result", None))
self.actionAdd_PowerLaw.setText(_translate("MainWindow", "Add Power Law", None)) self.actionAdd_PowerLaw.setText(_translate("MainWindow", "Add Power Law", None))
self.actionAdd_PowerLaw.setToolTip(_translate("MainWindow", "Add (complex) Power Law", None)) self.actionAdd_PowerLaw.setToolTip(_translate("MainWindow", "Add (complex) Power Law", None))
self.actionAdd_PowerLaw.setShortcut(_translate("MainWindow", "Alt+3", None))
self.actionAdd_Eps_Infty.setText(_translate("MainWindow", "Add e_infty", None)) self.actionAdd_Eps_Infty.setText(_translate("MainWindow", "Add e_infty", None))
self.actionAdd_Eps_Infty.setToolTip(_translate("MainWindow", "Add eps_infty", None)) self.actionAdd_Eps_Infty.setToolTip(_translate("MainWindow", "Add eps_infty", None))
self.actionAdd_Eps_Infty.setShortcut(_translate("MainWindow", "Alt+4", None))
self.actionYAFF.setText(_translate("MainWindow", "YAFF", None)) self.actionYAFF.setText(_translate("MainWindow", "YAFF", None))
self.actionYAFF.setToolTip(_translate("MainWindow", "Fit with YAFF", None)) self.actionYAFF.setToolTip(_translate("MainWindow", "Fit with YAFF", None))
self.actionActionAbortFit.setText(_translate("MainWindow", "Abort Fit", None)) self.actionActionAbortFit.setText(_translate("MainWindow", "Abort Fit", None))
@ -169,6 +214,19 @@ class Ui_MainWindow(object):
self.actionShow_Derivative.setText(_translate("MainWindow", "Show Derivative", None)) self.actionShow_Derivative.setText(_translate("MainWindow", "Show Derivative", None))
self.actionAppend_Fit.setText(_translate("MainWindow", "Append Fit", None)) self.actionAppend_Fit.setText(_translate("MainWindow", "Append Fit", None))
self.actionAppend_Fit.setToolTip(_translate("MainWindow", "Appends current plot to existing plot.", None)) self.actionAppend_Fit.setToolTip(_translate("MainWindow", "Appends current plot to existing plot.", None))
self.action_openFile.setText(_translate("MainWindow", "&Open", None))
self.action_openFile.setShortcut(_translate("MainWindow", "Ctrl+O", None))
self.action_nextFile.setText(_translate("MainWindow", "Next", None))
self.action_nextFile.setShortcut(_translate("MainWindow", "Ctrl+K", None))
self.action_previousFile.setText(_translate("MainWindow", "Previous", None))
self.action_previousFile.setShortcut(_translate("MainWindow", "Ctrl+J", None))
self.action_saveFile.setText(_translate("MainWindow", "&Save Fit Result (Data)", None))
self.action_saveFile.setShortcut(_translate("MainWindow", "Ctrl+S", None))
self.action_fit_lm.setText(_translate("MainWindow", "Complex NLS", None))
self.action_fit_lm.setShortcut(_translate("MainWindow", "Ctrl+F", None))
self.action_NLS_imag.setText(_translate("MainWindow", "NLS (Imag.)", None))
self.action_NLS_imag.setShortcut(_translate("MainWindow", "Ctrl+Shift+F", None))
self.actionSimulated_Annealing.setText(_translate("MainWindow", "Simulated Annealing", None))
from pyqtgraph import PlotWidget from pyqtgraph import PlotWidget
import images_rc import images_rc

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>956</width> <width>956</width>
<height>699</height> <height>687</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -27,6 +27,9 @@
</sizepolicy> </sizepolicy>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="margin">
<number>0</number>
</property>
<item> <item>
<widget class="QSplitter" name="splitter"> <widget class="QSplitter" name="splitter">
<property name="orientation"> <property name="orientation">
@ -64,7 +67,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>956</width> <width>956</width>
<height>22</height> <height>30</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuExtras"> <widget class="QMenu" name="menuExtras">
@ -78,6 +81,25 @@
<string>Configuration</string> <string>Configuration</string>
</property> </property>
</widget> </widget>
<widget class="QMenu" name="fileMenu">
<property name="title">
<string>File</string>
</property>
<addaction name="action_openFile"/>
<addaction name="action_nextFile"/>
<addaction name="action_previousFile"/>
<addaction name="action_saveFile"/>
</widget>
<widget class="QMenu" name="menuStandard_Fits">
<property name="title">
<string>Standard Fits</string>
</property>
<addaction name="action_fit_lm"/>
<addaction name="action_NLS_imag"/>
<addaction name="actionSimulated_Annealing"/>
</widget>
<addaction name="fileMenu"/>
<addaction name="menuStandard_Fits"/>
<addaction name="menuExtras"/> <addaction name="menuExtras"/>
<addaction name="menuConfiguration"/> <addaction name="menuConfiguration"/>
</widget> </widget>
@ -120,7 +142,33 @@
<attribute name="dockWidgetArea"> <attribute name="dockWidgetArea">
<number>1</number> <number>1</number>
</attribute> </attribute>
<widget class="QWidget" name="dockWidgetContents_4"/> <widget class="QWidget" name="dockWidgetContents_4">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>82</width>
<height>512</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
</widget> </widget>
<action name="actionAdd_Peak"> <action name="actionAdd_Peak">
<property name="checkable"> <property name="checkable">
@ -133,6 +181,9 @@
<property name="text"> <property name="text">
<string>Add Peak</string> <string>Add Peak</string>
</property> </property>
<property name="shortcut">
<string>Alt+1</string>
</property>
</action> </action>
<action name="actionAdd_Cond"> <action name="actionAdd_Cond">
<property name="checkable"> <property name="checkable">
@ -148,6 +199,9 @@
<property name="toolTip"> <property name="toolTip">
<string>Added Conductivity Term</string> <string>Added Conductivity Term</string>
</property> </property>
<property name="shortcut">
<string>Alt+2</string>
</property>
</action> </action>
<action name="actionSave_FitResult"> <action name="actionSave_FitResult">
<property name="icon"> <property name="icon">
@ -175,6 +229,9 @@
<property name="toolTip"> <property name="toolTip">
<string>Add (complex) Power Law</string> <string>Add (complex) Power Law</string>
</property> </property>
<property name="shortcut">
<string>Alt+3</string>
</property>
</action> </action>
<action name="actionAdd_Eps_Infty"> <action name="actionAdd_Eps_Infty">
<property name="checkable"> <property name="checkable">
@ -190,6 +247,9 @@
<property name="toolTip"> <property name="toolTip">
<string>Add eps_infty</string> <string>Add eps_infty</string>
</property> </property>
<property name="shortcut">
<string>Alt+4</string>
</property>
</action> </action>
<action name="actionYAFF"> <action name="actionYAFF">
<property name="checkable"> <property name="checkable">
@ -235,6 +295,59 @@
<string>Appends current plot to existing plot.</string> <string>Appends current plot to existing plot.</string>
</property> </property>
</action> </action>
<action name="action_openFile">
<property name="text">
<string>&amp;Open</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="action_nextFile">
<property name="text">
<string>Next</string>
</property>
<property name="shortcut">
<string>Ctrl+K</string>
</property>
</action>
<action name="action_previousFile">
<property name="text">
<string>Previous</string>
</property>
<property name="shortcut">
<string>Ctrl+J</string>
</property>
</action>
<action name="action_saveFile">
<property name="text">
<string>&amp;Save Fit Result (Data)</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="action_fit_lm">
<property name="text">
<string>Complex NLS</string>
</property>
<property name="shortcut">
<string>Ctrl+F</string>
</property>
</action>
<action name="action_NLS_imag">
<property name="text">
<string>NLS (Imag.)</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+F</string>
</property>
</action>
<action name="actionSimulated_Annealing">
<property name="text">
<string>Simulated Annealing</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

View File

@ -2,8 +2,7 @@
# Form implementation generated from reading ui file 'ui/YAFFparameters.ui' # Form implementation generated from reading ui file 'ui/YAFFparameters.ui'
# #
# Created: Wed Sep 24 21:21:48 2014 # Created by: PyQt4 UI code generator 4.11.4
# by: PyQt4 UI code generator 4.11.1
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!