Skip to content

Commit

Permalink
add variance weighting to cost function
Browse files Browse the repository at this point in the history
  • Loading branch information
bernard-giroux committed Sep 29, 2018
1 parent 3e78ced commit 4b73c9d
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions pycpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,10 @@ def initUI(self):
self.ztc = QCheckBox()
self.dzc = QCheckBox()
self.Cc = QCheckBox()
self.lfc = QCheckBox('Low frequency weighting')
self.lfc.setChecked(False)
self.lfc = QComboBox()
self.lfc.addItem('No weighting')
self.lfc.addItem('Low frequency weighting')
self.lfc.addItem('Variance weighting')

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

self.sp.type.currentIndexChanged.connect(self.computeSpectrum)
self.sp.detrend.currentIndexChanged.connect(self.computeSpectrum)
Expand Down Expand Up @@ -974,7 +975,7 @@ def updateSpectrum(self):
zt = locale.toDouble(self.mp.zted.text())[0]
dz = locale.toDouble(self.mp.dzed.text())[0]
C = locale.toDouble(self.mp.Ced.text())[0]
self.splot.plot(f, (beta, zt, dz, C), self.sp.log.isChecked(), self.mp.lfc.isChecked())
self.splot.plot(f, (beta, zt, dz, C), self.sp.log.isChecked())
else:
self.splot.plot2D(f, self.sp.log.isChecked())

Expand Down Expand Up @@ -1020,10 +1021,11 @@ def computeSpectrum(self, x=None, y=None):
elif self.forage != None:
f = self.forage
elif self.forages != None:
f = self.forages[self.bh.bhlist.currentIndex()]

index = self.bh.bhlist.currentIndex()
f = self.forages[index]

self.statusBar().clearMessage()
self.statusBar().showMessage('Borehole: '+f.site_name)
self.statusBar().showMessage('Borehole no '+str(index)+': '+f.site_name)

if f != None:
ww = 1000.0 * locale.toDouble(self.sp.winsize.text())[0]
Expand Down Expand Up @@ -1211,7 +1213,9 @@ def fitSpectrum(self):
ztc = self.mp.ztc.isChecked()
dzc = self.mp.dzc.isChecked()
Cc = self.mp.Cc.isChecked()
lfc = self.mp.lfc.isChecked()
lfc = self.mp.lfc.currentIndex()
if lfc == 2:
lfc = f.std_r**2

meth = self.mp.method

Expand Down Expand Up @@ -1352,7 +1356,10 @@ def fitSpec2step(self):
zt = locale.toDouble(self.mp.zted.text())[0]
dz = locale.toDouble(self.mp.dzed.text())[0]
C = locale.toDouble(self.mp.Ced.text())[0]
lfc = self.mp.lfc.isChecked()

lfc = self.mp.lfc.currentIndex()
if lfc == 2:
lfc = f.std_r**2

meth = self.mp.method

Expand Down

0 comments on commit 4b73c9d

Please sign in to comment.