from scitools.std import *
import scitools.filetable as ft

infile = open('xy.dat', 'r')
x, y = ft.read_columns(infile)
infile.close()

print 'The maximum y coordinate is %6.4f' % max(y)
print 'The minimum y coordinate is %6.4f' % min(y)
plot(x,y, xlabel='x', ylabel='y')
raw_input('Press Enter to quit: ')

'''
python read_2columns_filetable.py
The maximum y coordinate is 0.9482
The minimum y coordinate is -0.9482
Press Enter to quit: 
'''
示例#2
0
	'''
	Uses the Trapezoidal rule to calculate the velocity
	at time step k (each time step is dt) from discrete measurements
	of acceleration
	k specifices the time to measure velocity (k * dt)
	dt is the time step 
	a is the list of acceleration measurements
	
	The function returns a velocity
	'''
	# note: k < len(a)
	return dt*(1./2*a[0] + 1./2*a[-1] + sum(a[1:k]))
	

filename = 'acc.dat'
infile = open(filename, 'r')
accel = ft.read_columns(infile)[0]
infile.close()
print 'v(t_k) = %f' % (v(dt, k, accel))
plot(range(len(accel)),accel,
	xlabel='Units of time elapsed (delta t)',
	ylabel='Accelaration m/s^2',
	title='Acceleration v. Time')
raw_input('Press Enter to quit: ')

'''
python acc2vel_v1.py .5 40
v(t_k) = 9.839308
Press Enter to quit: 
'''
示例#3
0
import scitools.filetable as ft
def v_pos(k,x,s):
	'''
	Simple formula for calculating velocity in one dimension
	for an array with positions recorded in increments of
	time step s
	0 <= k < len(x)-1

	The function returns the one-dimensional velocity 
	'''
	return (x[k+1] - x[k])/float(s)

filename = 'pos.dat'
infile = open(filename, 'r')
s = float(infile.readline())
x,y = ft.read_columns(infile)
infile.close()

t = [s*i for i in range(0,len(x))]
vx = [0]*(len(x)-1)
vy = [0]*(len(y)-1)
for i in range(len(x)-1):
	vx[i] = v_pos(i,x,s)
	vy[i] = v_pos(i,y,s)

figure()
plot(t[:-1],vx,
	xlabel='Time (s)',
	ylabel='Velocity in x-direction',
	title='V_x v. time')
示例#4
0
# -*- coding: utf-8 -*-
import glob, os, shutil
from math import cos, pi, exp
from numpy import *
import scitools.filetable as ft
#from scitools.easyviz import *
import sys

file = open('result.out', 'r')
file.readline()
X, Y, Z, U, V, W, P, T = ft.read_columns(file)
for i in xrange(X.shape[0]):
    print X[i], T[i]
示例#5
0
    '''
	Uses the Trapezoidal rule to calculate the velocity
	at time step k (each time step is dt) from discrete measurements
	of acceleration
	k specifices the time to measure velocity (k * dt)
	dt is the time step 
	a is the list of acceleration measurements
	
	The function returns a velocity
	'''
    # note: k < len(a)
    return dt * (1. / 2 * a[0] + 1. / 2 * a[-1] + sum(a[1:k]))


filename = 'acc.dat'
infile = open(filename, 'r')
accel = ft.read_columns(infile)[0]
infile.close()
print 'v(t_k) = %f' % (v(dt, k, accel))
plot(range(len(accel)),
     accel,
     xlabel='Units of time elapsed (delta t)',
     ylabel='Accelaration m/s^2',
     title='Acceleration v. Time')
raw_input('Press Enter to quit: ')
'''
python acc2vel_v1.py .5 40
v(t_k) = 9.839308
Press Enter to quit: 
'''