Example #1
0
                                                                   (x))**p[5]))


filename = ('tgdata.dat')
data = scipy.io.array_import.read_array(filename)

y = data[:, 1]
x = data[:, 0]

A1_0 = 4
A2_0 = 3
k1_0 = 0.5
k2_0 = 0.04
n1_0 = 2
n2_0 = 1
pname = (['A1', 'A2', 'k1', 'k2', 'n1', 'n2'])
p0 = array([A1_0, A2_0, k1_0, k2_0, n1_0, n2_0])
plsq = leastsq(residuals, p0, args=(y, x), maxfev=2000)
gplt.plot(x, y, 'title "Meas" with points', x, peval(x, plsq[0]),
          'title "Fit" with lines lt -1')
gplt.yaxis((0, 7))
gplt.legend('right bottom Left')
gplt.xtitle('Time [h]')
gplt.ytitle('Hydrogen release [wt. %]')
gplt.grid("off")
gplt.output('kinfit.png', 'png medium transparent size 600,400')

print "Final parameters"
for i in range(len(pname)):
    print "%s = %.4f " % (pname[i], p0[i])
Example #2
0
print "length of vector = ", sqrt(p('x')*p('x')+p('y')*p('y')+p('z')*p('z')), \
      " (should = radius parameter ", radius, ")"
print "for x = 1.5, y - 3z = ", p('y') - 3*p('z')
print "\ntraj2.dimension => ", traj2.dimension
print "isparameterized(traj2) => ", isparameterized(traj2)

print "\nTest bounds checking:"
try:
    traj2(3.)
    print "BOUNDS TEST FAILED"
except ValueError, e:
    print "traj2(3.) => Error: ", e
    print "BOUNDS TEST PASSED"

ps1 = traj2.sample(dt=0.02)

testimp2d.set(ics={'y': -0.75})
traj3 = testimp2d.compute('traj3')
ps2 = traj3.sample(dt=0.02)

if do_gnu:
    plotarray1 = transpose(ps1.toarray())
    plotarray2 = transpose(ps2.toarray())

    constraintline = array([[2.,-1,0],[2.,1,0]])
    gplt.plot3d((plotarray1,plotarray2,constraintline))
    gplt.zaxis([-2,2])
    gplt.yaxis([-2,2])
    gplt.view([80,85,1])
    #gplt.close()
Example #3
0
    p("x") * p("x") + p("y") * p("y") + p("z") * p("z")
), " (should = radius parameter ", radius, ")"
print "for x = 1.5, y - 3z = ", p("y") - 3 * p("z")
print "\ntraj2.dimension => ", traj2.dimension
print "isparameterized(traj2) => ", isparameterized(traj2)

print "\nTest bounds checking:"
try:
    traj2(3.0)
    print "BOUNDS TEST FAILED"
except ValueError, e:
    print "traj2(3.) => Error: ", e
    print "BOUNDS TEST PASSED"

ps1 = traj2.sample(dt=0.02)

testimp2d.set(ics={"y": -0.75})
traj3 = testimp2d.compute("traj3")
ps2 = traj3.sample(dt=0.02)

if do_gnu:
    plotarray1 = transpose(ps1.toarray())
    plotarray2 = transpose(ps2.toarray())

    constraintline = array([[2.0, -1, 0], [2.0, 1, 0]])
    gplt.plot3d((plotarray1, plotarray2, constraintline))
    gplt.zaxis([-2, 2])
    gplt.yaxis([-2, 2])
    gplt.view([80, 85, 1])
    # gplt.close()
Example #4
0
filename=('tgdata.dat')
data_x_inlet = genfromtxt(dirName + '/A_3H/epanhils.dat')
data = scipy.io.array_import.read_array(filename)
y = 3.0/4.0*(data_x_inlet[:,4]**2+data_x_inlet[:,5]**2)

y = data[:,1]
x = data[:,0]

A1_0=4
A2_0=3
k1_0=0.5
k2_0=0.04
n1_0=2
n2_0=1
pname = (['A1','A2','k1','k2','n1','n2'])
p0 = array([A1_0 , A2_0, k1_0, k2_0,n1_0,n2_0])
plsq = leastsq(residuals, p0, args=(y, x), maxfev=2000)
gplt.plot(x,y,'title "Meas" with points',x,peval(x,plsq[0]),'title "Fit" with lines lt -1')
gplt.yaxis((0, 7))
gplt.legend('right bottom Left')
gplt.xtitle('Time [h]')
gplt.ytitle('Hydrogen release [wt. %]')
gplt.grid("off")
gplt.output('kinfit.png','png medium transparent size 600,400')

print "Final parameters"
for i in range(len(pname)):
	print "%s = %.4f " % (pname[i], p0[i])