autoscale yaxis of concomitant velocity
[quplot.git] / defangle.py
blob04b7cd0c716bb13a91974d41de6e99373a44f307
1 import matplotlib as mpl
2 import matplotlib.mlab as mlab
3 import matplotlib.pyplot as plt
4 import matplotlib.axes as axe
5 import matplotlib.collections as collections
6 import numpy as np
7 import random
8 from pylab import *
9 from matplotlib.pyplot import *
11 ANGLE = "../rk_defangle.dat"
12 VELO = "../rk_bif_avg_velo.dat"
13 FOUT = "../defangle.png"
15 xlabel = r'$h$'
16 ylabel = r'$\delta y$'
18 ######################################################################
20 angle = mlab.csv2rec(ANGLE, delimiter='\t', comments='#')
21 velo = mlab.csv2rec(VELO, delimiter='\t', comments='#')
23 r = angle.r
24 psi = angle.x
25 vx = velo.x
29 def mean_angle(param,angle):
30 unique_param = unique(param)
31 list_angles = [ [] for DUMMYVAR in range(len(unique_param)) ]
32 ret_avg = []
33 for i in range(len(unique_param)):
34 for j in range(len(angle)):
35 if (param[j] == unique_param[i]):
36 list_angles[i].append(angle[j])
37 print len(list_angles[i])
38 ret_avg.append(float(sum(list_angles[i])) / len(list_angles[i]))
39 #print len(ret_avg)
40 return ret_avg
43 fig = plt.figure()
45 ax1 = fig.add_subplot(211)
46 ax2 = fig.add_subplot(212)
48 avg_angles = mean_angle(r,psi)
49 unique_r = unique(r)
51 ax1.plot(unique_r, avg_angles, marker=',', ms=0.1, ls='')
52 ax2.plot(r, vx, marker=',', ms=0.1, ls='')
54 ax1.set_xlim(r.min(),r.max())
55 ax1.set_ylim(psi.min(),psi.max())
57 #plt.savefig(FOUT)
59 plt.show()