further reorganization

This commit is contained in:
Markus Rosenstihl 2015-01-08 13:18:45 +01:00
parent 21a93d6d09
commit 53234a2af8
16 changed files with 367 additions and 78 deletions

View File

@ -3,10 +3,10 @@ MAKEFLAGS+="-j 4"
###### EDIT ##################### ###### EDIT #####################
#Directory with ui and resource files #Directory with ui and resource files
RESOURCE_DIR = gui RESOURCE_DIR = ui
#Directory for compiled resources #Directory for compiled resources
COMPILED_DIR = gui COMPILED_DIR = ui
#UI files to compile #UI files to compile
UI_FILES = *.ui UI_FILES = *.ui
@ -30,7 +30,7 @@ ui : $(COMPILED_UI)
$(COMPILED_DIR)/%.py : $(RESOURCE_DIR)/%.ui $(COMPILED_DIR)/%.py : $(RESOURCE_DIR)/%.ui
pyuic4 $< -o $@ pyuic4 $< -o $@
$(COMPILED_DIR)/%_rc.py : $(RESOURCE_DIR)/icons/%.qrc $(COMPILED_DIR)/$(RESOURCE_DIR)/%_rc.py : $(RESOURCE_DIR)/icons/%.qrc
pyrcc4 $< -o $@ pyrcc4 $< -o $@
clean : clean :

View File

@ -11,8 +11,6 @@ from container_base import BaseContainer
import gui.container_widgets import gui.container_widgets
__author__ = 'markusro' __author__ = 'markusro'
@ -44,7 +42,6 @@ class PowerComplex(BaseContainer):
self.param_number = 2 self.param_number = 2
def function( self, p, x ): def function( self, p, x ):
BaseContainer.function(self, 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
@ -62,7 +59,6 @@ class Static(BaseContainer):
self.param_number = 1 self.param_number = 1
def function( self, p, x ): def function( self, p, x ):
BaseContainer.function(self, 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
@ -82,7 +78,6 @@ class Peak(BaseContainer):
self.param_number = 4 self.param_number = 4
def function( self, p, x ): def function( self, p, x ):
BaseContainer.function(self, p, x)
eps, t, a, b = p eps, t, a, b = p
om = 2*np.pi*x om = 2*np.pi*x
hn = eps/(1+(1j*om*t)**a)**b hn = eps/(1+(1j*om*t)**a)**b
@ -124,7 +119,6 @@ class YAFF(BaseContainer):
self.update_data() self.update_data()
def function( self, p, x ): def function( self, p, x ):
BaseContainer.function(self, p, x)
ya = self._libyaff.loss(p, x) ya = self._libyaff.loss(p, x)
cplx = np.array([ya.imag, ya.real]) cplx = np.array([ya.imag, ya.real])
return cplx return cplx

View File

@ -3,24 +3,30 @@ from PyQt4.QtGui import QColor
import numpy as np import numpy as np
import pyqtgraph as pg import pyqtgraph as pg
__author__ = 'markusro' __author__ = 'markusro'
class BaseContainer(QObject): class BaseContainer(QObject):
"""
This class provides placeholders (or default) methods for "container" objects.
These objects are basically the different fit elements for dielectric spectroscopy.
"""
# TODO generalize the base class so that we can use plugins (self-contained fit functions)
changedData = pyqtSignal() changedData = pyqtSignal()
removeObj = pyqtSignal(QObject) removeObj = pyqtSignal(QObject)
def __init__(self, plt_real=None, plt_imag=None, limits=None): def __init__( self, plt_real=None, plt_imag=None, limits=None ):
super(BaseContainer, self).__init__() super(BaseContainer, self).__init__()
myPen = pg.mkPen( style=Qt.DotLine, myPen = pg.mkPen(style=Qt.DotLine,
width=2.5) width=2.5)
self.data_curve_real = pg.PlotDataItem(x=np.array([np.nan]),y=np.array([np.nan]), pen=myPen) self.data_curve_real = pg.PlotDataItem(x=np.array([np.nan]), y=np.array([np.nan]), pen=myPen)
self.plt_real = plt_real self.plt_real = plt_real
self.plt_real.addItem(self.data_curve_real) self.plt_real.addItem(self.data_curve_real)
self.data_curve_imag = pg.PlotDataItem(x=np.array([np.nan]),y=np.array([np.nan]), pen=myPen) self.data_curve_imag = pg.PlotDataItem(x=np.array([np.nan]), y=np.array([np.nan]), pen=myPen)
self.plt_imag = plt_imag self.plt_imag = plt_imag
self.plt_imag.addItem(self.data_curve_imag) self.plt_imag.addItem(self.data_curve_imag)
@ -41,65 +47,63 @@ class BaseContainer(QObject):
self._param_number = 0 self._param_number = 0
self._abort = False self._abort = False
def set_limits(self, limits): def set_limits( self, limits ):
self.limits = limits self.limits = limits
self.update_data() self.update_data()
@pyqtSlot(bool) @pyqtSlot(bool)
def abort(self, abort=False): def abort( self, abort=False ):
self._abort = abort self._abort = abort
@property @property
def param_number(self): def param_number( self ):
return self._param_number return self._param_number
@param_number.setter @param_number.setter
def param_number(self, num): def param_number( self, num ):
self._param_number = num self._param_number = num
@property @property
def id_string(self): def id_string( self ):
return self._id_string return self._id_string
@id_string.setter @id_string.setter
def id_string(self, id): def id_string( self, id ):
#self._func = self.functions.get_function(id) # self._func = self.functions.get_function(id)
self._id_string = id self._id_string = id
@property @property
def id_label(self): def id_label( self ):
return self._id_label return self._id_label
@id_label.setter @id_label.setter
def id_label(self, id): def id_label( self, id ):
#self._func = self.functions.get_function(id) self._id_label = id
self._func = self.function
self._id_label = id
@property @property
def color(self): def color( self ):
return self._color return self._color
@color.setter @color.setter
def color(self, c): def color( self, c ):
self._color = c self._color = c
self.data_curve_real.setPen(color=c, style=Qt.DotLine, width=2.5) self.data_curve_real.setPen(color=c, style=Qt.DotLine, width=2.5)
self.data_curve_imag.setPen(color=c, style=Qt.DotLine, width=2.5) self.data_curve_imag.setPen(color=c, style=Qt.DotLine, width=2.5)
@property @property
def widget(self): def widget( self ):
return self._widget return self._widget
@widget.setter @widget.setter
def widget(self, wdgt): def widget( self, wdgt ):
self._widget = wdgt self._widget = wdgt
self._widget.changedTable.connect(self.update_data) # TODO better to use self.setParameter self._widget.changedTable.connect(self.update_data) # TODO better to use self.setParameter
self.removeObj.connect(self._widget.deleteLater) self.removeObj.connect(self._widget.deleteLater)
self._widget.removeMe.connect(self.removeMe) self._widget.removeMe.connect(self.removeMe)
def get_parameter( self ): def get_parameter( self ):
p = self.widget.getTable() # TODO ugly ... should return self._beta etc ...? p = self.widget.getTable() # TODO ugly ... should return self._beta etc ...?
return p return p
def get_fixed( self ): def get_fixed( self ):
@ -107,15 +111,15 @@ class BaseContainer(QObject):
return p return p
def set_parameter( self, beta, sd_beta=None ): def set_parameter( self, beta, sd_beta=None ):
self._beta = beta self._beta = beta
self._sd_beta = sd_beta self._sd_beta = sd_beta
self.widget.update_table(beta, sd_beta) self.widget.update_table(beta, sd_beta)
self.update_data() self.update_data()
def get_data(self): def get_data( self ):
return self._frequency, self._data return self._frequency, self._data
def removeMe(self): def removeMe( self ):
self.plt_imag.removeItem(self.data_curve_imag) self.plt_imag.removeItem(self.data_curve_imag)
self.plt_real.removeItem(self.data_curve_real) self.plt_real.removeItem(self.data_curve_real)
self.removeObj.emit(self) self.removeObj.emit(self)
@ -123,20 +127,27 @@ class BaseContainer(QObject):
def update_data( self ): def update_data( self ):
self._frequency = np.logspace(np.log10(self.limits[0]), np.log10(self.limits[1]), 256) self._frequency = np.logspace(np.log10(self.limits[0]), np.log10(self.limits[1]), 256)
self._data = self._func(self.get_parameter(), self._frequency) self._data = self.function(self.get_parameter(), self._frequency)
self.data_curve_real.setData(x=self._frequency, y=self._data[0]) self.data_curve_real.setData(x=self._frequency, y=self._data[0])
self.data_curve_imag.setData(x=self._frequency, y=self._data[1]) self.data_curve_imag.setData(x=self._frequency, y=self._data[1])
self.changedData.emit() self.changedData.emit()
def resampleData(self, x): def resampleData( self, x ):
data = self._func(self.get_parameter(), x) data = self.function(self.get_parameter(), x)
return np.array([x,data[0],data[1]]).T return np.array([x, data[0], data[1]]).T
def subtractMe(self, flag):
print "subtract"
self._data = -self._data
self.changedData.emit()
def clear_data( self ): def clear_data( self ):
self.data_curve_real.setData(x=[np.nan], y=[np.nan]) self.data_curve_real.setData(x=[np.nan], y=[np.nan])
self.data_curve_imag.setData(x=[np.nan], y=[np.nan]) self.data_curve_imag.setData(x=[np.nan], y=[np.nan])
def function(self,p,x): def function( self, p, x ):
if self._abort: raise StopIteration if self._abort:
#raise NotImplementedError, "This needs to be implemented in your subclass" raise StopIteration
raise NotImplementedError, "This needs to be implemented in your subclass"

21
data/data.py Normal file
View File

@ -0,0 +1,21 @@
from PyQt4.QtCore import QObject, pyqtSignal
__author__ = 'markusro'
class Daten(QObject):
data_changed_signal = pyqtSignal(list, list, list)
def __init__(self, x=None, y_real=None, y_imag=None):
super(Daten, self).__init__(None)
self._data = (x, y_real, y_imag)
def get_data(self):
return self._data
def set_data(self, x, y_real, y_imag):
if len(x) == len(y_real) == len(y_imag):
self._data = (x, y_real, y_imag)
self.data_changed_signal.emit(list(x), list(y_real), list(y_imag))
else:
raise AttributeError("Inhomogeneous data size x,real,imag: %i,%i,%i"(len(x), len(y_real), len(y_imag)))

View File

@ -16,7 +16,7 @@ class Data:
myPen_real = pg.mkPen(width=2.5, color=(51, 255, 127)) myPen_real = pg.mkPen(width=2.5, color=(51, 255, 127))
self.experimental_curve_imag = pg.PlotDataItem(x=[np.nan], y=[np.nan], self.experimental_curve_imag = pg.PlotDataItem(x=[np.nan], y=[np.nan],
pen=QColor(0, 0, 0, 0), pen=None,
symbol='o', symbol='o',
symbolBrush=(255, 127, 0, 127)) symbolBrush=(255, 127, 0, 127))
self.experimental_curve_real = pg.PlotDataItem(x=[np.nan], y=[np.nan], self.experimental_curve_real = pg.PlotDataItem(x=[np.nan], y=[np.nan],

View File

@ -48,7 +48,7 @@ class LogFSpinBox(QDoubleSpinBox):
class BaseWidget(QGroupBox): class BaseWidget(QGroupBox):
changedTable = pyqtSignal() changedTable = pyqtSignal()
removeMe = pyqtSignal() removeMe = pyqtSignal()
subtract = pyqtSignal() subtract = pyqtSignal(bool)
def __init__(self, parent=None): def __init__(self, parent=None):
super(BaseWidget, self).__init__(parent) super(BaseWidget, self).__init__(parent)
@ -56,6 +56,7 @@ class BaseWidget(QGroupBox):
self.inputs = [] self.inputs = []
self.errors = [] self.errors = []
self.names = [] self.names = []
self._subtracted = False
self.selector_mask = None # TODO: clean up self.selector_mask = None # TODO: clean up
self.func_type="None" self.func_type="None"
@ -63,7 +64,9 @@ class BaseWidget(QGroupBox):
self.removeMe.emit() self.removeMe.emit()
def subtract(self): def subtract(self):
self.subtract.emit() self.subtract.emit(self._subtracted)
self._subtracted = not self._subtracted # Toggle state
def change_values( self, num ): def change_values( self, num ):
self.changedTable.emit() self.changedTable.emit()
@ -317,7 +320,8 @@ class ConductivityWidget(BaseWidget, QGroupBox):
self.ui.gridLayout.addWidget(self.ui.rSigma,2,1) self.ui.gridLayout.addWidget(self.ui.rSigma,2,1)
self.ui.removeButton.clicked.connect(self.remove) self.ui.removeButton.clicked.connect(self.remove)
#self.ui.subtractConductivityButton.connect(self.subtract) self.ui.pushButton_hide.clicked.connect(self.subtract)
self.func_type="Cond." self.func_type="Cond."
self.names = [ self.names = [
@ -355,6 +359,7 @@ class PowerLawWidget(BaseWidget):
self.ui.doubleSpinBox_2 = LogFSpinBox(self) self.ui.doubleSpinBox_2 = LogFSpinBox(self)
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1) self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1)
self.ui.removeButton.clicked.connect(self.remove) self.ui.removeButton.clicked.connect(self.remove)
self.ui.pushButton_hide.toggled.connect(self.subtract)
self.func_type="Power Law" self.func_type="Power Law"
self.names = ["Amp", "pwrAmp"] self.names = ["Amp", "pwrAmp"]

83
gui/graphs.py Normal file
View File

@ -0,0 +1,83 @@
# coding=utf-8
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtGui import QColor
from data.data import Daten
from libmath.function_library import ModelFunction
__author__ = 'markusro'
import pyqtgraph as pg
class Graph(object):
def __init__(self,x = None, y = None):
super(Graph, self).__init__(self)
print "Graph"
self._pen = pg.mkPen(color="w", width=2.0, style=3)
self.graph_real = pg.PlotDataItem(x=x, y=y, pen=self._pen)
self.graph_imag = pg.PlotDataItem(x=x, y=y, pen=self._pen)
@property
def color(self):
return self._pen.color()
@color.setter
def color(self, c):
self._pen.setColor(c)
@property
def style(self):
return self._pen.style()
@style.setter
def style(self, s):
self._pen.setStyle(s)
@property
def width(self):
return self._pen.width()
@width.setter
def width(self, w):
self._pen.setWidth(w)
def set_symbol(self, s):
for gr in self.graph_real, self.graph_imag:
gr.setSymbol(s)
gr.setStyle(0)
def update_graph_data(self, x, y_real, y_imag):
"""
Update Graph data.
@param x:
@param y_real:
@param y_imag:
"""
self.graph_real.setData(x, y_real)
self.graph_imag.setData(x, y_imag)
class DataGraph(Graph):
def __init__(self):
super(DataGraph, self).__init__()
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_imag = pg.PlotDataItem(x=x, y=y, pen=self._pen, symbol="o", symbolBrush=(255, 127, 0, 127))
class GraphObject(Graph, Daten, ModelFunction):
parameter_changed_signal = pyqtSignal(list)
def __init__(self):
super(GraphObject, self).__init__(self)
self.data_changed_signal.connect(self.update_graph_data)
def update(self, x, p):
if self.model is not None:
_x, ry, iy = self.model.calculate(x, p)
self.set_data(_x, ry, iy)
self.parameter_changed_signal.emit(list(p))
else:
print "doing nothing"
pass

View File

@ -255,7 +255,7 @@ class Functions(QObject):
cplx = np.array([ya.imag, ya.real]) cplx = np.array([ya.imag, ya.real])
return cplx return cplx
def get( self, name ): def get_name( self, name ):
return self.list[name] return self.list[name]
def get_function( self, name ): def get_function( self, name ):

141
libmath/function_library.py Normal file
View File

@ -0,0 +1,141 @@
# coding=utf-8
import warnings
import numpy as np
import yafflib
__author__ = 'markusro'
class Function(object):
def __init__(self):
super(Function, self).__init__()
self._id_string = None
self._num_parameters = None
self._pretty_name = ""
self._function = None
def get_id_string(cls):
if cls._id_string is None:
raise NotImplementedError("You need to set the id_string")
return cls._id_string
def set_id_string(cls, s):
cls._id_string = s
def get_num_paramters(cls):
if cls._num_paramters is None:
raise NotImplementedError("You need to set the num_paramters")
return cls._num_paramters
def set_num_paramters(cls, s):
cls._num_paramters = s
def get_function(cls):
if cls._function is None:
raise NotImplementedError("You need to set f")
return cls._function
def set_function(cls, f):
cls._function = f
def calculate(self, x, p):
if self._function is None: raise NotImplementedError("You need to set f")
data = self._function(x, p)
return x,data[0],data[1]
class HavNegCmplx(Function):
def __init__(self):
super(HavNegCmplx, self).__init__()
self.set_function(hn)
self.set_id_string("hn")
self.set_num_paramters(4)
def hn(x, p):
om = 2*np.pi*x
#hn = om*1j
eps, t, a, b = p
h_n = eps/(1+(1j*om*t)**a)**b
cplx = np.array([h_n.real, -h_n.imag])
return cplx
class ConductivityCmplx(Function):
def __init__(self):
super(ConductivityCmplx, self).__init__()
self.set_num_paramters(3)
self.set_function(cond_cmplx)
self.set_id_string("conductivity")
def cond_cmplx(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
cplx = np.array([cond.real, -cond.imag])
return cplx
class PowerCmplx(Function):
def __init__(self):
super(PowerCmplx, self).__init__()
self.set_function(power_cmplx)
self.set_num_paramters(2)
self.set_id_string("power_law")
def power_cmplx( p, x ):
om = 2*np.pi*x
sgma, n = p
power = sgma/(om*1j)**n
cplx = np.array([power.real, -power.imag])
return cplx
class EpsInftyCmplx(Function):
def __init__(self):
super(EpsInftyCmplx, self).__init__()
self.set_function(static_cmplx)
self.set_id_string("e_inf")
self.set_num_paramters(1)
def static_cmplx(p, x ):
eps_inf = p[0]
static = np.ones((2, x.size))*eps_inf
static[1, :] *= 0 # set imag part zero
return static
class YaffCmplx(Function):
def __init__(self):
super(YaffCmplx, self).__init__()
self.set_function(yaff)
self.set_id_string("yaff")
self.set_num_paramters(8)
def yaff( p, x ):
#ya = self.YAFF.yaff(p[:8], x)
ya = yafflib.Yaff.yaff(p[:,0], x)
cplx = np.array([ya.imag, ya.real])
return cplx
class ModelFunction(object):
def __init__(self):
super(ModelFunction, self).__init__(self)
self.model = None
@classmethod
def select_model(self, model):
self._functions_avail = ", ".join( cls().get_id_string() for cls in Function.__subclasses__())
for cls in Function.__subclasses__():
if model == cls().get_id_string():
self.model = cls()
return True
warnings.warn("Function not found: %s \n(available functions: %s)"%(model, self._functions_avail))
return False

35
qds.py
View File

@ -76,9 +76,9 @@ class AppWindow(QMainWindow):
# fit boundary signals # fit boundary signals
self.fit_boundary_imag.sigRegionChanged.connect(self._update_fit_boundary_imag) self.fit_boundary_imag.sigRegionChanged.connect(self._update_fit_boundary_imag)
self.fit_boundary_imag.sigRegionChangeFinished.connect(self.updatePlot) self.fit_boundary_imag.sigRegionChangeFinished.connect(self.update_plot)
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.updatePlot) self.fit_boundary_real.sigRegionChangeFinished.connect(self.update_plot)
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)
@ -157,6 +157,10 @@ class AppWindow(QMainWindow):
self.ui.actionShow_Derivative.triggered.connect(self.show_derivative) self.ui.actionShow_Derivative.triggered.connect(self.show_derivative)
self.ui.menuConfiguration.triggered.connect(self.conf)
def conf(self):
pass
def show_derivative( self ): def show_derivative( self ):
self.xtra_wdgt = ExtraDifferentialWidget.DifferentialWidget() self.xtra_wdgt = ExtraDifferentialWidget.DifferentialWidget()
@ -349,7 +353,7 @@ class AppWindow(QMainWindow):
plt_imag=self.ui.pgPlotWidget_imag, plt_imag=self.ui.pgPlotWidget_imag,
limits=self.data.fit_limits) limits=self.data.fit_limits)
_yaff.blockSignals(True) _yaff.blockSignals(True)
_yaff.changedData.connect(self.updatePlot) _yaff.changedData.connect(self.update_plot)
_yaff.removeObj.connect(self.delParamterObject) _yaff.removeObj.connect(self.delParamterObject)
gg_y = 10**pos.y()*2 gg_y = 10**pos.y()*2
gg_x = 1/(10**pos.x()*2*np.pi) gg_x = 1/(10**pos.x()*2*np.pi)
@ -357,7 +361,7 @@ class AppWindow(QMainWindow):
_yaff.set_parameter(beta=yaff_par) _yaff.set_parameter(beta=yaff_par)
self.parameterWidget.add(_yaff.widget) self.parameterWidget.add(_yaff.widget)
self.function_registry.register_function(_yaff) self.function_registry.register_function(_yaff)
self.updatePlot() self.update_plot()
_yaff.blockSignals(False) _yaff.blockSignals(False)
@ -366,13 +370,13 @@ class AppWindow(QMainWindow):
plt_imag=self.ui.pgPlotWidget_imag, plt_imag=self.ui.pgPlotWidget_imag,
limits=self.data.fit_limits) limits=self.data.fit_limits)
_conductivity.blockSignals(True) _conductivity.blockSignals(True)
_conductivity.changedData.connect(self.updatePlot) _conductivity.changedData.connect(self.update_plot)
_conductivity.removeObj.connect(self.delParamterObject) _conductivity.removeObj.connect(self.delParamterObject)
cond_par = [0.0, 10**(pos.y()+pos.x())*2*np.pi, 1.0] cond_par = [0.0, 10**(pos.y()+pos.x())*2*np.pi, 1.0]
_conductivity.set_parameter(beta=cond_par) _conductivity.set_parameter(beta=cond_par)
self.parameterWidget.add(_conductivity.widget) self.parameterWidget.add(_conductivity.widget)
self.function_registry.register_function(_conductivity) self.function_registry.register_function(_conductivity)
self.updatePlot() self.update_plot()
_conductivity.blockSignals(False) _conductivity.blockSignals(False)
@ -380,29 +384,29 @@ class AppWindow(QMainWindow):
_power_complex = PowerComplex(plt_imag=self.ui.pgPlotWidget_imag, _power_complex = PowerComplex(plt_imag=self.ui.pgPlotWidget_imag,
plt_real=self.ui.pgPlotWidget_real, plt_real=self.ui.pgPlotWidget_real,
limits=self.data.fit_limits) limits=self.data.fit_limits)
_power_complex.changedData.connect(self.updatePlot) _power_complex.changedData.connect(self.update_plot)
_power_complex.removeObj.connect(self.delParamterObject) _power_complex.removeObj.connect(self.delParamterObject)
cond_par = [10**(pos.y()+pos.x())*2*np.pi, 1.0] cond_par = [10**(pos.y()+pos.x())*2*np.pi, 1.0]
_power_complex.set_parameter(beta=cond_par) _power_complex.set_parameter(beta=cond_par)
self.parameterWidget.add(_power_complex.widget) self.parameterWidget.add(_power_complex.widget)
self.function_registry.register_function(_power_complex) self.function_registry.register_function(_power_complex)
self.updatePlot() self.update_plot()
def addEpsInfty( self, pos ): def addEpsInfty( self, pos ):
_eps_infty = Static(plt_imag=self.ui.pgPlotWidget_imag, _eps_infty = Static(plt_imag=self.ui.pgPlotWidget_imag,
plt_real=self.ui.pgPlotWidget_real, plt_real=self.ui.pgPlotWidget_real,
limits=self.data.fit_limits) limits=self.data.fit_limits)
_eps_infty.changedData.connect(self.updatePlot) _eps_infty.changedData.connect(self.update_plot)
_eps_infty.removeObj.connect(self.delParamterObject) _eps_infty.removeObj.connect(self.delParamterObject)
cond_par = [10**pos.y()] cond_par = [10**pos.y()]
_eps_infty.set_parameter(beta=cond_par) _eps_infty.set_parameter(beta=cond_par)
self.parameterWidget.add(_eps_infty.widget) self.parameterWidget.add(_eps_infty.widget)
self.function_registry.register_function(_eps_infty) self.function_registry.register_function(_eps_infty)
self.updatePlot() self.update_plot()
def delParamterObject( self, obj ): def delParamterObject( self, obj ):
self.function_registry.unregister_function(obj) self.function_registry.unregister_function(obj)
self.updatePlot() self.update_plot()
def addPeak( self, pos ): def addPeak( self, pos ):
id_list = [key.id_num for key in id_list = [key.id_num for key in
@ -417,12 +421,12 @@ class AppWindow(QMainWindow):
limits=self.data.fit_limits) limits=self.data.fit_limits)
self.function_registry.register_function(_peak) self.function_registry.register_function(_peak)
_peak.changedData.connect(self.updatePlot) _peak.changedData.connect(self.update_plot)
_peak.removeObj.connect(self.delParamterObject) _peak.removeObj.connect(self.delParamterObject)
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]
_peak.set_parameter(beta=new_peak_beta0) _peak.set_parameter(beta=new_peak_beta0)
self.parameterWidget.add(_peak.widget) self.parameterWidget.add(_peak.widget)
self.updatePlot() self.update_plot()
def fitData_start( self, method ): def fitData_start( self, method ):
#fit_methods = [fit_odr_cmplx, fit_odr_imag, fit_lbfgsb, fit_anneal] #fit_methods = [fit_odr_cmplx, fit_odr_imag, fit_lbfgsb, fit_anneal]
@ -532,10 +536,11 @@ class AppWindow(QMainWindow):
#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.updatePlot() self.update_plot()
def updatePlot( self ): def update_plot( self ):
print "redrawing plot"
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)

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'ui/ConductivityGroupBox.ui' # Form implementation generated from reading ui file 'ui/ConductivityGroupBox.ui'
# #
# Created: Wed Sep 24 21:21:48 2014 # Created: Tue Dec 16 15:06:22 2014
# by: PyQt4 UI code generator 4.11.1 # 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 +26,7 @@ except AttributeError:
class Ui_ConductivityGroupBox(object): class Ui_ConductivityGroupBox(object):
def setupUi(self, ConductivityGroupBox): def setupUi(self, ConductivityGroupBox):
ConductivityGroupBox.setObjectName(_fromUtf8("ConductivityGroupBox")) ConductivityGroupBox.setObjectName(_fromUtf8("ConductivityGroupBox"))
ConductivityGroupBox.resize(253, 156) ConductivityGroupBox.resize(253, 158)
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)
@ -113,9 +113,10 @@ class Ui_ConductivityGroupBox(object):
self.rSigma.setSizePolicy(sizePolicy) self.rSigma.setSizePolicy(sizePolicy)
self.rSigma.setObjectName(_fromUtf8("rSigma")) self.rSigma.setObjectName(_fromUtf8("rSigma"))
self.gridLayout.addWidget(self.rSigma, 2, 1, 1, 1) self.gridLayout.addWidget(self.rSigma, 2, 1, 1, 1)
self.subtractConductivityButton = QtGui.QPushButton(ConductivityGroupBox) self.pushButton_hide = QtGui.QPushButton(ConductivityGroupBox)
self.subtractConductivityButton.setObjectName(_fromUtf8("subtractConductivityButton")) self.pushButton_hide.setCheckable(True)
self.gridLayout.addWidget(self.subtractConductivityButton, 0, 2, 1, 1) self.pushButton_hide.setObjectName(_fromUtf8("pushButton_hide"))
self.gridLayout.addWidget(self.pushButton_hide, 0, 2, 1, 1)
self.label_3 = QtGui.QLabel(ConductivityGroupBox) self.label_3 = QtGui.QLabel(ConductivityGroupBox)
self.label_3.setObjectName(_fromUtf8("label_3")) self.label_3.setObjectName(_fromUtf8("label_3"))
self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1, QtCore.Qt.AlignHCenter) self.gridLayout.addWidget(self.label_3, 1, 0, 1, 1, QtCore.Qt.AlignHCenter)
@ -145,7 +146,7 @@ class Ui_ConductivityGroupBox(object):
self.label_4.setText(_translate("ConductivityGroupBox", "α", None)) self.label_4.setText(_translate("ConductivityGroupBox", "α", None))
self.rSigma_sd.setText(_translate("ConductivityGroupBox", "TextLabel", 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.pushButton_hide.setText(_translate("ConductivityGroupBox", "Hide", None))
self.label_3.setText(_translate("ConductivityGroupBox", "<html><head/><body><p>σ&quot;</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.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)) self.iSigma_sd.setText(_translate("ConductivityGroupBox", "TextLabel", None))

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>253</width> <width>253</width>
<height>156</height> <height>158</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -171,10 +171,13 @@
</widget> </widget>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="subtractConductivityButton"> <widget class="QPushButton" name="pushButton_hide">
<property name="text"> <property name="text">
<string>Hide</string> <string>Hide</string>
</property> </property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0" alignment="Qt::AlignHCenter"> <item row="1" column="0" alignment="Qt::AlignHCenter">

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'ui/PowerLawGroupBox.ui' # Form implementation generated from reading ui file 'ui/PowerLawGroupBox.ui'
# #
# Created: Wed Sep 24 21:21:48 2014 # Created: Tue Dec 16 15:03:15 2014
# by: PyQt4 UI code generator 4.11.1 # 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 +26,7 @@ except AttributeError:
class Ui_PowerLawGroupBox(object): class Ui_PowerLawGroupBox(object):
def setupUi(self, PowerLawGroupBox): def setupUi(self, PowerLawGroupBox):
PowerLawGroupBox.setObjectName(_fromUtf8("PowerLawGroupBox")) PowerLawGroupBox.setObjectName(_fromUtf8("PowerLawGroupBox"))
PowerLawGroupBox.resize(206, 129) PowerLawGroupBox.resize(253, 131)
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)
@ -113,6 +113,10 @@ class Ui_PowerLawGroupBox(object):
self.checkBox_2.setText(_fromUtf8("")) self.checkBox_2.setText(_fromUtf8(""))
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2")) self.checkBox_2.setObjectName(_fromUtf8("checkBox_2"))
self.gridLayout.addWidget(self.checkBox_2, 1, 3, 1, 1, QtCore.Qt.AlignHCenter) self.gridLayout.addWidget(self.checkBox_2, 1, 3, 1, 1, QtCore.Qt.AlignHCenter)
self.pushButton_hide = QtGui.QPushButton(PowerLawGroupBox)
self.pushButton_hide.setCheckable(True)
self.pushButton_hide.setObjectName(_fromUtf8("pushButton_hide"))
self.gridLayout.addWidget(self.pushButton_hide, 0, 2, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1) self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
self.retranslateUi(PowerLawGroupBox) self.retranslateUi(PowerLawGroupBox)
@ -128,4 +132,5 @@ class Ui_PowerLawGroupBox(object):
self.label_5.setText(_translate("PowerLawGroupBox", "TextLabel", None)) self.label_5.setText(_translate("PowerLawGroupBox", "TextLabel", None))
self.label_3.setText(_translate("PowerLawGroupBox", "n", None)) self.label_3.setText(_translate("PowerLawGroupBox", "n", None))
self.label_2.setText(_translate("PowerLawGroupBox", "U", None)) self.label_2.setText(_translate("PowerLawGroupBox", "U", None))
self.pushButton_hide.setText(_translate("PowerLawGroupBox", "Hide", None))

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>206</width> <width>253</width>
<height>129</height> <height>131</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -167,6 +167,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_hide">
<property name="text">
<string>Hide</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -2,8 +2,8 @@
# Form implementation generated from reading ui file 'ui/QDSMain.ui' # Form implementation generated from reading ui file 'ui/QDSMain.ui'
# #
# Created: Wed Sep 24 21:21:48 2014 # Created: Tue Sep 30 15:34:02 2014
# by: PyQt4 UI code generator 4.11.1 # by: PyQt4 UI code generator 4.11.2
# #
# WARNING! All changes made in this file will be lost! # WARNING! All changes made in this file will be lost!
@ -67,6 +67,8 @@ class Ui_MainWindow(object):
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.setObjectName(_fromUtf8("menuConfiguration"))
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"))
@ -125,6 +127,7 @@ class Ui_MainWindow(object):
self.actionShow_Derivative.setObjectName(_fromUtf8("actionShow_Derivative")) self.actionShow_Derivative.setObjectName(_fromUtf8("actionShow_Derivative"))
self.menuExtras.addAction(self.actionShow_Derivative) self.menuExtras.addAction(self.actionShow_Derivative)
self.menubar.addAction(self.menuExtras.menuAction()) self.menubar.addAction(self.menuExtras.menuAction())
self.menubar.addAction(self.menuConfiguration.menuAction())
self.toolBar.addAction(self.actionAdd_Peak) self.toolBar.addAction(self.actionAdd_Peak)
self.toolBar.addAction(self.actionAdd_Cond) self.toolBar.addAction(self.actionAdd_Cond)
self.toolBar.addAction(self.actionAdd_PowerLaw) self.toolBar.addAction(self.actionAdd_PowerLaw)
@ -141,6 +144,7 @@ class Ui_MainWindow(object):
def retranslateUi(self, MainWindow): def retranslateUi(self, MainWindow):
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.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_Cond.setText(_translate("MainWindow", "Add Cond.", None)) self.actionAdd_Cond.setText(_translate("MainWindow", "Add Cond.", None))

View File

@ -73,7 +73,13 @@
</property> </property>
<addaction name="actionShow_Derivative"/> <addaction name="actionShow_Derivative"/>
</widget> </widget>
<widget class="QMenu" name="menuConfiguration">
<property name="title">
<string>Configuration</string>
</property>
</widget>
<addaction name="menuExtras"/> <addaction name="menuExtras"/>
<addaction name="menuConfiguration"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">