Changeset 5919
- Timestamp:
- Nov 6, 2008, 5:22:13 PM (16 years ago)
- Location:
- anuga_core/source_numpy_conversion/anuga/damage_modelling
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source_numpy_conversion/anuga/damage_modelling/inundation_damage.py
r4951 r5919 7 7 from math import sqrt 8 8 from Scientific.Functions.Interpolation import InterpolatingFunction 9 from Numeric import array, ravel, Float, zeros 9 import numpy 10 10 from random import choice 11 11 from types import StringType … … 203 203 STRUCT_COLLAPSED_TITLE = "collapsed structure if 1" 204 204 STRUCT_INUNDATED_TITLE = "inundated structure if 1" 205 double_brick_damage_array = array([[-kinds.default_float_kind.MAX, 0.0],205 double_brick_damage_array = numpy.array([[-kinds.default_float_kind.MAX, 0.0], 206 206 [0.0-depth_epsilon, 0.0], 207 207 [0.0,0.016], … … 215 215 [kinds.default_float_kind.MAX,64.7]]) 216 216 double_brick_damage_curve = InterpolatingFunction( \ 217 ( ravel(double_brick_damage_array[:,0:1]),),218 ravel(double_brick_damage_array[:,1:]))219 220 brick_veeer_damage_array = array([[-kinds.default_float_kind.MAX, 0.0],217 (numpy.ravel(double_brick_damage_array[:,0:1]),), 218 numpy.ravel(double_brick_damage_array[:,1:])) 219 220 brick_veeer_damage_array = numpy.array([[-kinds.default_float_kind.MAX, 0.0], 221 221 [0.0-depth_epsilon, 0.0], 222 222 [0.0,0.016], … … 230 230 [kinds.default_float_kind.MAX,69.4]]) 231 231 brick_veeer_damage_curve = InterpolatingFunction( \ 232 ( ravel(brick_veeer_damage_array[:,0:1]),),233 ravel(brick_veeer_damage_array[:,1:]))232 (numpy.ravel(brick_veeer_damage_array[:,0:1]),), 233 numpy.ravel(brick_veeer_damage_array[:,1:])) 234 234 struct_damage_curve = {'Double Brick':double_brick_damage_curve, 235 235 'Brick Veneer':brick_veeer_damage_curve} 236 236 default_struct_damage_curve = brick_veeer_damage_curve 237 237 238 contents_damage_array = array([[-kinds.default_float_kind.MAX, 0.0],238 contents_damage_array = numpy.array([[-kinds.default_float_kind.MAX, 0.0], 239 239 [0.0-depth_epsilon, 0.0], 240 240 [0.0,0.013], … … 247 247 [kinds.default_float_kind.MAX,98.6]]) 248 248 contents_damage_curve = InterpolatingFunction( \ 249 ( ravel(contents_damage_array[:,0:1]),),250 ravel(contents_damage_array[:,1:]))249 (numpy.ravel(contents_damage_array[:,0:1]),), 250 numpy.ravel(contents_damage_array[:,1:])) 251 251 252 252 #building collapse probability … … 312 312 313 313 # the data being created 314 struct_damage = zeros(self.structure_count,Float)315 contents_damage = zeros(self.structure_count,Float)314 struct_damage = numpy.zeros(self.structure_count,numpy.float) 315 contents_damage = numpy.zeros(self.structure_count,numpy.float) 316 316 self.struct_inundated = ['']* self.structure_count 317 317 -
anuga_core/source_numpy_conversion/anuga/damage_modelling/test_inundation_damage.py
r5442 r5919 17 17 from anuga.shallow_water.data_manager import get_dataobject 18 18 19 from Numeric import zeros, Float, allclose 19 import numpy 20 20 21 21 … … 83 83 #Initial condition - with jumps 84 84 bed = domain.quantities['elevation'].vertex_values 85 stage = zeros(bed.shape, Float)85 stage = numpy.zeros(bed.shape, numpy.float) 86 86 87 87 h = 0.3 … … 153 153 #Initial condition - with jumps 154 154 bed = domain.quantities['elevation'].vertex_values 155 stage = zeros(bed.shape, Float)155 stage = numpy.zeros(bed.shape, numpy.float) 156 156 157 157 h = 30. … … 308 308 #print "struct_loss",struct_loss 309 309 struct_loss = [float(x) for x in struct_loss] 310 assert allclose(struct_loss,[10,150,16.9,0])310 assert numpy.allclose(struct_loss,[10,150,16.9,0]) 311 311 depth = csv_handle.get_column(EventDamageModel.MAX_DEPTH_TITLE) 312 312 #print "depth",depth 313 313 depth = [float(x) for x in depth] 314 assert allclose(depth,[5.5,4.5,0.1,-0.3])314 assert numpy.allclose(depth,[5.5,4.5,0.1,-0.3]) 315 315 os.remove(sww.filename) 316 316 os.remove(csv_file) … … 395 395 #print "struct_loss",struct_loss 396 396 struct_loss = [float(x) for x in struct_loss] 397 assert allclose(struct_loss,[10,150,16.9,0])397 assert numpy.allclose(struct_loss,[10,150,16.9,0]) 398 398 depth = csv_handle.get_column(EventDamageModel.MAX_DEPTH_TITLE) 399 399 #print "depth",depth 400 400 depth = [float(x) for x in depth] 401 assert allclose(depth,[5.5,4.5,0.1,-0.3])401 assert numpy.allclose(depth,[5.5,4.5,0.1,-0.3]) 402 402 403 403 # Test another file … … 406 406 #print "struct_loss",struct_loss 407 407 struct_loss = [float(x) for x in struct_loss] 408 assert allclose(struct_loss,[10,150,16.9,0])408 assert numpy.allclose(struct_loss,[10,150,16.9,0]) 409 409 depth = csv_handle.get_column(EventDamageModel.MAX_DEPTH_TITLE) 410 410 #print "depth",depth 411 411 depth = [float(x) for x in depth] 412 assert allclose(depth,[5.5,4.5,0.1,-0.3])412 assert numpy.allclose(depth,[5.5,4.5,0.1,-0.3]) 413 413 os.remove(sww.filename) 414 414 os.remove(csv_file) … … 458 458 struct_costs, content_costs) 459 459 edm.calc_damage_percentages() 460 assert allclose(edm.struct_damage,[0.0,0.016,0.572,460 assert numpy.allclose(edm.struct_damage,[0.0,0.016,0.572, 461 461 0.0,0.016,0.618, 462 462 0.0,0.016,0.618]) 463 assert allclose(edm.contents_damage,[0.0,0.013,0.970,463 assert numpy.allclose(edm.contents_damage,[0.0,0.013,0.970, 464 464 0.0,0.013,0.970, 465 465 0.0,0.013,0.970]) 466 466 edm.calc_cost() 467 assert allclose(edm.struct_loss,[0.0,.16,5.72,467 assert numpy.allclose(edm.struct_loss,[0.0,.16,5.72, 468 468 0.0,.16,6.18, 469 469 0.0,0.016,0.618]) 470 assert allclose(edm.contents_loss,[0.0,1.3,97,470 assert numpy.allclose(edm.contents_loss,[0.0,1.3,97, 471 471 0.0,1.3,97, 472 472 0.0,0.13,9.7]) … … 476 476 edm = EventDamageModel([0.0]*17, [0.0]*17, [0.0]*17, 477 477 [0.0]*17, [0.0]*17) 478 edm.struct_damage = zeros(17,Float)479 edm.contents_damage = zeros(17,Float)478 edm.struct_damage = numpy.zeros(17,numpy.float) 479 edm.contents_damage = numpy.zeros(17,numpy.float) 480 480 collapse_probability = {0.4:[0], #0 481 481 0.6:[1], #1 … … 582 582 # Test values based on returned results, so not an excellent test 583 583 584 assert allclose(deps[0],0.113204555211)585 assert allclose(deps[1],11.3215)586 assert allclose(deps[2],0.0) # this value is outside both sww files584 assert numpy.allclose(deps[0],0.113204555211) 585 assert numpy.allclose(deps[1],11.3215) 586 assert numpy.allclose(deps[2],0.0) # this value is outside both sww files 587 587 588 588 #-------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.