1 | """ Make a line of gauges from outside boundary to near centre polygon |
---|
2 | for Onslow study to look at MOST wave and compare to ANUGA output |
---|
3 | """ |
---|
4 | import project |
---|
5 | from pylab import plot, xlabel, ylabel, title, ion, axis, savefig, close |
---|
6 | from utilities.polygon import poly_xy |
---|
7 | from Numeric import arange |
---|
8 | from pmesh.create_mesh import convert_points_from_latlon_to_utm |
---|
9 | |
---|
10 | x_bound, y_bound = poly_xy(project.polyAll) |
---|
11 | |
---|
12 | MOST_south = project.south |
---|
13 | MOST_north = project.north |
---|
14 | MOST_east = project.east |
---|
15 | MOST_west = project.west |
---|
16 | p0 = [MOST_south, MOST_west] |
---|
17 | p1 = [MOST_south, MOST_east] |
---|
18 | p2 = [MOST_north, MOST_east] |
---|
19 | p3 = [MOST_north, MOST_west] |
---|
20 | MOSTpoly, zone = convert_points_from_latlon_to_utm([p0, p1, p2, p3]) |
---|
21 | |
---|
22 | MOSTymax = 0 |
---|
23 | MOSTymin = 7800000.0 |
---|
24 | MOSTxmax = 0 |
---|
25 | MOSTxmin = 7800000.0 |
---|
26 | for i, point in enumerate(MOSTpoly): |
---|
27 | x = point[0] |
---|
28 | y = point[1] |
---|
29 | if y > MOSTymax: MOSTymax = y |
---|
30 | if y < MOSTymin: MOSTymin = y |
---|
31 | if x > MOSTxmax: MOSTxmax = x |
---|
32 | if x < MOSTxmin: MOSTxmin = x |
---|
33 | |
---|
34 | MOSTymax = MOSTymax-3000.0 |
---|
35 | print 'MOST clipping: ', MOSTxmin, MOSTxmax, MOSTymin, MOSTymax |
---|
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 | for i, point in enumerate(d): |
---|
57 | x = point[0] |
---|
58 | y = point[1] |
---|
59 | m = (y-y2)/(x-x2) |
---|
60 | c = y2-m*x2 |
---|
61 | if m > 0: |
---|
62 | plotx = arange(MOSTxmin,MOSTxmax,1000.0) |
---|
63 | for j, xpoint in enumerate(plotx): |
---|
64 | ypoint = m*xpoint+c |
---|
65 | if ypoint > testy and ypoint <= d0[1]: |
---|
66 | #if ypoint >= testy and ypoint <= MOSTymax: |
---|
67 | if xpoint > MOSTxmin and xpoint < MOSTxmax: |
---|
68 | xplot.append(xpoint) |
---|
69 | yplot.append(ypoint) |
---|
70 | name = 'Point%d' %count |
---|
71 | count += 1 |
---|
72 | s = '%.2f,%.2f,%s,%.2f \n' %(xpoint,ypoint,name,0.0) |
---|
73 | fid.write(s) |
---|
74 | else: |
---|
75 | plotx = arange(MOSTxmin,MOSTxmax,5000.0) |
---|
76 | for j, xpoint in enumerate(plotx): |
---|
77 | ypoint = m*xpoint+c |
---|
78 | if ypoint > testy and ypoint < MOSTymax: #testy |
---|
79 | if xpoint > MOSTxmin and xpoint < MOSTxmax: |
---|
80 | xplot.append(xpoint) |
---|
81 | yplot.append(ypoint) |
---|
82 | name = 'Point%d' %count |
---|
83 | count += 1 |
---|
84 | s = '%.2f,%.2f,%s,%.2f \n' %(xpoint,ypoint,name,0.0) |
---|
85 | fid.write(s) |
---|
86 | |
---|
87 | plot(x_bound, y_bound, xplot, yplot,'b+') |
---|
88 | |
---|
89 | axis([240000,340000, miny, maxy]) |
---|
90 | savefig('boundarycomparison') |
---|
91 | close('all') |
---|