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_dir1 = '20080912_154439_run_final_0.6_27255_alpha0.1_kvanputt' |
---|
26 | |
---|
27 | #cellsize = 20 |
---|
28 | cellsize = 30 |
---|
29 | #timestep = 0 |
---|
30 | #area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham'] |
---|
31 | area = 'All' |
---|
32 | which_area = area |
---|
33 | var = [1,2] # Absolute momentum and depth |
---|
34 | #var = [2] # depth |
---|
35 | #var = [0,4] #stage and elevation |
---|
36 | |
---|
37 | time_dirs = [time_dir1] |
---|
38 | for time_dir in time_dirs: |
---|
39 | |
---|
40 | name1 = directory+time_dir+sep+project.scenario_name |
---|
41 | #name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything |
---|
42 | |
---|
43 | names = [name1] |
---|
44 | for name in names: |
---|
45 | |
---|
46 | ## for which_area in area: |
---|
47 | ## if which_area == 'All': |
---|
48 | ## |
---|
49 | ## if which_area == 'Geordie': |
---|
50 | ## easting_min = project.xminGeordie |
---|
51 | ## easting_max = project.xmaxGeordie |
---|
52 | ## northing_min = project.yminGeordie |
---|
53 | ## northing_max = project.ymaxGeordie |
---|
54 | ## |
---|
55 | ## if which_area == 'Sorrento': |
---|
56 | ## easting_min = project.xminSorrento |
---|
57 | ## easting_max = project.xmaxSorrento |
---|
58 | ## northing_min = project.yminSorrento |
---|
59 | ## northing_max = project.ymaxSorrento |
---|
60 | ## |
---|
61 | ## if which_area == 'Fremantle': |
---|
62 | ## easting_min = project.xminFremantle |
---|
63 | ## easting_max = project.xmaxFremantle |
---|
64 | ## northing_min = project.yminFremantle |
---|
65 | ## northing_max = project.ymaxFremantle |
---|
66 | ## |
---|
67 | ## if which_area == 'Rockingham': |
---|
68 | ## easting_min = project.xminRockingham |
---|
69 | ## easting_max = project.xmaxRockingham |
---|
70 | ## northing_min = project.yminRockingham |
---|
71 | ## northing_max = project.ymaxRockingham |
---|
72 | |
---|
73 | |
---|
74 | for which_var in var: |
---|
75 | if which_var == 0: # Stage |
---|
76 | outname = name + which_area + '_stage' |
---|
77 | quantityname = 'stage' |
---|
78 | |
---|
79 | if which_var == 1: # Absolute Momentum |
---|
80 | outname = name + which_area + '_momentum' |
---|
81 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5' |
---|
82 | |
---|
83 | if which_var == 2: # Depth |
---|
84 | outname = name + which_area + '_depth' |
---|
85 | quantityname = 'stage-elevation' |
---|
86 | |
---|
87 | if which_var == 3: # Speed |
---|
88 | outname = name + which_area + '_speed' |
---|
89 | #quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6/(stage-elevation))' #Speed |
---|
90 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)' #Speed |
---|
91 | |
---|
92 | if which_var == 4: # Elevation |
---|
93 | outname = name + which_area + '_elevation' |
---|
94 | quantityname = 'elevation' #Elevation |
---|
95 | |
---|
96 | else: |
---|
97 | print 'start sww2dem',area |
---|
98 | sww2dem(name, basename_out = outname, |
---|
99 | quantity = quantityname, |
---|
100 | #timestep = timestep, |
---|
101 | cellsize = cellsize, |
---|
102 | reduction = max, |
---|
103 | verbose = True, |
---|
104 | format = 'asc') |
---|
105 | ## |
---|
106 | ## else: |
---|
107 | ## print 'start sww2dem',which_area, easting_min |
---|
108 | ## sww2dem(name, basename_out = outname, |
---|
109 | ## quantity = quantityname, |
---|
110 | ## #timestep = timestep, |
---|
111 | ## cellsize = cellsize, |
---|
112 | ## easting_min = easting_min, |
---|
113 | ## easting_max = easting_max, |
---|
114 | ## northing_min = northing_min, |
---|
115 | ## northing_max = northing_max, |
---|
116 | ## reduction = max, |
---|
117 | ## verbose = True, |
---|
118 | ## format = 'asc') |
---|
119 | ## |
---|