Exemplo n.º 1
0
 def calcRL(self):
     msg = 'fit failed. please acquire some data first'
     if self.xdata is not None:
         start, end = self.region.getRegion()
         leftIndex = (np.abs(self.xdata * 1e-3 - start)).argmin()
         rightIndex = (np.abs(self.xdata * 1e-3 - end)).argmin()
         from expeyes import eyemath17
         self.p.I.set_state(
             OD1=1
         )  # Do some DC work to find the resistance of the Inductor
         time.sleep(.5)
         Rext = float(self.res.value())
         vtotal = 5.0  # Assume OD1 = 5 volts
         v = self.p.I.get_voltage('A2')
         if v > 4.8:  # Means user has connected OD1 to A2
             vtotal = v
         Vind = self.p.I.get_voltage('A1')  # voltage across the Inductor
         i = (vtotal - Vind) / Rext
         Rind = Vind / i
         fa = eyemath17.fit_exp(self.xdata[leftIndex:rightIndex],
                                self.ydata[leftIndex:rightIndex])
         if fa != None:
             pa = fa[1]
             par1 = abs(1.0 / pa[1])
             msg = u'L/R = %5.3f mSec\nRind = %5.0f \u03A9\nL = %5.1f mH' % (
                 par1, Rind, (Rext + Rind) * par1)
             fitcurve = self.addCurve(
                 self.plot, '%s_%5.2fmS' % (self.curve.name(), par1),
                 '#fff')
             fitcurve.setData(self.xdata[leftIndex:rightIndex] * 1e-3,
                              fa[0])
         else:
             msg = 'Failed to fit the curve with V=Vo*exp(-t/RC)'
     QtGui.QMessageBox.information(self, 'Fit Results', msg)
Exemplo n.º 2
0
def fit_curve():
	global data
	fa = eyemath.fit_exp(data[0], data[1])
	if fa != None:
		pa = fa[1]
		rc = abs(1.0 / pa[1])
		g.line(data[0],fa[0],1)
		dispmsg(_('RC = %5.2f mSec')%rc)
	else:
		dispmsg(_('Failed to fit the curve with V=Vo*exp(-t/RC)'))
Exemplo n.º 3
0
def fit_curve():
	global data, running
	if running == True or len(data[0])==0:
		return
	f = eyemath.fit_exp(data[0], data[1])
	if f != None:
		g.line(data[0], f[0], 1)
		k = 1.38e-23    # Boltzmann const
		q = 1.6e-19     # unit charge
		Io = f[1][0]
		a1 = f[1][1]
		T = 300.0		# Room temp in Kelvin
		n = q/(a1*k*T)
		s = _('Fitted with Diode Equation : Io = %5.2e mA , Ideality factor = %5.2f')%(Io,n)
		msg.config(text = s)
Exemplo n.º 4
0
 def calcRC(self):
     msg = 'fit failed. please acquire some data first'
     if self.xdata is not None:
         start, end = self.region.getRegion()
         leftIndex = (np.abs(self.xdata * 1e-3 - start)).argmin()
         rightIndex = (np.abs(self.xdata * 1e-3 - end)).argmin()
         from expeyes import eyemath17
         print start, end, leftIndex, rightIndex
         fa = eyemath17.fit_exp(self.xdata[leftIndex:rightIndex],
                                self.ydata[leftIndex:rightIndex])
         if fa != None:
             pa = fa[1]
             rc = np.abs(1.0 / pa[1])
             msg = 'RC time constant = %5.2f mSec\nNew curve (%s_%5.2fmS) overlaid' % (
                 rc, self.curve.name(), rc)
             fitcurve = self.addCurve(
                 self.plot, '%s_%5.2fmS' % (self.curve.name(), rc), '#fff')
             fitcurve.setData(self.xdata[leftIndex:rightIndex] * 1e-3,
                              fa[0])
         else:
             msg = 'Failed to fit the curve with V=Vo*exp(-t/RC)'
     QtGui.QMessageBox.information(self, 'Fit Results', msg)
Exemplo n.º 5
0
def fit_curve():
    global data
    p.set_state(
        OD1=1)  # Do some DC work to find the resistance of the Inductor
    time.sleep(.5)
    Rext = float(Res.get())
    vtotal = 5.0  # Assume OD1 = 5 volts
    v = p.get_voltage('A2')
    if v > 4.8:  # Means user has connected OD1 to A2
        vtotal = v
    Vind = p.get_voltage('A1')  # voltage across the Inductor
    i = (vtotal - Vind) / Rext
    Rind = Vind / i
    fa = eyemath.fit_exp(data[0], data[1])
    if fa != None:
        pa = fa[1]
        par1 = abs(1.0 / pa[1])
        g.line(data[0], fa[0], 1)
        dispmsg(
            _('L/R = %5.3f mSec : Rind = %5.0f Ohm : L = %5.1f mH') %
            (par1, Rind, (Rext + Rind) * par1))
    else:
        dispmsg(_('Failed to Fit. Try fitting V=Vo*exp(-tR/L) with Xmgrace'))
Exemplo n.º 6
0
    def fit_curve(self):
        msg = 'fit failed. please acquire some data first'
        if self.xdata is not None and self.activeCurve is not None:
            from expeyes import eyemath17
            f = eyemath17.fit_exp(self.xdata, self.ydata)
            if f != None:
                k = 1.38e-23  # Boltzmann const
                q = 1.6e-19  # unit charge
                Io = f[1][0]
                a1 = f[1][1]
                T = 300.0  # Room temp in Kelvin
                n = q / (a1 * k * T)

                msg = 'Fitted with Diode Equation :\nIo = %s\nIdeality factor = %5.2f' % (
                    self.applySIPrefix(Io, 'A', 2), n)
                fitcurve = self.addCurve(
                    self.plot,
                    '%s\n%s\nIF=%5.1f' % (self.activeCurve.name(),
                                          self.applySIPrefix(Io, 'A', 2), n),
                    '#fff')
                fitcurve.setData(self.xdata, f[0])
            else:
                msg = 'Failed to fit the curve '
        QtGui.QMessageBox.information(self, 'Fit Results', msg)