def fit_curve(self):
        if self.running == True or self.data[0] == []:
            return

        if (len(self.data[0]) % 2) == 1:  # make it an even size, for fitting
            self.data[0] = self.data[0][:-1]
            self.data[1] = self.data[1][:-1]

        fa = em.fit_dsine(self.data[0], self.data[1],
                          1000.0)  # fit in em expects khz
        if fa != None:
            pa = fa[1]
            self.traces.append(
                self.pwin.plot(self.data[0],
                               fa[0],
                               pen=self.traceCols[self.trial % 5]))
            self.trial += 1
            ss1 = '%5.2f' % pa[1]
            ss2 = '%5.3f' % pa[4]
            self.msg(
                self.tr('Frequency of Oscillation = ') + ss1 +
                self.tr(' Hz. Damping Factor = ') + ss2)
            self.history.append((self.data[0], fa[0]))
        else:
            self.msg(self.tr('Analysis failed. Could not fit data'))
Exemplo n.º 2
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'))
Exemplo n.º 3
0
	def fit_curve(self):
		if self.history != []:
			fa = em.fit_dsine(self.history[-1][0], self.history[-1][1],0)
		else:
			self.msg(self.tr('No data to analyze.'))
			return
			
		if fa != None:
			pa = fa[1]
			rc = 1.0 / pa[1]
			damping = pa[4] / (2*math.pi*pa[1]) # unitless damping factor
			ss1 = '%5.2f'%pa[1]
			ss2 = '%5.3f'%damping
			self.msg(self.tr('Resonant Frequency = ') + ss1 + self.tr(' kHz Damping factor= ') + ss2)
			self.traces.append(self.pwin.plot(self.history[-1][0], fa[0], pen = self.traceCols[self.trial%5]))
			self.history.append((self.history[-1][0], fa[0]))			
			self.trial += 1
		else:
			self.msg(self.tr('Failed to fit the curve'))
Exemplo n.º 4
0
	def fit_curve(self):
		if self.running == True or self.data[0]==[]:
			return

		if (len(self.data[0])%2) == 1:			# make it an even size, for fitting
			self.data[0] = self.data[0][:-1]
			self.data[1] = self.data[1][:-1]
			
		fa = em.fit_dsine(self.data[0], self.data[1], 1000.0)   # fit in em expects khz
		if fa != None:
			pa = fa[1]
			self.traces.append(self.pwin.plot(self.data[0], fa[0], pen = self.traceCols[self.trial%5]))
			self.trial += 1
			ss1 = '%5.2f'%pa[1]
			ss2 = '%5.3f'%pa[4]
			self.msg(self.tr('Frequency of Oscillation = ') + ss1 + self.tr(' Hz. Damping Factor = ') + ss2)	
			self.history.append((self.data[0], fa[0]))	
		else:
			self.msg(self.tr('Analysis failed. Could not fit data'))
Exemplo n.º 5
0
    def fit_curve(self):
        if self.running == True or self.data[0] == []:
            return
        return
        # Make histogram to be added

        if (len(self.data[0]) % 2) == 1:  # make it an even size, for fitting
            self.data[0] = self.data[0][:-1]
            self.data[1] = self.data[1][:-1]

        fa = em.fit_dsine(self.data[0], self.data[1])
        if fa != None:
            pa = fa[1]
            self.traces.append(self.pwin.plot(self.data[0], fa[0], pen='w'))
            self.msg(
                'Frequency of Oscillation = %5.2f Hz. Damping Factor = %5.3f' %
                (pa[1], pa[4]))
        else:
            self.msg('Analysis failed. Could not fit data')
Exemplo n.º 6
0
	def fit_curve(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:
			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]))
			self.trial += 1
		else:
			self.msg(self.tr('Failed to fit the curve'))
Exemplo n.º 7
0
	def fit_curve(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:
			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]))
			self.trial += 1
		else:
			self.msg(self.tr('Failed to fit the curve'))