source: production/onslow_2006/make_gauges.py @ 3261

Last change on this file since 3261 was 3188, checked in by sexton, 19 years ago

make gauges to compare MOST and ANUGA time series

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