1 | """ |
---|
2 | Quick plot of the Carrier-Greenspan outputs |
---|
3 | |
---|
4 | """ |
---|
5 | import anuga.utilities.plot_utils as util |
---|
6 | from matplotlib import pyplot as pyplot |
---|
7 | from carrier_greenspan_analytic import * |
---|
8 | |
---|
9 | p_st = util.get_output('carrier_greenspan.sww') |
---|
10 | p2_st=util.get_centroids(p_st) |
---|
11 | |
---|
12 | v = p2_st.y[10] |
---|
13 | v2=(p2_st.y==v) |
---|
14 | |
---|
15 | W1, P1, Z1, H1, U1 = analytic_cg(p2_st.x[v2], p2_st.time[55], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
16 | W2, P2, Z2, H2, U2 = analytic_cg(p2_st.x[v2], p2_st.time[56], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
17 | W3, P3, Z3, H3, U3 = analytic_cg(p2_st.x[v2], p2_st.time[57], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
18 | W4, P4, Z4, H4, U4 = analytic_cg(p2_st.x[v2], p2_st.time[58], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
19 | W5, P5, Z5, H5, U5 = analytic_cg(p2_st.x[v2], p2_st.time[59], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
20 | W6, P6, Z6, H6, U6 = analytic_cg(p2_st.x[v2], p2_st.time[60], h0=5e2, L=5e4, a=1.0, Tp=900.0) |
---|
21 | |
---|
22 | #Plot the stages############################################################## |
---|
23 | pyplot.clf() |
---|
24 | pyplot.ion() |
---|
25 | pyplot.plot(p2_st.x[v2], p2_st.stage[55,v2], 'b.', label='numerical') # 1*T/6 |
---|
26 | pyplot.plot(p2_st.x[v2], p2_st.stage[56,v2], 'b.') # 2*T/6 |
---|
27 | pyplot.plot(p2_st.x[v2], p2_st.stage[57,v2], 'b.') # 3*T/6 |
---|
28 | pyplot.plot(p2_st.x[v2], p2_st.stage[58,v2], 'b.') # 4*T/6 |
---|
29 | pyplot.plot(p2_st.x[v2], p2_st.stage[59,v2], 'b.') # 5*T/6 |
---|
30 | pyplot.plot(p2_st.x[v2], p2_st.stage[60,v2], 'b.') # 6*T/6 |
---|
31 | |
---|
32 | pyplot.plot(p2_st.x[v2], W1,'r-', label='analytical') |
---|
33 | pyplot.plot(p2_st.x[v2], W2,'r-') |
---|
34 | pyplot.plot(p2_st.x[v2], W3,'r-') |
---|
35 | pyplot.plot(p2_st.x[v2], W4,'r-') |
---|
36 | pyplot.plot(p2_st.x[v2], W5,'r-') |
---|
37 | pyplot.plot(p2_st.x[v2], W6,'r-') |
---|
38 | |
---|
39 | |
---|
40 | pyplot.title('Stage at several instants in time') |
---|
41 | pyplot.ylim(-5.0,5.0) |
---|
42 | pyplot.legend(loc=2) |
---|
43 | pyplot.savefig('stage_plot.png') |
---|
44 | |
---|
45 | |
---|
46 | #Plot the momentums########################################################## |
---|
47 | pyplot.clf() |
---|
48 | pyplot.ion() |
---|
49 | pyplot.plot(p2_st.x[v2], p2_st.xmom[55,v2], 'b.', label='numerical') # 1*T/6 |
---|
50 | pyplot.plot(p2_st.x[v2], p2_st.xmom[56,v2], 'b.') # 2*T/6 |
---|
51 | pyplot.plot(p2_st.x[v2], p2_st.xmom[57,v2], 'b.') # 3*T/6 |
---|
52 | pyplot.plot(p2_st.x[v2], p2_st.xmom[58,v2], 'b.') # 4*T/6 |
---|
53 | pyplot.plot(p2_st.x[v2], p2_st.xmom[59,v2], 'b.') # 5*T/6 |
---|
54 | pyplot.plot(p2_st.x[v2], p2_st.xmom[60,v2], 'b.') # 6*T/6 |
---|
55 | |
---|
56 | pyplot.plot(p2_st.x[v2], P1,'r-', label='analytical') |
---|
57 | pyplot.plot(p2_st.x[v2], P2,'r-') |
---|
58 | pyplot.plot(p2_st.x[v2], P3,'r-') |
---|
59 | pyplot.plot(p2_st.x[v2], P4,'r-') |
---|
60 | pyplot.plot(p2_st.x[v2], P5,'r-') |
---|
61 | pyplot.plot(p2_st.x[v2], P6,'r-') |
---|
62 | |
---|
63 | pyplot.title('Xmomentum at several instants in time') |
---|
64 | pyplot.legend(loc=4) |
---|
65 | pyplot.savefig('xmom_plot.png') |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | #Plot the velocities######################################################### |
---|
70 | pyplot.clf() |
---|
71 | pyplot.ion() |
---|
72 | pyplot.plot(p2_st.x[v2], p2_st.xvel[55,v2], 'b.', label='numerical') # 1*T/6 |
---|
73 | pyplot.plot(p2_st.x[v2], p2_st.xvel[56,v2], 'b.') # 2*T/6 |
---|
74 | pyplot.plot(p2_st.x[v2], p2_st.xvel[57,v2], 'b.') # 3*T/6 |
---|
75 | pyplot.plot(p2_st.x[v2], p2_st.xvel[58,v2], 'b.') # 4*T/6 |
---|
76 | pyplot.plot(p2_st.x[v2], p2_st.xvel[59,v2], 'b.') # 5*T/6 |
---|
77 | pyplot.plot(p2_st.x[v2], p2_st.xvel[60,v2], 'b.') # 6*T/6 |
---|
78 | |
---|
79 | pyplot.plot(p2_st.x[v2], U1,'r-', label='analytical') |
---|
80 | pyplot.plot(p2_st.x[v2], U2,'r-') |
---|
81 | pyplot.plot(p2_st.x[v2], U3,'r-') |
---|
82 | pyplot.plot(p2_st.x[v2], U4,'r-') |
---|
83 | pyplot.plot(p2_st.x[v2], U5,'r-') |
---|
84 | pyplot.plot(p2_st.x[v2], U6,'r-') |
---|
85 | |
---|
86 | pyplot.title('Velocity at several instants in time') |
---|
87 | pyplot.legend(loc=3) |
---|
88 | pyplot.savefig('xvel_plot.png') |
---|
89 | |
---|