コード例 #1
0
ファイル: scope.py プロジェクト: expeyes/expeyes-programs
	def show_fft(self):
		for ch in range(4):
			if self.chanStatus[ch] == 1:
				try:	
					fa = em.fit_sine(self.timeData[ch],self.voltData[ch])
				except Exception as err:
					print('fit_sine error:', err)
					fa=None
				if fa != None:
					fr = fa[1][1]*1000			# frequency in Hz
					dt = int(1.e6/ (20 * fr))	# dt in usecs, 20 samples per cycle
					try:
						t,v = self.p.capture1(self.sources[ch], 3000, dt)
					except:
						self.comerr()

					xa,ya = em.fft(v,dt)
					xa *= 1000
					peak = self.peak_index(xa,ya)
					ypos = np.max(ya)
					pop = pg.plot(xa,ya, pen = self.traceCols[ch])
					pop.showGrid(x=True, y=True)
					txt = pg.TextItem(text=unicode(self.tr('Fundamental frequency = %5.1f Hz')) %peak, color = 'w')
					txt.setPos(peak, ypos)
					pop.addItem(txt)
					pop.setWindowTitle(self.tr('Frequency Spectrum'))
				else:
					self.msg(self.tr('FFT Error'))
コード例 #2
0
    def show_fft(self):
        for ch in range(4):
            if self.chanStatus[ch] == 1:
                try:
                    fa = em.fit_sine(self.timeData[ch], self.voltData[ch])
                except Exception as err:
                    print('fit_sine error:', err)
                    fa = None
                if fa != None:
                    fr = fa[1][1] * 1000  # frequency in Hz
                    dt = int(1.e6 /
                             (20 * fr))  # dt in usecs, 20 samples per cycle
                    try:
                        t, v = self.p.capture1(self.sources[ch], 3000, dt)
                    except:
                        self.comerr()

                    xa, ya = em.fft(v, dt)
                    xa *= 1000
                    peak = self.peak_index(xa, ya)
                    ypos = np.max(ya)
                    pop = pg.plot(xa, ya, pen=self.traceCols[ch])
                    pop.showGrid(x=True, y=True)
                    txt = pg.TextItem(text=unicode(
                        self.tr('Fundamental frequency = %5.1f Hz')) % peak,
                                      color='w')
                    txt.setPos(peak, ypos)
                    pop.addItem(txt)
                    pop.setWindowTitle(self.tr('Frequency Spectrum'))
                else:
                    self.msg(self.tr('FFT Error'))
コード例 #3
0
	def show_fft(self):
		self.popwin = pg.PlotWidget()				# pyqtgraph window
		self.popwin.showGrid(x=True, y=True)						# with grid
		self.popwin.setWindowTitle(self.tr('Frequency Spectrum'))
		try:
			xa,ya = em.fft(self.voltData[0], self.timeData[0][1]-self.timeData[0][0])
			self.popwin.plot(xa*1000,ya, pen = self.traceCols[1])
		except:
			self.msg(self.tr('FFT err'))
		self.popwin.show()
コード例 #4
0
	def show_fft(self):
		self.popwin = pg.PlotWidget()				# pyqtgraph window
		self.popwin.showGrid(x=True, y=True)						# with grid
		self.popwin.setWindowTitle(self.tr('Frequency Spectrum'))
		try:
			xa,ya = em.fft(self.voltData[0], self.timeData[0][1]-self.timeData[0][0])
			self.popwin.plot(xa*1000,ya, pen = self.traceCols[1])
		except:
			self.msg(self.tr('FFT err'))
		self.popwin.show()
コード例 #5
0
    def show_fft(self):
        if self.history != []:
            x = self.history[-1][0]
            y = self.history[-1][1]
            if len(x) % 2 != 0:
                x = x[:-1]
                y = y[:-1]
            fa = em.fit_dsine(
                np.array(x), np.array(y),
                1000)  # ./self.guessTP)  #Need to fix eyemath, expects kHz
        else:
            self.msg(self.tr('No data to analyze.'))
            return

        if fa != None:
            if len(self.data[0]) % 2:  #odd number
                self.data[0] = self.data[0][:-1]
                self.data[1] = self.data[1][:-1]
            pa = fa[1]
            ss = '%5.2f' % pa[1]
            self.msg(
                self.tr('Sine Fit Result: Frequency ') + ss + self.tr('Hz'))
            self.traces.append(
                self.pwin.plot(x, fa[0], pen=self.traceCols[self.trial % 5]))

            fr = pa[1]  # frequency in Hz
            dt = np.average(np.diff(self.data[0])) * 1000  #mS

            print('freq:%.2f, dt=%.2e' % (fr, dt))
            xa, ya = em.fft(self.data[1] - np.average(self.data[1]), dt)
            peak = self.peak_index(xa, ya)
            ypos = np.max(ya)
            pop = pg.plot(xa, ya, pen=self.traceCols[self.trial % 5])
            pop.showGrid(x=True, y=True)
            txt = pg.TextItem(
                text=unicode(self.tr('Fundamental frequency = %5.1f Hz')) %
                peak,
                color='w')
            txt.setPos(peak, ypos)
            pop.addItem(txt)
            pop.setWindowTitle(self.tr('Frequency Spectrum'))
            self.trial += 1

        else:
            self.msg(self.tr('Failed to fit the curve'))
コード例 #6
0
#import eyes17.eyes          # uncomment these two lines while running stand-alone
#p = eyes17.eyes.open()

from pylab import *
import eyes17.eyemath17 as em

p.set_sine(1000)
p.set_sqr1(500)

t, v, tt, vv = p.capture2(5000, 20)  # captures A1 and A2

xlabel('Freq')
ylabel('Amplitude')
xlim([0, 10000])

xa, ya = em.fft(v, 20 * 0.001)
plot(xa, ya, linewidth=2, color='blue')

xa, ya = em.fft(vv, 20 * 0.001)
plot(xa, ya, linewidth=2, color='red')

show()
コード例 #7
0
import eyes17.eyes
p = eyes17.eyes.open()

from pylab import *
import eyes17.eyemath17 as em

p.set_sine(1000)
p.set_sqr1(500)

t,v, tt,vv = p.capture2(5000, 20)   # captures A1 and A2

xlabel('Freq')
ylabel('Amplitude')
xlim([0,10000])

xa,ya = em.fft(v,20*0.001)
plot(xa,ya, linewidth = 2, color = 'blue')

xa,ya = em.fft(vv, 20*0.001)
plot(xa, ya, linewidth = 2, color = 'red')

show()