Ejemplo n.º 1
0
    def calc_cap(self,e):
        if self.data.points == []:
            return
        x = self.restext.get()
        try:
            R = float(x)
        except:
            self.msgwin.msg('Set the Resistance value', 'red')
            return

        import phmath, math
        dat = []
        for k in self.data.points:
           dat.append([k[0], k[1]])
        res = phmath.fit_exp(dat)
        fit = []
        for k in res[0]: 
            fit.append([k[0],k[2]])
        self.data.traces.append(fit)
       	self.col = self.data.get_col()
        self.plot2d.line(fit, self.col)

        RC = -1.0/res[1][1]
        C = RC/R
#        print res[1][1], RC, R, C
        ss = 'RC = %4.3f . C = %4.3f\n'%(RC,C)
        self.msgwin.showtext(ss)
Ejemplo n.º 2
0
import phm, phmath
p=phm.phm()

ifp=open('cap.dat','r')

data = []
while 1:
  a = ifp.readline()
  if a == '': break
  ss = a.split()
  data.append( [float(ss[0]), float(ss[1])])
 
res = phmath.fit_exp(data)
frfit = res[1][1]*1.0e6
print frfit

p.plot(res[0])
p.set_scale(0,0,5,5)
raw_input()