Commit 613f9895 authored by Dimitris Lampridis's avatar Dimitris Lampridis

Fix typos and avoid using floats for array indexing, solves #1615

parent d89f028a
...@@ -88,8 +88,8 @@ class SingleToneSignal(Signal): ...@@ -88,8 +88,8 @@ class SingleToneSignal(Signal):
fdft = self.fulldft fdft = self.fulldft
# index of the biggest peak # index of the biggest peak
first = 1. + argmax(fdft[1:N/2]) first = 1 + argmax(fdft[1:N/2])
# index of the biggest peak nearest to `first` # index of the biggest peak nearest to `first`
# can only be first +-1. # can only be first +-1.
second = first + ((fdft[first-1]<fdft[first+1])*2) -1 second = first + ((fdft[first-1]<fdft[first+1])*2) -1
...@@ -127,7 +127,7 @@ class SingleToneSignal(Signal): ...@@ -127,7 +127,7 @@ class SingleToneSignal(Signal):
# limit data removing incoherency # limit data removing incoherency
self.w0index = self.w0 /freqSample * self.nsamples self.w0index = self.w0 /freqSample * self.nsamples
self.limit = floor(0.5 + N*int(self.w0index)/self.w0index) self.limit = int(floor(0.5 + N*int(self.w0index)/self.w0index))
self.data = data[:self.limit] self.data = data[:self.limit]
self.nsamples = len(self.data) self.nsamples = len(self.data)
...@@ -202,7 +202,7 @@ class SingleToneSignal(Signal): ...@@ -202,7 +202,7 @@ class SingleToneSignal(Signal):
tenHarmonicsValues = array(map(lambda x: x[2], tenHarmonics)) tenHarmonicsValues = array(map(lambda x: x[2], tenHarmonics))
rssHarmonics = norm(tenHarmonicsValues) rssHarmonics = norm(tenHarmonicsValues)
output.THD = -dB(output.dft[w0index]/rssHarmonics) output.THD = -dB(output.dft[int(w0index)]/rssHarmonics)
# we need the avg of HDs # we need the avg of HDs
avgHarmonics = mean(tenHarmonicsValues) avgHarmonics = mean(tenHarmonicsValues)
...@@ -220,11 +220,11 @@ class SingleToneSignal(Signal): ...@@ -220,11 +220,11 @@ class SingleToneSignal(Signal):
noiseMask = array(ones(len(output.dft))) noiseMask = array(ones(len(output.dft)))
noiseMask[0] = 0 noiseMask[0] = 0
noiseMask[w0index] = 0 noiseMask[int(w0index)] = 0
noiseMask[-w0index] = 0 noiseMask[-int(w0index)] = 0
for i in thindex: noiseMask[int(i)] = 0 for i in thindex: noiseMask[int(i)] = 0
noise = where(noiseMask, self.data, 0) noise = where(noiseMask, output.dft, 0)
output.noisePower = (norm(noise)**2) / self.nsamples output.noisePower = (norm(noise)**2) / self.nsamples
# SNR # SNR
...@@ -242,11 +242,11 @@ class SingleToneSignal(Signal): ...@@ -242,11 +242,11 @@ class SingleToneSignal(Signal):
output.ENOB = (output.SINAD - 1.76 + factor) / 6.02 output.ENOB = (output.SINAD - 1.76 + factor) / 6.02
# SFDR - should I use dB(x) instead of 10log10 ? # SFDR - should I use dB(x) instead of 10log10 ?
output.maxPeak = 10*log10(output.dft[w0index]) output.maxPeak = 10*log10(output.dft[int(w0index)])
secondPeak = max(thvalues) secondPeak = max(thvalues)
output.secondPeak = 10*log10(secondPeak) output.secondPeak = 10*log10(secondPeak)
output.SFDR = 10*log10(output.dft[w0index]/secondPeak) output.SFDR = 10*log10(output.dft[int(w0index)]/secondPeak)
return output return output
......
...@@ -33,11 +33,11 @@ class WindowedSignal: ...@@ -33,11 +33,11 @@ class WindowedSignal:
return data return data
def harmonicPeaksGenerator(self, start, end): def harmonicPeaksGenerator(self, start, end):
indexes = (self.adjust(x * self.w0index, self.nsamples -1) for x in xrange(start , end)) indexes = (self.adjust(x * int(self.w0index), self.nsamples -1) for x in xrange(start , end))
return ((i, self.ratio*i, self.dft[i]) for i in indexes) return ((i, self.ratio*i, self.dft[i]) for i in indexes)
def logHarmonicPeaksGenerator(self, start, end): def logHarmonicPeaksGenerator(self, start, end):
indexes = (self.adjust(x * self.w0index, self.nsamples -1) for x in xrange(start , end)) indexes = (self.adjust(x * int(self.w0index), self.nsamples -1) for x in xrange(start , end))
return ((i, self.ratio*i, self.ldft[i]) for i in indexes) return ((i, self.ratio*i, self.ldft[i]) for i in indexes)
......
...@@ -322,8 +322,6 @@ class MainWindow(QMainWindow): ...@@ -322,8 +322,6 @@ class MainWindow(QMainWindow):
print 'Data fetch complete, elaboration is beginning' print 'Data fetch complete, elaboration is beginning'
print self.wave.getType()
if self.chain in ('adc', 'file'): if self.chain in ('adc', 'file'):
self.decision = self.modes[self.ui.modeBox.currentIndex()][1] self.decision = self.modes[self.ui.modeBox.currentIndex()][1]
else: else:
...@@ -382,7 +380,7 @@ class MainWindow(QMainWindow): ...@@ -382,7 +380,7 @@ class MainWindow(QMainWindow):
self.updateTT() self.updateTT()
def fetchFile(self): def fetchFile(self):
return readFile(self.fileName) return readFile(self.filename)
def fetchSynth(self): def fetchSynth(self):
self.frequencies = frequencies = self.fcCreateList() self.frequencies = frequencies = self.fcCreateList()
......
...@@ -66,7 +66,7 @@ class ModuleSelector(QDialog): ...@@ -66,7 +66,7 @@ class ModuleSelector(QDialog):
if params[key][3] == 'file': if params[key][3] == 'file':
fileName = str(QFileDialog.getOpenFileName(self, caption = "Select device", directory = '/dev', filter = "*")) fileName = str(QFileDialog.getOpenFileName(self, caption = "Select device", directory = '/dev', filter = "*"))
if fileName != "": if fileName != "":
item.setText(1, filename) item.setText(1, fileName)
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment