1 | """Read in sww file, interpolate at specified locations and plot |
---|
2 | """ |
---|
3 | |
---|
4 | import project |
---|
5 | from pyvolution.util import file_function |
---|
6 | |
---|
7 | swwfile = project.outputdir + project.basename + '.sww' |
---|
8 | |
---|
9 | #gauges = [[0.000, 1.696]] #Boundary |
---|
10 | #gauges += [[4.521, 1.196], [4.521, 1.696], [4.521, 2.196]] #Ch 5-7-9 |
---|
11 | #gauge_names = ['Boundary', 'ch5', 'ch7', 'ch9'] |
---|
12 | #finaltime = 22.5 |
---|
13 | #timestep = 0.05 |
---|
14 | |
---|
15 | gauges = [[60000, 83000], |
---|
16 | [60000, 80000], |
---|
17 | [60000, 75000], |
---|
18 | [60000, 70000], |
---|
19 | [60000, 60000], |
---|
20 | [60000, 50000], |
---|
21 | [60000, 40000], |
---|
22 | [60000, 30000], |
---|
23 | [60000, 20000], |
---|
24 | [60000, 10000], |
---|
25 | [60000, 0]] |
---|
26 | #gauge_names = ['SW', 'N', 'N2', ] |
---|
27 | |
---|
28 | |
---|
29 | #Read model output |
---|
30 | from caching import cache |
---|
31 | #f = file_function(swwfile, |
---|
32 | # quantities = 'stage', |
---|
33 | # interpolation_points = gauges, |
---|
34 | # verbose = True) |
---|
35 | |
---|
36 | f = cache(file_function, swwfile, |
---|
37 | {'quantities': 'stage', |
---|
38 | 'interpolation_points': gauges, |
---|
39 | 'verbose': True}, |
---|
40 | dependencies = [swwfile], |
---|
41 | verbose = True) |
---|
42 | |
---|
43 | print f |
---|
44 | model_time = f.T |
---|
45 | |
---|
46 | |
---|
47 | for k, g in enumerate(gauges): |
---|
48 | model_values = [] |
---|
49 | for i, t in enumerate(f.T): |
---|
50 | val = f(t, point_id = k)[0] |
---|
51 | model_values.append(val) |
---|
52 | |
---|
53 | from pylab import * |
---|
54 | ion() |
---|
55 | hold(False) |
---|
56 | plot(model_time, model_values, '-b') |
---|
57 | name = str(g) |
---|
58 | title('Gauge %s' %name) |
---|
59 | savefig(name, dpi = 300) |
---|
60 | |
---|
61 | raw_input('Next') |
---|
62 | show() |
---|
63 | |
---|