I am trying to make in python an array within an array that looks like this:
[[3,0,-3,-4],[6,0,-2.44,-4]]
which I could use in a vector plot in matplotlib.
I tried doing this with the following program:
data = np.loadtxt(sys.argv[1], dtype='str',delimiter=',', skiprows=1, usecols=(0,1,2,3,4,5,6,7))
x = data[:,0].astype(float)
u = data[:,6].astype(float)
v = data[:,7].astype(float)
soa = []
for t in range(0,2):
print "At time ",x[t]," U is ",u[t]," and V is ",v[t]
result = [x[t],0,u[t],v[t]]
soa = np.append(soa, [result])
print "soa is ",soa
When I run the program I get the output:
soa is [ 3. 0. -3. -4. 6. 0. -2.44 -4. ]
This cannot be plotted as a vector plot in matplotlib. How can I tweak the above script to get the array into the format:
[[3,0,-3,-4],[6,0,-2.44,-4]]
where [3,0,-3,-4] and [6,0,-2.44,-4] are vectors that I could plot in matplotlib?
soa = soa.reshape((2,-1))