1 | ### Python code to do plotting of this experiment. |
---|
2 | |
---|
3 | import util |
---|
4 | import numpy |
---|
5 | from matplotlib import pyplot as pyplot |
---|
6 | |
---|
7 | # Define gauge points, following Soares Frazao et al (2008) |
---|
8 | offset=numpy.array([7.7,+1.8]) |
---|
9 | Gauge_xy=numpy.array([ [2.65,1.15] + offset, |
---|
10 | [2.65, -0.60] + offset, |
---|
11 | [4.00, 1.15] + offset, |
---|
12 | [4.00,-0.8] + offset, |
---|
13 | [5.20,0.3] + offset, |
---|
14 | [-1.87,1.10] + offset ]) |
---|
15 | |
---|
16 | # Read model data |
---|
17 | p2=util.get_output('urban_flow0p05.sww',0.001) |
---|
18 | p=util.get_centroids(p2,velocity_extrapolation=True) |
---|
19 | |
---|
20 | |
---|
21 | # Read experimental data |
---|
22 | data_dir='/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/tests/urban_flow/experimental_data/Isolated_Obstacle/Isolated Obstacle/' |
---|
23 | exp_data_h=data_dir+'building_gauges_h.txt' |
---|
24 | exp_data_uv=data_dir+'/gareths_edits/data.txt' |
---|
25 | |
---|
26 | # Dir to save figures |
---|
27 | fig_dir='./figures/' |
---|
28 | h_gauges=numpy.genfromtxt(exp_data_h, skip_header=2) |
---|
29 | uv_gauges=numpy.genfromtxt(exp_data_uv, skip_header=2) |
---|
30 | |
---|
31 | for i in range((Gauge_xy.shape[0])): |
---|
32 | Gauge=Gauge_xy[i,:] |
---|
33 | G_ind = ((p.x-Gauge[0])**2 + (p.y-Gauge[1])**2).argmin() |
---|
34 | |
---|
35 | pyplot.plot(p.time, p.stage[:,G_ind], 'o-', label='model') |
---|
36 | pyplot.plot(h_gauges[:,0], h_gauges[:,(i+1)],'-', label='data') |
---|
37 | fig_filename=fig_dir+'G'+str(i+1)+'_stage.png' |
---|
38 | pyplot.savefig(fig_filename) |
---|
39 | pyplot.legend() |
---|
40 | pyplot.clf() |
---|
41 | |
---|
42 | if(i<5): |
---|
43 | # Note -- Gauge 6 does not have velocity measurements |
---|
44 | pyplot.plot(p.time, p.xvel[:,G_ind], 'o-') |
---|
45 | pyplot.plot(uv_gauges[:,0], uv_gauges[:,2*i+1],'-') |
---|
46 | fig_filename=fig_dir+'G'+str(i+1)+'_xvel.png' |
---|
47 | pyplot.savefig(fig_filename) |
---|
48 | pyplot.clf() |
---|
49 | |
---|
50 | |
---|
51 | pyplot.plot(p.time, p.yvel[:,G_ind], 'o-') |
---|
52 | pyplot.plot(uv_gauges[:,0], uv_gauges[:,2*i+2],'-') |
---|
53 | fig_filename=fig_dir+'G'+str(i+1)+'_yvel.png' |
---|
54 | pyplot.savefig(fig_filename) |
---|
55 | pyplot.clf() |
---|
56 | |
---|
57 | |
---|
58 | ### Plot of experimental set-up |
---|
59 | pyplot.figure(figsize=(8,3)) |
---|
60 | pyplot.scatter(p.x, p.y, c=p.elev>0.2,edgecolors='none', s=5.0, marker='8') |
---|
61 | pyplot.gca().set_aspect('equal') |
---|
62 | pyplot.xlim((4,15)) |
---|
63 | pyplot.title('Zoom of the flume geometry') |
---|
64 | #pyplot.colorbar() |
---|
65 | # Add gauge locations |
---|
66 | for i in range(Gauge_xy.shape[0]): |
---|
67 | gauge_name='G' + str(i+1) |
---|
68 | pyplot.scatter(Gauge_xy[i,0], Gauge_xy[i,1],marker='x',color='white') |
---|
69 | pyplot.text(Gauge_xy[i,0], Gauge_xy[i,1], s=gauge_name, fontweight='black', color='white', ha='left') |
---|
70 | |
---|
71 | pyplot.text(7.0, 1.7, 'Reservoir \n Outflow',color='white', size=8) |
---|
72 | pyplot.quiver(7,1.5, 1.0, 0.0,color='white') |
---|
73 | pyplot.text(4.5, 1.0, 'Reservoir',color='white') |
---|
74 | |
---|
75 | pyplot.text(11.7, 1.5, 'Isolated \n Building',color='white',size=8) |
---|
76 | #pyplot.quiver(12.5,1.5, -1.0, 1.0, color='white') |
---|
77 | |
---|
78 | fig_filename=fig_dir+'Model_domain.png' |
---|
79 | pyplot.savefig(fig_filename, orientation='landscape') |
---|
80 | pyplot.clf() |
---|