Changeset 3350
- Timestamp:
- Jul 18, 2006, 1:10:06 PM (18 years ago)
- Location:
- inundation/damage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/damage/inundation_damage.py
r3346 r3350 37 37 def inundation_damage(sww_file, exposure_file_in, 38 38 exposure_file_out=None, 39 ground_floor_height=0.3, 39 40 overwrite=False, verbose=True, 40 41 use_cache = True): … … 51 52 geospatial = csv.get_location() 52 53 max_depths, max_momentums = calc_max_depth_and_momentum(sww_file, 53 geospatial, 54 verbose=verbose, 55 use_cache=use_cache) 54 geospatial, 55 ground_floor_height=ground_floor_height, 56 verbose=verbose, 57 use_cache=use_cache) 56 58 edm = EventDamageModel(max_depths, 57 59 csv.get_column('SHORE_DIST'), … … 62 64 results_dic = edm.calc_damage_and_costs(verbose_csv=True) 63 65 for title, value in results_dic.iteritems(): 64 csv.set_column(title, value )66 csv.set_column(title, value, overwrite=overwrite) 65 67 66 68 # Save info back to csv file … … 139 141 STRUCT_DAMAGE_TITLE = "Structure damaged (fraction)" 140 142 COLLAPSE_CSV_INFO_TITLE = "Calculation notes" 143 MAX_DEPTH_TITLE = "Inundation height above ground floor (m)" 141 144 double_brick_damage_array = array([[-kinds.default_float_kind.MAX, 0.0], 142 145 [0.0-depth_epsilon, 0.0], … … 201 204 def __init__(self,max_depths, shore_distances, walls, 202 205 struct_costs, content_costs): 206 """ 207 max depth is Inundation height above ground floor (m), so 208 the ground floor has been taken into account. 209 """ 203 210 self.max_depths = [float(x) for x in max_depths] 204 211 self.shore_distances = [float(x) for x in shore_distances] … … 225 232 ,self.CONTENTS_LOSS_TITLE:self.contents_loss 226 233 ,self.CONTENTS_DAMAGE_TITLE:self.contents_damage 227 #,self.:self.234 ,self.MAX_DEPTH_TITLE:self.max_depths 228 235 #,self.:self. 229 236 #,self.:self. -
inundation/damage/test_inundation_damage.py
r3346 r3350 18 18 19 19 from Numeric import zeros, Float, allclose 20 20 21 22 def elevation_function(x, y): 23 return -x 24 21 25 class Test_inundation_damage(unittest.TestCase): 22 26 def setUp(self): … … 49 53 points_ab = spat.get_data_points( absolute = True) 50 54 51 #FIXME - put this back when it is working52 #geo = Geo_reference(56,400000,6000000)53 #spat.set_geo_reference(geo)55 56 geo = Geo_reference(56,400000,6000000) 57 spat.set_geo_reference(geo) 54 58 55 59 m = Mesh() … … 148 152 #print "sww_file",sww_file 149 153 inundation_damage(sww_file, self.csv_file, verbose=False) 150 154 155 156 def ztest_inundation_damage2(self): 157 158 # create mesh 159 mesh_file = tempfile.mktemp(".tsh") 160 points = [[0.0,0.0],[6.0,0.0],[6.0,6.0],[0.0,6.0]] 161 m = Mesh() 162 m.add_vertices(points) 163 m.autoSegment() 164 m.generate_mesh(verbose=True) #False) 165 m.export_mesh_file(mesh_file) 166 167 #Create shallow water domain 168 domain = Domain(mesh_file) 169 os.remove(mesh_file) 170 171 domain.default_order=2 172 domain.beta_h = 0 173 174 #Set some field values 175 domain.set_quantity('stage', 0.3) 176 domain.set_quantity('elevation', elevation_function) 177 domain.set_quantity('friction', 0.03) 178 domain.set_quantity('xmomentum', 22.0) 179 domain.set_quantity('ymomentum', 55.0) 180 181 ###################### 182 # Boundary conditions 183 B = Transmissive_boundary(domain) 184 domain.set_boundary( {'exterior': B}) 185 domain.distribute_to_vertices_and_edges() 186 187 #sww_file = tempfile.mktemp("") 188 domain.filename = 'datatest' + str(time.time()) 189 #domain.filename = sww_file 190 #print "domain.filename",domain.filename 191 domain.format = 'sww' 192 domain.smooth = True 193 domain.reduction = mean 194 195 sww = get_dataobject(domain) 196 sww.store_connectivity() 197 sww.store_timestep(['stage', 'xmomentum', 'ymomentum']) 198 domain.time = 2. 199 sww.store_timestep(['stage', 'xmomentum', 'ymomentum']) 200 sww = sww # so it can be deleted 201 202 #Create a csv file 203 csv_file = tempfile.mktemp(".csv") 204 fd = open(csv_file,'wb') 205 writer = csv.writer(fd) 206 writer.writerow(['LONGITUDE','LATITUDE','STR_VALUE','C_VALUE','ROOF_TYPE','WALLS', 'SHORE_DIST']) 207 writer.writerow(['151.5','-34','199770','130000','Metal','Timber',20]) 208 writer.writerow(['151','-34.5','150000','76000','Metal','Double Brick',200]) 209 writer.writerow(['151','-34.25','150000','76000','Metal','Brick Veneer',200]) 210 151 211 def ztest_add_depth_and_momentum2csv(self): 152 212 sww_file = self.domain.filename + "." + self.domain.format
Note: See TracChangeset
for help on using the changeset viewer.