1 | """ |
---|
2 | Generates ascii grids of nominated areas - |
---|
3 | Input: sww file from run_perth.py |
---|
4 | boundaries for grids from project.py |
---|
5 | Outputs: ascii grids of specified variables |
---|
6 | Stored in the 'outputs_dir' folder for respective .sww file |
---|
7 | |
---|
8 | Note: |
---|
9 | If producing a grid for the enitre extent cellsize should be greater than 30m |
---|
10 | If producing grids for inundation area resolution should be greater than mesh (ie ~22m) |
---|
11 | """ |
---|
12 | |
---|
13 | import project, os |
---|
14 | import sys |
---|
15 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
16 | |
---|
17 | from anuga.shallow_water.data_manager import sww2dem |
---|
18 | from os import sep |
---|
19 | |
---|
20 | directory = project.output_dir |
---|
21 | |
---|
22 | #time_dir = '20080526_104946_run_final_0.6_test_kvanputt' |
---|
23 | #time_dir = '20080530_170833_run_final_0.6_exmouth_kvanputt' |
---|
24 | time_dir1 = '20080815_103442_run_final_0.0_polyline_alpha0.1_kvanputt' |
---|
25 | time_dir2 = '20080909_151438_run_final_0.0_polyline_alpha0.1_kvanputt' |
---|
26 | |
---|
27 | #cellsize = 20 |
---|
28 | cellsize = 30 |
---|
29 | #timestep = 0 |
---|
30 | #area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham'] |
---|
31 | area = ['All'] |
---|
32 | #var = [1,2] # Absolute momentum and depth |
---|
33 | #var = [2] # depth |
---|
34 | var = [0,4] #stage and elevation |
---|
35 | |
---|
36 | time_dir = [time_dir1, time_dir2] |
---|
37 | for time_dir in time_dirs: |
---|
38 | |
---|
39 | name1 = directory+time_dir+sep+project.scenario_name |
---|
40 | name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything |
---|
41 | |
---|
42 | names = [name1, name2] |
---|
43 | for name in names: |
---|
44 | |
---|
45 | for which_area in area: |
---|
46 | if which_area == 'All': |
---|
47 | |
---|
48 | if which_area == 'Geordie': |
---|
49 | easting_min = project.xminGeordie |
---|
50 | easting_max = project.xmaxGeordie |
---|
51 | northing_min = project.yminGeordie |
---|
52 | northing_max = project.ymaxGeordie |
---|
53 | |
---|
54 | if which_area == 'Sorrento': |
---|
55 | easting_min = project.xminSorrento |
---|
56 | easting_max = project.xmaxSorrento |
---|
57 | northing_min = project.yminSorrento |
---|
58 | northing_max = project.ymaxSorrento |
---|
59 | |
---|
60 | if which_area == 'Fremantle': |
---|
61 | easting_min = project.xminFremantle |
---|
62 | easting_max = project.xmaxFremantle |
---|
63 | northing_min = project.yminFremantle |
---|
64 | northing_max = project.ymaxFremantle |
---|
65 | |
---|
66 | if which_area == 'Rockingham': |
---|
67 | easting_min = project.xminRockingham |
---|
68 | easting_max = project.xmaxRockingham |
---|
69 | northing_min = project.yminRockingham |
---|
70 | northing_max = project.ymaxRockingham |
---|
71 | |
---|
72 | |
---|
73 | for which_var in var: |
---|
74 | if which_var == 0: # Stage |
---|
75 | outname = name + which_area + '_stage' |
---|
76 | quantityname = 'stage' |
---|
77 | |
---|
78 | if which_var == 1: # Absolute Momentum |
---|
79 | outname = name + which_area + '_momentum' |
---|
80 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5' |
---|
81 | |
---|
82 | if which_var == 2: # Depth |
---|
83 | outname = name + which_area + '_depth' |
---|
84 | quantityname = 'stage-elevation' |
---|
85 | |
---|
86 | if which_var == 3: # Speed |
---|
87 | outname = name + which_area + '_speed' |
---|
88 | #quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6/(stage-elevation))' #Speed |
---|
89 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)' #Speed |
---|
90 | |
---|
91 | if which_var == 4: # Elevation |
---|
92 | outname = name + which_area + '_elevation' |
---|
93 | quantityname = 'elevation' #Elevation |
---|
94 | |
---|
95 | if which_area == 'All' |
---|
96 | print 'start sww2dem',which_area |
---|
97 | sww2dem(name, basename_out = outname, |
---|
98 | quantity = quantityname, |
---|
99 | #timestep = timestep, |
---|
100 | cellsize = cellsize, |
---|
101 | reduction = max, |
---|
102 | verbose = True, |
---|
103 | format = 'asc') |
---|
104 | |
---|
105 | else: |
---|
106 | print 'start sww2dem',which_area, easting_min |
---|
107 | sww2dem(name, basename_out = outname, |
---|
108 | quantity = quantityname, |
---|
109 | #timestep = timestep, |
---|
110 | cellsize = cellsize, |
---|
111 | easting_min = easting_min, |
---|
112 | easting_max = easting_max, |
---|
113 | northing_min = northing_min, |
---|
114 | northing_max = northing_max, |
---|
115 | reduction = max, |
---|
116 | verbose = True, |
---|
117 | format = 'asc') |
---|
118 | |
---|