1 | # -*- coding: cp1252 -*- |
---|
2 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
3 | """ |
---|
4 | |
---|
5 | from os import sep, environ, getenv, getcwd |
---|
6 | from os.path import expanduser |
---|
7 | import sys |
---|
8 | from time import localtime, strftime, gmtime |
---|
9 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
10 | from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees, convert_points_from_latlon_to_utm |
---|
11 | |
---|
12 | if sys.platform == 'win32': |
---|
13 | home = getenv('INUNDATIONHOME') |
---|
14 | user = getenv('USERPROFILE') |
---|
15 | |
---|
16 | else: |
---|
17 | home = getenv('INUNDATIONHOME', sep+'d'+sep+'xrd'+sep+'gem'+sep+'2'+sep+'ramp'+sep+'risk_assessment_methods_project'+sep+'inundation') |
---|
18 | user = getenv('LOGNAME') |
---|
19 | print 'USER:', user |
---|
20 | |
---|
21 | # INUNDATIONHOME is the inundation directory, not the data directory. |
---|
22 | home += sep +'data' |
---|
23 | |
---|
24 | #Making assumptions about the location of scenario data |
---|
25 | state = 'western_australia' |
---|
26 | scenario_dir_name = 'broome_tsunami_scenario_2006' |
---|
27 | |
---|
28 | # onshore data provided by WA DLI |
---|
29 | onshore_name = '' # original |
---|
30 | |
---|
31 | # offshore data provided by WA DPI |
---|
32 | offshore_name_dpi1 = '' |
---|
33 | |
---|
34 | # AHO data |
---|
35 | offshore_name1 = 'xy100003760' |
---|
36 | |
---|
37 | # developed by NM&I |
---|
38 | coast_name = 'coastline_points' |
---|
39 | |
---|
40 | boundary_basename = 'SU-AU' # Mw ? |
---|
41 | |
---|
42 | #swollen/ all data output |
---|
43 | basename = 'source' |
---|
44 | codename = 'project.py' |
---|
45 | |
---|
46 | #Derive subdirectories and filenames |
---|
47 | local_time = strftime('%Y%m%d_%H%M%S',gmtime()) |
---|
48 | meshdir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'meshes'+sep |
---|
49 | datadir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'topographies'+sep |
---|
50 | gaugedir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'gauges'+sep |
---|
51 | polygondir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'polygons'+sep |
---|
52 | boundarydir = home+sep+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'boundaries'+sep |
---|
53 | outputdir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'outputs'+sep |
---|
54 | outputtimedir = outputdir + local_time + sep |
---|
55 | polygondir = home+sep+state+sep+scenario_dir_name+sep+'anuga'+sep+'polygons'+sep |
---|
56 | |
---|
57 | gauge_filename = gaugedir + 'broome_gauges.csv' |
---|
58 | |
---|
59 | codedir = getcwd()+sep |
---|
60 | codedirname = codedir + 'project.py' |
---|
61 | meshname = outputtimedir + 'mesh_' + basename |
---|
62 | |
---|
63 | # Necessary if using point datasets, rather than grid |
---|
64 | onshore_dem_name = datadir + onshore_name |
---|
65 | offshore_dem_name_local1 = datadir + offshore_name_dpi1 |
---|
66 | offshore_dem_name_aho1 = datadir + offshore_name1 |
---|
67 | |
---|
68 | coast_dem_name = datadir + coast_name |
---|
69 | |
---|
70 | combined_dem_name = datadir + 'broome_combined_elevation' |
---|
71 | |
---|
72 | ############################### |
---|
73 | # Domain definitions |
---|
74 | ############################### |
---|
75 | |
---|
76 | # bounding box for clipping MOST/URS output (much bigger than study area) |
---|
77 | south = degminsec2decimal_degrees(-19,0,0) |
---|
78 | north = degminsec2decimal_degrees(-17,15,0) |
---|
79 | west = degminsec2decimal_degrees(120,0,0) |
---|
80 | east = degminsec2decimal_degrees(122,30,0) |
---|
81 | |
---|
82 | d0 = [south, west] |
---|
83 | d1 = [south, east] |
---|
84 | d2 = [north, east] |
---|
85 | d3 = [north, west] |
---|
86 | poly_bc, zone = convert_points_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
87 | refzone = zone |
---|
88 | |
---|
89 | # bounding polygon for study area |
---|
90 | polyAll = read_polygon(polygondir+'extent.csv') |
---|
91 | |
---|
92 | # plot bounding polygon and make sure BC info surrounds it |
---|
93 | plot_polygons([polyAll, poly_bc],'boundingpoly',verbose=False) |
---|
94 | print 'Area of bounding polygon', polygon_area(polyAll)/1000000.0 |
---|
95 | |
---|
96 | ################################################################### |
---|
97 | # Clipping regions for export to asc and regions for clipping data |
---|
98 | ################################################################### |
---|
99 | |
---|
100 | # clipping 20m onshore data set |
---|
101 | #eastingmin = 520000 |
---|
102 | #eastingmax = 536000 |
---|
103 | #northingmin = 5245000 |
---|
104 | #northingmax = 5260000 |
---|
105 | |
---|
106 | ############################### |
---|
107 | # Interior region definitions |
---|
108 | ############################### |
---|
109 | |
---|
110 | # broome digitized polygons |
---|
111 | poly_broome1 = read_polygon(polygondir+'Broome_Local_Polygon.csv') |
---|
112 | poly_broome2 = read_polygon(polygondir+'Broome_Close2.csv') |
---|
113 | poly_broome3 = read_polygon(polygondir+'Broome_Coast.csv') |
---|
114 | poly_broome4 = read_polygon(polygondir+'Cable_Beach.csv') |
---|
115 | |
---|
116 | plot_polygons([polyAll,poly_broome1,poly_broome2,poly_broome3,poly_broome4],'boundingpoly2',verbose=False) |
---|
117 | print 'Area of local polygon', polygon_area(poly_broome1)/1000000.0 |
---|
118 | print 'Area of close polygon', polygon_area(poly_broome2)/1000000.0 |
---|
119 | print 'Area of coastal polygon', polygon_area(poly_broome3)/1000000.0 |
---|
120 | print 'Area of cable beach polygon', polygon_area(poly_broome4)/1000000.0 |
---|
121 | |
---|
122 | for i in poly_broome3: |
---|
123 | v = is_inside_polygon(i,poly_broome1, verbose=False) |
---|
124 | if v == False: print v |
---|