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 | timedir = '20070906_061418_run_final_1.5_jsexton_exmouth_original' |
---|
10 | #timedir = '20070608_060316_run_final_1.5_onslow_nbartzis' |
---|
11 | #timedir = '20070613_034754_run_final_1.5_dampier_nbartzis' |
---|
12 | |
---|
13 | def get_data(filename): |
---|
14 | fid = open(filename) |
---|
15 | lines = fid.readlines() |
---|
16 | fid.close() |
---|
17 | stage = [] |
---|
18 | for line in lines[1:]: |
---|
19 | fields = line.split(',') |
---|
20 | stage.append(float(fields[2])) |
---|
21 | return max(stage), min(stage) |
---|
22 | |
---|
23 | files = ['stage0_convert.csv','stage5_convert.csv','stage20_convert.csv','stage80_convert.csv'] |
---|
24 | depth = [0,5,20,80] |
---|
25 | stage_max = [] |
---|
26 | stage_min = [] |
---|
27 | |
---|
28 | for thefile in files: |
---|
29 | |
---|
30 | filename = directory + timedir + sep + thefile |
---|
31 | max_stage, min_stage = get_data(filename) |
---|
32 | stage_max.append(max_stage) |
---|
33 | stage_min.append(min_stage) |
---|
34 | |
---|
35 | from anuga.abstract_2d_finite_volumes.util import greens_law |
---|
36 | from Numeric import arange |
---|
37 | d1 = 80. |
---|
38 | d2 = arange(d1,0.15,-0.1) |
---|
39 | h1 = max_stage |
---|
40 | #h1 = 4.0 |
---|
41 | green = [] |
---|
42 | for d in d2: |
---|
43 | h2 = greens_law(d1,d,h1) |
---|
44 | green.append(h2) |
---|
45 | |
---|
46 | ion() |
---|
47 | plot(depth,stage_max,'ob',d2,green,'-g',depth,stage_max,'-b') |
---|
48 | xlabel('depth (m)') |
---|
49 | ylabel('stage (m)') |
---|
50 | title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
51 | Magnitude 9.3 event (Java) at Onslow') |
---|
52 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
53 | #Magnitude 9.1 event (Sumba) at Onslow') |
---|
54 | #title('ANUGA modelled maximum stage versus Green\'s approximation \n \ |
---|
55 | #Magnitude 9.0 event (Sumba) at Onslow') |
---|
56 | legend(['ANUGA','Green\'s law']) |
---|
57 | axis([-5,85,min(stage_max)*0.9,max(stage_max)*1.1]) |
---|
58 | grid(True) |
---|
59 | #savefig('stratification_onslow_gun') |
---|
60 | savefig('stratification_exmouth_gun') |
---|
61 | #savefig('stratification_dampier_gun') |
---|
62 | |
---|
63 | close('all') |
---|
64 | |
---|