1 | """Read in sww file, interpolate at specified locations and plot |
---|
2 | """ |
---|
3 | |
---|
4 | import project |
---|
5 | from pyvolution.util import file_function |
---|
6 | from pyvolution.coordinate_transforms.redfearn import degminsec2decimal_degrees, redfearn |
---|
7 | |
---|
8 | #swwfile = project.outputdir + project.basename + '.sww' |
---|
9 | swwfile = project.outputname + '_0.0tide' + '.sww' |
---|
10 | #swwfile = project.outputdir + 'karratha_100m_12m.sww' |
---|
11 | |
---|
12 | #MOST Boundary directly north of Legendre island |
---|
13 | y = project.north |
---|
14 | x = (project.p3[1] + project.p4[1])/2 #?????// |
---|
15 | z, easting, northing = redfearn(y, x) |
---|
16 | |
---|
17 | |
---|
18 | #From Neil |
---|
19 | gauges = [[easting, northing], |
---|
20 | [470882, 7717952], |
---|
21 | [469390, 7715426], |
---|
22 | [469214, 7714979], |
---|
23 | [468899, 7715177], |
---|
24 | [469038, 7715725], |
---|
25 | [470285, 7717470]] |
---|
26 | |
---|
27 | |
---|
28 | |
---|
29 | #gauge_names = ['MOST', |
---|
30 | # 'Gauge_1', 'Gauge_2', 'Gauge_3', |
---|
31 | # 'Gauge_4', 'Gauge_5', 'Gauge_6'] |
---|
32 | |
---|
33 | |
---|
34 | #Read model output |
---|
35 | from caching import cache |
---|
36 | #f = file_function(swwfile, |
---|
37 | # quantities = 'stage', |
---|
38 | # interpolation_points = gauges, |
---|
39 | # verbose = True) |
---|
40 | |
---|
41 | f = cache(file_function, swwfile, |
---|
42 | {'quantities': 'stage', |
---|
43 | 'interpolation_points': gauges, |
---|
44 | 'verbose': True}, |
---|
45 | compression = False, |
---|
46 | dependencies = [swwfile], |
---|
47 | verbose = True) |
---|
48 | |
---|
49 | print f |
---|
50 | model_time = f.T |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | for k, g in enumerate(gauges): |
---|
55 | model_values = [] |
---|
56 | for i, t in enumerate(f.T): |
---|
57 | val = f(t, point_id = k)[0] |
---|
58 | model_values.append(val) |
---|
59 | |
---|
60 | from pylab import * |
---|
61 | ion() |
---|
62 | hold(False) |
---|
63 | plot(model_time, model_values, '-b') |
---|
64 | name = 'Gauge_%d: %s' %(k, str(g)) |
---|
65 | title(name) |
---|
66 | |
---|
67 | savefig('Gauge_%d' %k) |
---|
68 | |
---|
69 | raw_input('Next') |
---|
70 | show() |
---|
71 | |
---|