Skip to content

Commit 4b73c9d

Browse files
add variance weighting to cost function
1 parent 3e78ced commit 4b73c9d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

pycpd.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,10 @@ def initUI(self):
453453
self.ztc = QCheckBox()
454454
self.dzc = QCheckBox()
455455
self.Cc = QCheckBox()
456-
self.lfc = QCheckBox('Low frequency weighting')
457-
self.lfc.setChecked(False)
456+
self.lfc = QComboBox()
457+
self.lfc.addItem('No weighting')
458+
self.lfc.addItem('Low frequency weighting')
459+
self.lfc.addItem('Variance weighting')
458460

459461
self.beta_lb = QLineEdit(locale.toString(1.5, format='f', precision=1))
460462
self.beta_lb.setEnabled(False)
@@ -845,7 +847,6 @@ def initUI(self):
845847
self.mp.Ced.editingFinished.connect(self.updateSpectrum)
846848
self.mp.fit2step.clicked.connect(self.fitSpec2step)
847849
self.mp.fit.clicked.connect(self.fitSpectrum)
848-
self.mp.lfc.stateChanged.connect(self.updateSpectrum)
849850

850851
self.sp.type.currentIndexChanged.connect(self.computeSpectrum)
851852
self.sp.detrend.currentIndexChanged.connect(self.computeSpectrum)
@@ -974,7 +975,7 @@ def updateSpectrum(self):
974975
zt = locale.toDouble(self.mp.zted.text())[0]
975976
dz = locale.toDouble(self.mp.dzed.text())[0]
976977
C = locale.toDouble(self.mp.Ced.text())[0]
977-
self.splot.plot(f, (beta, zt, dz, C), self.sp.log.isChecked(), self.mp.lfc.isChecked())
978+
self.splot.plot(f, (beta, zt, dz, C), self.sp.log.isChecked())
978979
else:
979980
self.splot.plot2D(f, self.sp.log.isChecked())
980981

@@ -1020,10 +1021,11 @@ def computeSpectrum(self, x=None, y=None):
10201021
elif self.forage != None:
10211022
f = self.forage
10221023
elif self.forages != None:
1023-
f = self.forages[self.bh.bhlist.currentIndex()]
1024-
1024+
index = self.bh.bhlist.currentIndex()
1025+
f = self.forages[index]
1026+
10251027
self.statusBar().clearMessage()
1026-
self.statusBar().showMessage('Borehole: '+f.site_name)
1028+
self.statusBar().showMessage('Borehole no '+str(index)+': '+f.site_name)
10271029

10281030
if f != None:
10291031
ww = 1000.0 * locale.toDouble(self.sp.winsize.text())[0]
@@ -1211,7 +1213,9 @@ def fitSpectrum(self):
12111213
ztc = self.mp.ztc.isChecked()
12121214
dzc = self.mp.dzc.isChecked()
12131215
Cc = self.mp.Cc.isChecked()
1214-
lfc = self.mp.lfc.isChecked()
1216+
lfc = self.mp.lfc.currentIndex()
1217+
if lfc == 2:
1218+
lfc = f.std_r**2
12151219

12161220
meth = self.mp.method
12171221

@@ -1352,7 +1356,10 @@ def fitSpec2step(self):
13521356
zt = locale.toDouble(self.mp.zted.text())[0]
13531357
dz = locale.toDouble(self.mp.dzed.text())[0]
13541358
C = locale.toDouble(self.mp.Ced.text())[0]
1355-
lfc = self.mp.lfc.isChecked()
1359+
1360+
lfc = self.mp.lfc.currentIndex()
1361+
if lfc == 2:
1362+
lfc = f.std_r**2
13561363

13571364
meth = self.mp.method
13581365

0 commit comments

Comments
 (0)