Fit shown calculated only within the selected region
This commit is contained in:
parent
62a8d0fb9d
commit
4f5cdc7103
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'ConductivityGroupBox.ui'
|
||||
#
|
||||
# Created: Thu Mar 20 13:41:01 2014
|
||||
# Created: Thu Mar 20 14:46:49 2014
|
||||
# by: PyQt4 UI code generator 4.10.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -42,11 +42,13 @@ class ParameterWidget(QWidget):
|
||||
def __init__(self, parent = None):
|
||||
super(ParameterWidget, self).__init__(parent)
|
||||
self.vlayout = QVBoxLayout(self)
|
||||
self.vlayout.addSpacerItem(QSpacerItem(10,10,QSizePolicy.Minimum, QSizePolicy.Expanding) )
|
||||
#self.vlayout.addSpacerItem(QSpacerItem(10,10,QSizePolicy.Minimum, QSizePolicy.Expanding) )
|
||||
self.vlayout.addSpacerItem(QSpacerItem(10,10,QSizePolicy.Minimum, QSizePolicy.Expanding) )
|
||||
#self.vlayout.addStretch(1)
|
||||
|
||||
|
||||
def add(self, wdgt):
|
||||
self.vlayout.insertWidget(self.vlayout.count()-1, wdgt)
|
||||
self.vlayout.update()
|
||||
if __name__ == "__main__":
|
||||
app = QApplication([])
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'PeakGroupBox.ui'
|
||||
#
|
||||
# Created: Thu Mar 20 13:41:01 2014
|
||||
# Created: Thu Mar 20 14:46:49 2014
|
||||
# by: PyQt4 UI code generator 4.10.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'PowerLawGroupBox.ui'
|
||||
#
|
||||
# Created: Thu Mar 20 13:41:01 2014
|
||||
# Created: Thu Mar 20 14:46:49 2014
|
||||
# by: PyQt4 UI code generator 4.10.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
49
QDS.py
49
QDS.py
@ -36,8 +36,6 @@ class AppWindow(QMainWindow):
|
||||
super(AppWindow, self).__init__(parent)
|
||||
self.ui = QDSMain.Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
self.picked_artist = None
|
||||
self.data = None
|
||||
|
||||
actions = {
|
||||
self.ui.actionAdd_Peak:self.addPeak,
|
||||
@ -45,17 +43,13 @@ class AppWindow(QMainWindow):
|
||||
self.ui.actionAdd_PowerLaw:self.addPowerComplex,
|
||||
self.ui.actionAdd_Eps_Infty:self.addEpsInfty
|
||||
}
|
||||
|
||||
self.myActionGroup = QActionGroup(self)
|
||||
for a in actions.keys(): self.myActionGroup.addAction(a)
|
||||
|
||||
self.function_registry = FunctionRegister()
|
||||
|
||||
self.Conductivity = None
|
||||
|
||||
self._lines = dict()
|
||||
|
||||
self.peakId = 0
|
||||
self.peakBoxes = {}
|
||||
|
||||
self.parameterWidget = ParameterWidget()
|
||||
self.ui.dockWidget_3.setWidget(self.parameterWidget)
|
||||
@ -133,17 +127,12 @@ class AppWindow(QMainWindow):
|
||||
self.ui.pgPlotWidget_imag.setLabel("left", "(I) Dielectric loss", units="Debye")
|
||||
self.ui.pgPlotWidget_real.setLabel("left", "(R) Dielectric loss", units="Debye")
|
||||
|
||||
#self.peak_box_layout = QGridLayout()
|
||||
#self.ui.scrollAreaWidgetContents.setLayout(self.peak_box_layout)
|
||||
##self.huh = pg.SignalProxy(, slot=self.mPE)
|
||||
sc_real = self.ui.pgPlotWidget_real.scene()
|
||||
sc_real.sigMouseClicked.connect(self.mousePress)
|
||||
|
||||
sc_real.sigMouseMoved.connect(self.updateCrosshair)
|
||||
|
||||
sc_imag = self.ui.pgPlotWidget_imag.scene()
|
||||
sc_imag.sigMouseClicked.connect(self.mousePress)
|
||||
|
||||
sc_imag.sigMouseMoved.connect(self.updateCrosshair)
|
||||
|
||||
|
||||
@ -158,7 +147,7 @@ class AppWindow(QMainWindow):
|
||||
elif self.ui.pgPlotWidget_real.underMouse():
|
||||
pos = vb_real.mapSceneToView(evt)
|
||||
else:
|
||||
pos = QPointF(1.0,1.0)
|
||||
pos = QPointF(0.0, 0.0)
|
||||
|
||||
self.last_pos = pos
|
||||
|
||||
@ -286,9 +275,8 @@ class AppWindow(QMainWindow):
|
||||
cond_par = [10**(pos.y() + pos.x())*2*N.pi , 1.0]
|
||||
_conductivity.setParameter(beta=cond_par)
|
||||
|
||||
self.parameterWidget.vlayout.insertWidget(1,_conductivity.widget)
|
||||
self.parameterWidget.add(_conductivity.widget)
|
||||
self.function_registry.register_function(_conductivity)
|
||||
self.parameterWidget.vlayout.update()
|
||||
self.updatePlot()
|
||||
|
||||
|
||||
@ -302,9 +290,8 @@ class AppWindow(QMainWindow):
|
||||
cond_par = [10**(pos.y() + pos.x())*2*N.pi , 1.0]
|
||||
_power_complex.setParameter(beta=cond_par)
|
||||
|
||||
self.parameterWidget.vlayout.insertWidget(1,_power_complex.widget)
|
||||
self.parameterWidget.add(_power_complex.widget)
|
||||
self.function_registry.register_function(_power_complex)
|
||||
self.parameterWidget.vlayout.update()
|
||||
self.updatePlot()
|
||||
|
||||
def addEpsInfty(self, pos):
|
||||
@ -317,21 +304,15 @@ class AppWindow(QMainWindow):
|
||||
cond_par = [10**pos.y()]
|
||||
_eps_infty.setParameter(beta=cond_par)
|
||||
|
||||
self.parameterWidget.vlayout.insertWidget(1,_eps_infty.widget)
|
||||
self.parameterWidget.add(_eps_infty.widget)
|
||||
self.function_registry.register_function(_eps_infty)
|
||||
self.parameterWidget.vlayout.update()
|
||||
self.updatePlot()
|
||||
|
||||
|
||||
|
||||
def delParamterObject(self, obj):
|
||||
print "unregister",obj
|
||||
self.function_registry.unregister_function(obj)
|
||||
self.updatePlot()
|
||||
|
||||
|
||||
|
||||
|
||||
def addPeak(self, pos):
|
||||
id_list = [ key.id_num for key in
|
||||
self.function_registry.get_registered_functions().keys()
|
||||
@ -341,8 +322,11 @@ class AppWindow(QMainWindow):
|
||||
while self.peakId in id_list:
|
||||
self.peakId += 1
|
||||
|
||||
_peak = Peak(id_num=self.peakId, plt_real=self.ui.pgPlotWidget_real, plt_imag=self.ui.pgPlotWidget_imag,
|
||||
_peak = Peak(id_num=self.peakId,
|
||||
plt_real=self.ui.pgPlotWidget_real,
|
||||
plt_imag=self.ui.pgPlotWidget_imag,
|
||||
limits=self.data.fit_limits)
|
||||
|
||||
_peak.changedData.connect(self.updatePlot)
|
||||
_peak.removeObj.connect(self.delParamterObject)
|
||||
|
||||
@ -350,11 +334,7 @@ class AppWindow(QMainWindow):
|
||||
_peak.setParameter(beta = new_peak)
|
||||
|
||||
self.function_registry.register_function(_peak)
|
||||
self.peakBoxes[_peak] = self.peakId
|
||||
|
||||
for i,pb in enumerate(self.peakBoxes.keys()):
|
||||
self.parameterWidget.vlayout.insertWidget(1,pb.widget)
|
||||
self.parameterWidget.vlayout.update()
|
||||
self.parameterWidget.add(_peak.widget)
|
||||
|
||||
self.updatePlot()
|
||||
|
||||
@ -371,8 +351,6 @@ class AppWindow(QMainWindow):
|
||||
self.updatePlot()
|
||||
|
||||
def fitData(self, method):
|
||||
log10fmin, log10fmax = self.fit_boundary.getRegion()
|
||||
self.data.set_fit_xlimits(10**log10fmin, 10**log10fmax)
|
||||
fit_methods = [fit_odr_cmplx, fit_lbfgsb, fit_anneal]
|
||||
|
||||
# build function list
|
||||
@ -433,6 +411,8 @@ class AppWindow(QMainWindow):
|
||||
|
||||
|
||||
def updatePlot(self):
|
||||
log10fmin, log10fmax = self.fit_boundary.getRegion()
|
||||
self.data.set_fit_xlimits(10**log10fmin, 10**log10fmax)
|
||||
p0,funcs = [],[]
|
||||
for fcn in self.function_registry.get_registered_functions():
|
||||
p0.extend(fcn.getParameter())
|
||||
@ -445,12 +425,13 @@ class AppWindow(QMainWindow):
|
||||
self.data.data_curve_imag.setData(self.data.frequency, self.data.epsilon.imag)
|
||||
|
||||
if len(funcs)> 0:
|
||||
self.data.fitted_curve_real.setData(self.data.frequency, self.data.epsilon_fit.real)
|
||||
self.data.fitted_curve_imag.setData(self.data.frequency, self.data.epsilon_fit.imag)
|
||||
self.data.fitted_curve_real.setData(self.data.frequency_fit, self.data.epsilon_fit.real)
|
||||
self.data.fitted_curve_imag.setData(self.data.frequency_fit, self.data.epsilon_fit.imag)
|
||||
|
||||
else:
|
||||
self.data.fitted_curve_real.setData([N.nan],[N.nan])
|
||||
self.data.fitted_curve_imag.setData([N.nan],[N.nan])
|
||||
|
||||
def sigint_handler(*args):
|
||||
"""Handler for the SIGINT signal (CTRL + C).
|
||||
"""
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'QDSMain.ui'
|
||||
#
|
||||
# Created: Thu Mar 20 13:41:01 2014
|
||||
# Created: Thu Mar 20 14:46:49 2014
|
||||
# by: PyQt4 UI code generator 4.10.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@ -94,7 +94,7 @@ class Ui_MainWindow(object):
|
||||
self.actionAdd_Cond.setObjectName(_fromUtf8("actionAdd_Cond"))
|
||||
self.actionSave_FitResult = QtGui.QAction(MainWindow)
|
||||
icon2 = QtGui.QIcon()
|
||||
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/save_fit.svg")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
icon2.addPixmap(QtGui.QPixmap(_fromUtf8(":/icons/save_fit.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
self.actionSave_FitResult.setIcon(icon2)
|
||||
self.actionSave_FitResult.setObjectName(_fromUtf8("actionSave_FitResult"))
|
||||
self.actionAdd_PowerLaw = QtGui.QAction(MainWindow)
|
||||
|
@ -127,7 +127,7 @@
|
||||
<action name="actionSave_FitResult">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/images.qrc">
|
||||
<normaloff>:/icons/save_fit.svg</normaloff>:/icons/save_fit.svg</iconset>
|
||||
<normaloff>:/icons/save_fit.png</normaloff>:/icons/save_fit.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Fit</string>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'StaticGroupBox.ui'
|
||||
#
|
||||
# Created: Thu Mar 20 13:41:01 2014
|
||||
# Created: Thu Mar 20 14:46:49 2014
|
||||
# by: PyQt4 UI code generator 4.10.3
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
5
data.py
5
data.py
@ -14,6 +14,7 @@ class Data:
|
||||
def __init__(self, frequency=N.zeros(1), die_real=N.zeros(1), die_imag=N.zeros(1)):
|
||||
self.frequency = frequency
|
||||
self.epsilon = die_real + 1j * die_imag
|
||||
self.frequency_fit = frequency
|
||||
self.epsilon_fit = die_real*0 + 1j * die_imag*0
|
||||
myPen_imag = pg.mkPen(width=3, color=(255,255,127))
|
||||
myPen_real = pg.mkPen(width=3, color=(51,255,127))
|
||||
@ -35,7 +36,7 @@ class Data:
|
||||
def set_fit(self, param, funcs):
|
||||
self.fit_funcs = funcs
|
||||
self.fit_param = param
|
||||
fit_real, fit_imag = FitFunctionCreator().fitfcn(param, self.frequency, *funcs)
|
||||
fit_real, fit_imag = FitFunctionCreator().fitfcn(param, self.frequency_fit, *funcs)
|
||||
self.epsilon_fit = fit_real + 1j*fit_imag
|
||||
|
||||
def __del__(self):
|
||||
@ -54,6 +55,7 @@ class Data:
|
||||
def set_fit_xlimits(self, xmin, xmax):
|
||||
self.fit_limits[0] = xmin
|
||||
self.fit_limits[1] = xmax
|
||||
self.frequency_fit = self.frequency[(self.frequency <= xmax) & (self.frequency >= xmin)]
|
||||
|
||||
def set_fit_ylimits(self, ymin, ymax):
|
||||
self.fit_limits[2] = ymin
|
||||
@ -127,7 +129,6 @@ class Conductivity(QObject):
|
||||
p = self.getParameter()
|
||||
|
||||
y = self.f.cond_cmplx(p, self.frequency)
|
||||
print p
|
||||
self.conductivity = y # imaginary part
|
||||
|
||||
self.data_curve_real.setData(x=self.frequency, y=self.conductivity[0], label="Cond.")
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 17 KiB |
@ -1,9 +1,9 @@
|
||||
<RCC>
|
||||
<qresource prefix="icons">
|
||||
<file>add_eps_infty.png</file>
|
||||
<file>add_cond.svg</file>
|
||||
<file>add_eps_infty.png</file>
|
||||
<file>add_peak.svg</file>
|
||||
<file>save_fit.svg</file>
|
||||
<file>fit_limits.png</file>
|
||||
<file>save_fit.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 18 KiB |
3368
images_rc.py
3368
images_rc.py
File diff suppressed because it is too large
Load Diff
@ -219,20 +219,20 @@ class FunctionRegister:
|
||||
self.registry = {}
|
||||
|
||||
def register_function(self,obj):
|
||||
print "FR: Registering:",obj
|
||||
#print "FR: Registering:",obj
|
||||
id_string = obj.id_string
|
||||
if self.registry.has_key(obj):
|
||||
raise AssertionError,"The object is already registered! This should NOT happen"
|
||||
self.registry[obj]=id_string
|
||||
print "FR: ",self.registry
|
||||
#print "FR: ",self.registry
|
||||
|
||||
def unregister_function(self, obj):
|
||||
print "FR: UnRegistering:",obj
|
||||
#print "FR: UnRegistering:",obj
|
||||
if self.registry.has_key(obj):
|
||||
self.registry.pop(obj)
|
||||
else:
|
||||
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):
|
||||
return self.registry
|
||||
|
Loading…
Reference in New Issue
Block a user