|
@@ -131,7 +131,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
self.adc_checkbox_layout = QtGui.QHBoxLayout()
|
|
|
self.group = QtGui.QButtonGroup()
|
|
|
self.group.setExclusive(False)
|
|
|
- print(self.workingChannels)
|
|
|
+ #print(self.workingChannels)
|
|
|
for i in range(self.adc_number):
|
|
|
self.adcCheckBox.append(self.createCheckbox(text="ADC "+str(i+1), connect=self.changeWorking))
|
|
|
self.adc_checkbox_layout.addWidget(self.adcCheckBox[i])
|
|
@@ -243,7 +243,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
if int(file[-2:]) >= ctr:
|
|
|
ctr = int(file[-2:])+1
|
|
|
|
|
|
- print('rename')
|
|
|
+ #print('rename')
|
|
|
os.rename(self.old_id, self.old_id+'.old{:02d}'.format(ctr))
|
|
|
os.rename(self.calibId, self.old_id)
|
|
|
|
|
@@ -267,7 +267,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
for i in range(self.adc_number):
|
|
|
if self.adcCheckBox[i].isChecked():
|
|
|
self.workingChannels.append(i)
|
|
|
- print(self.workingChannels)
|
|
|
+ #print(self.workingChannels)
|
|
|
self.originalnotplotted = True
|
|
|
self.plot()
|
|
|
|
|
@@ -295,7 +295,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
#print(self.grpY[str(i)][0])
|
|
|
self.grpY[str(i)][...] = [[float(str(self.adcBaselineBox[i].text())), float(str(self.adcScalingBox[i].text()))]]
|
|
|
self.grpX[str(i)]['offset'][...] = float(str(self.adcOffsetBox[i].text()))*1e-12
|
|
|
- print(i, self.grpY[str(i)][0], self.grpX[str(i)]['offset'][()])
|
|
|
+ #print(i, self.grpY[str(i)][0], self.grpX[str(i)]['offset'][()])
|
|
|
pass
|
|
|
self.plot()
|
|
|
|
|
@@ -377,7 +377,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
fittype = self.fitSelect.currentIndex()+EGAUSS
|
|
|
useFirst = self.useFirst.value()
|
|
|
|
|
|
- print(typ, fittype, useFirst)
|
|
|
+ #print(typ, fittype, useFirst)
|
|
|
|
|
|
if typ in [0,1]: #Peak
|
|
|
self.updateY(typ, fittype, useFirst)
|
|
@@ -449,7 +449,7 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
y = scany[np.argsort(scanx)]
|
|
|
baseline = np.mean(y[:useFirst])
|
|
|
print('baseline ', baseline)
|
|
|
- print(scanx.shape, scany.shape)
|
|
|
+ #print(scanx.shape, scany.shape)
|
|
|
popt, perr, fitFun, pcov, label, x = self.doFit(scanx, scany, fittype, baseline=baseline, findMin=isNegativ)
|
|
|
phase, A = self.findMax(scanx, popt, fitFun, findMin=isNegativ)
|
|
|
except:
|
|
@@ -472,13 +472,13 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
if phase0 == 0:
|
|
|
phase0 = phase
|
|
|
grpX[str(i)]['offset'][...] = phase0 - phase
|
|
|
- print(phase, A, popt[4])
|
|
|
+ #print(phase, A, popt[4])
|
|
|
A -= popt[4]
|
|
|
if A0 == 0:
|
|
|
A0 = A
|
|
|
if isNegativ:
|
|
|
A *= -1
|
|
|
- print(phase, phase0 - phase, A)
|
|
|
+ #print(phase, phase0 - phase, A)
|
|
|
try:
|
|
|
grpY[str(i)][...] = data=np.array([[popt[4], A/A0]], dtype=np.float64)
|
|
|
grpY['{}popt'.format(i)][...] = popt
|
|
@@ -901,15 +901,14 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
sel = np.where((tmpy < y+tol) & (tmpy > y-tol))
|
|
|
tmp = tmp[sel]
|
|
|
tmpy = tmpy[sel]
|
|
|
-
|
|
|
- if i%(24) == 0: print('tol ', tol, len(res))
|
|
|
+ #if i%(24) == 0: print('tol ', tol, len(res))
|
|
|
+
|
|
|
if len(res) > 1:
|
|
|
-
|
|
|
res = [res[len(res)//2]]
|
|
|
if len(res) == 0:
|
|
|
print('bad',x, y)
|
|
|
res= [x]
|
|
|
- if i%(24) == 0: print(res[0]-x)
|
|
|
+
|
|
|
return res[0]-x
|
|
|
|
|
|
def doFit(self, x,y, type, p0=None, baseline=0, findMin=False):
|
|
@@ -951,7 +950,6 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
fitFun = expgauss
|
|
|
p0 = (23e-12, startx, 7e-8, 0.02e12, 2040)
|
|
|
if findMin:
|
|
|
- print('min')
|
|
|
p0 = (23e-12, startx, -7e-8, 0.02e12, 2040)
|
|
|
label = [' s ', ' m ', ' a ', ' l ', ' b ']
|
|
|
elif type == EGAUSSB:
|
|
@@ -978,7 +976,6 @@ class CalibrationUpdater(kcgw.KCGWidgets):
|
|
|
p0 = p0[:-1]
|
|
|
|
|
|
if p0 is not None:
|
|
|
- print(x.shape, y.shape)
|
|
|
popt, pcov = curve_fit(fitFun, x, y, p0=p0)
|
|
|
else:
|
|
|
popt, pcov = curve_fit(fitFun, x, y)
|