source: trunk/anuga_work/development/gareth/tests/urban_flow/plotme.py @ 8523

Last change on this file since 8523 was 8523, checked in by davies, 12 years ago

Adding 'anuga_tsunami' directory for version suited to tsunami

File size: 2.8 KB
Line 
1### Python code to do plotting of this experiment.
2
3import util
4import numpy
5from matplotlib import pyplot as pyplot
6
7# Define gauge points, following Soares Frazao et al (2008)
8offset=numpy.array([7.7,+1.8])
9Gauge_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
17p2=util.get_output('urban_flow0p05.sww',0.001)
18p=util.get_centroids(p2,velocity_extrapolation=True)
19
20
21# Read experimental data
22data_dir='/home/gareth/storage/anuga_clean/anuga_jan12/trunk/anuga_work/development/gareth/tests/urban_flow/experimental_data/Isolated_Obstacle/Isolated Obstacle/'
23exp_data_h=data_dir+'building_gauges_h.txt'
24exp_data_uv=data_dir+'/gareths_edits/data.txt'
25
26# Dir to save figures
27fig_dir='./figures/'
28h_gauges=numpy.genfromtxt(exp_data_h, skip_header=2)
29uv_gauges=numpy.genfromtxt(exp_data_uv, skip_header=2)
30
31for 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
59pyplot.figure(figsize=(8,3))
60pyplot.scatter(p.x, p.y, c=p.elev>0.2,edgecolors='none', s=5.0, marker='8')
61pyplot.gca().set_aspect('equal')
62pyplot.xlim((4,15))
63pyplot.title('Zoom of the flume geometry')
64#pyplot.colorbar()
65# Add gauge locations
66for 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
71pyplot.text(7.0, 1.7, 'Reservoir \n Outflow',color='white', size=8)
72pyplot.quiver(7,1.5, 1.0, 0.0,color='white')
73pyplot.text(4.5, 1.0, 'Reservoir',color='white')
74
75pyplot.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
78fig_filename=fig_dir+'Model_domain.png'
79pyplot.savefig(fig_filename, orientation='landscape')
80pyplot.clf()
Note: See TracBrowser for help on using the repository browser.