1 | """ Make a line of gauges from near the boundary to near centre polygon |
---|
2 | for Onslow study to look at MOST wave and compare to ANUGA output |
---|
3 | Output from here is used as the gauge file input in MOST_timeseries.py |
---|
4 | """ |
---|
5 | import project |
---|
6 | from pylab import plot, xlabel, ylabel, title, ion, axis, savefig, close, text |
---|
7 | from anuga.utilities.polygon import poly_xy, is_inside_polygon |
---|
8 | from Numeric import arange |
---|
9 | from anuga.pmesh.create_mesh import convert_from_latlon_to_utm |
---|
10 | |
---|
11 | x_bound, y_bound = poly_xy(project.polyAll) |
---|
12 | |
---|
13 | MOST_south = project.south |
---|
14 | MOST_north = project.north |
---|
15 | MOST_east = project.east |
---|
16 | MOST_west = project.west |
---|
17 | p0 = [MOST_south, MOST_west] |
---|
18 | p1 = [MOST_south, MOST_east] |
---|
19 | p2 = [MOST_north, MOST_east] |
---|
20 | p3 = [MOST_north, MOST_west] |
---|
21 | MOSTpoly, zone = convert_from_latlon_to_utm([p0, p1, p2, p3]) |
---|
22 | |
---|
23 | MOSTymax = 0 |
---|
24 | MOSTymin = 7800000.0 |
---|
25 | MOSTxmax = 0 |
---|
26 | MOSTxmin = 7800000.0 |
---|
27 | for i, point in enumerate(MOSTpoly): |
---|
28 | x = point[0] |
---|
29 | y = point[1] |
---|
30 | if y > MOSTymax: MOSTymax = y |
---|
31 | if y < MOSTymin: MOSTymin = y |
---|
32 | if x > MOSTxmax: MOSTxmax = x |
---|
33 | if x < MOSTxmin: MOSTxmin = x |
---|
34 | |
---|
35 | MOSTymax = MOSTymax-3000.0 |
---|
36 | # nominated point in centre region for Onslow |
---|
37 | x2 = 305000.0 |
---|
38 | y2 = 7605000.0 |
---|
39 | testy = 7625000.0 |
---|
40 | |
---|
41 | d0 = project.d0 |
---|
42 | d1 = project.d1 |
---|
43 | d2 = project.d2 |
---|
44 | d3 = project.d3 |
---|
45 | |
---|
46 | d = [d0, d1, d2, d3] |
---|
47 | ion() |
---|
48 | fid = open(project.gauge_comparison,'w') |
---|
49 | s = 'Easting,Northing,Name,Elevation \n' |
---|
50 | fid.write(s) |
---|
51 | count = 0 |
---|
52 | miny = 7580000.0 |
---|
53 | maxy = 7800000.0 |
---|
54 | xplot = [] |
---|
55 | yplot = [] |
---|
56 | names = [] |
---|
57 | for i, point in enumerate(d): |
---|
58 | x = point[0] |
---|
59 | y = point[1] |
---|
60 | m = (y-y2)/(x-x2) |
---|
61 | c = y2-m*x2 |
---|
62 | if m > 0: |
---|
63 | plotx = arange(MOSTxmin,MOSTxmax,1000.0) |
---|
64 | for j, xpoint in enumerate(plotx): |
---|
65 | ypoint = m*xpoint+c |
---|
66 | test = is_inside_polygon([xpoint,ypoint],project.polyAll,closed=True) |
---|
67 | if test == True: |
---|
68 | if ypoint > testy and ypoint < MOSTymax: |
---|
69 | xplot.append(xpoint) |
---|
70 | yplot.append(ypoint) |
---|
71 | thisname = 'Point%d' %count |
---|
72 | names.append(thisname) |
---|
73 | count += 1 |
---|
74 | s = '%.2f,%.2f,%s,%.2f \n' %(xpoint,ypoint,thisname,0.0) |
---|
75 | fid.write(s) |
---|
76 | else: |
---|
77 | plotx = arange(MOSTxmin,MOSTxmax,5000.0) |
---|
78 | for j, xpoint in enumerate(plotx): |
---|
79 | ypoint = m*xpoint+c |
---|
80 | test = is_inside_polygon([xpoint,ypoint],project.polyAll,closed=True) |
---|
81 | if test == True: |
---|
82 | if ypoint > testy and ypoint < MOSTymax: |
---|
83 | xplot.append(xpoint) |
---|
84 | yplot.append(ypoint) |
---|
85 | thisname = 'Point%d' %count |
---|
86 | names.append(thisname) |
---|
87 | count += 1 |
---|
88 | s = '%.2f,%.2f,%s,%.2f \n' %(xpoint,ypoint,thisname,0.0) |
---|
89 | fid.write(s) |
---|
90 | |
---|
91 | plot(x_bound, y_bound, xplot, yplot,'b+') |
---|
92 | for i, string in enumerate(names): |
---|
93 | if xplot[i] > 240000 and xplot[i] < 340000: |
---|
94 | text(xplot[i],yplot[i],string,fontsize=7) |
---|
95 | |
---|
96 | axis([240000,340000, miny, maxy]) |
---|
97 | savefig('boundarycomparison') |
---|
98 | close('all') |
---|