1 | """Read in contour data file and plot max and min |
---|
2 | """ |
---|
3 | |
---|
4 | import project |
---|
5 | from pylab import plot, xlabel, ylabel, savefig, ion, close, axis, title, legend, grid |
---|
6 | from os import sep |
---|
7 | |
---|
8 | directory = project.outputdir |
---|
9 | |
---|
10 | #timedir = '20070618_063824_run_final_2.4_onslow_nbartzis' |
---|
11 | timedir = '20070620_044413_run_final_2.4_exmouth_nbartzis' |
---|
12 | #timedir = '20070419_065050_run_final_2.4_dampier_nbartzis' |
---|
13 | |
---|
14 | def get_data(filename): |
---|
15 | fid = open(filename) |
---|
16 | lines = fid.readlines() |
---|
17 | fid.close() |
---|
18 | stage = [] |
---|
19 | for line in lines[1:]: |
---|
20 | fields = line.split(',') |
---|
21 | stage.append(float(fields[2])) |
---|
22 | return max(stage), min(stage) |
---|
23 | |
---|
24 | # Dampier |
---|
25 | files = ['stage0_convert_d.csv','stage5_convert_d.csv','stage20_convert_d.csv','stage80_convert_d.csv'] |
---|
26 | depth = [0,5,20,80] |
---|
27 | # Karratha |
---|
28 | #files = ['stage0_convert_k.csv','stage5_convert_k.csv','stage20_convert_k.csv','stage80_convert_k.csv'] |
---|
29 | |
---|
30 | stage_max = [] |
---|
31 | stage_min = [] |
---|
32 | |
---|
33 | for thefile in files: |
---|
34 | |
---|
35 | filename = directory + timedir + sep + thefile |
---|
36 | max_stage, min_stage = get_data(filename) |
---|
37 | stage_max.append(max_stage) |
---|
38 | stage_min.append(min_stage) |
---|
39 | |
---|
40 | from anuga.abstract_2d_finite_volumes.util import greens_law |
---|
41 | from Numeric import arange |
---|
42 | d1 = 80. |
---|
43 | d2 = arange(d1,0.15,-0.1) |
---|
44 | h1 = max_stage |
---|
45 | #h1 = 4.0 |
---|
46 | green = [] |
---|
47 | for d in d2: |
---|
48 | h2 = greens_law(d1,d,h1) |
---|
49 | green.append(h2) |
---|
50 | |
---|
51 | ion() |
---|
52 | plot(depth,stage_max,'ob',d2,green,'-g',depth,stage_max,'-b') |
---|
53 | xlabel('depth (m)') |
---|
54 | ylabel('stage (m)') |
---|
55 | # Dampier |
---|
56 | title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
57 | Magnitude 9.3 event (Java) at Dampier') |
---|
58 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
59 | #Magnitude 9.1 event (Sumba) at Dampier') |
---|
60 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
61 | #Magnitude 9.0 event (Sumba) at Dampier') |
---|
62 | # Karratha |
---|
63 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
64 | #Magnitude 9.3 event (Java) at Karratha') |
---|
65 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
66 | #Magnitude 9.1 event (Sumba) at Karratha') |
---|
67 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
68 | #Magnitude 9.0 event (Sumba) at Karratha') |
---|
69 | |
---|
70 | legend(['ANUGA','Green\'s law']) |
---|
71 | axis([-5,85,min(stage_max)*0.9,max(stage_max)*1.1]) |
---|
72 | grid(True) |
---|
73 | #savefig('stratification_onslow_gun') |
---|
74 | savefig('stratification_exmouth_gun') |
---|
75 | #savefig('stratification_dampier_gun') |
---|
76 | |
---|
77 | close('all') |
---|
78 | |
---|