Changeset 2634 for development
- Timestamp:
- Mar 30, 2006, 9:12:24 AM (19 years ago)
- Location:
- development/momentum_sink
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
development/momentum_sink/CCS.py
r2578 r2634 12 12 import project 13 13 import string 14 import operator15 14 from pyvolution.util import file_function 16 15 from create_buildings import WidtH 17 from pylab import *18 16 from numerical_tools import norm, corr, err 19 17 … … 23 21 #------------------------------------------------------------------------- 24 22 # Sorting function used to sort files by 25 B_list_unsorted=os.listdir( "buildings_Str_half_Off") # <<<< place folder name here23 B_list_unsorted=os.listdir(project.building_dir) # <<<< place folder name here 26 24 B_strings=[] 27 25 B_list=[] … … 32 30 B_current = [A,B,C]; B_strings.append(B_current) 33 31 34 B_strings.sort( key=operator.itemgetter(1))32 B_strings.sort(lambda x, y: cmp(x[1],y[1])) 35 33 36 34 for B_str in B_strings: … … 38 36 final=string.join(B_str).replace(' ','') 39 37 B_list.append(final) 40 38 print B_list 41 39 print ">> ",B_list[0],"<< FIRST file" 42 40 print ">> ",B_list[-1],"<< LAST file" 43 41 # End of sorting file 44 42 #------------------------------------------------------------------------- 45 46 fd = open("buildings_Str_ Off(hlf)_report.csv", 'w')47 fd.write( 'buildings_Str_ Off(hlf)_report. Summary.' + '\n' )43 raw_input('next') 44 fd = open("buildings_Str_half_Off_report.csv", 'w') 45 fd.write( 'buildings_Str_half_Off_report. Summary.' + '\n' ) 48 46 49 47 best_fric=[] … … 52 50 Breadth=[] 53 51 prev_index=0 54 52 u=1 55 53 56 54 #------------------------------------------------------------------------- 57 55 # Buildings scenario loops from sorting. 58 56 for B_file in B_list: 59 swwfile_B = project. outputdir + sep+ B_file57 swwfile_B = project.building_dir + B_file 60 58 bre = float(B_file.split('=')[1].split('_')[0]) # middle part of string 61 59 print bre, "breadth" … … 91 89 #Friction_log = [0.025, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000] 92 90 Friction.extend(Friction_large) 91 #Friction = [0.8, 0.825, 0.85, 0.875, 0.9, 0.925, 0.95, 0.975, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] 93 92 94 93 if prev_index < 6: … … 100 99 101 100 102 for f_index, fric in enumerate(Friction[pri:]): 103 swwfile_F = project.outputdir + sep + 'friction_n=' + str(fric) + '_3135.sww' 101 for f_index, fric in enumerate(Friction): 102 #for f_index, fric in enumerate(Friction[pri:]): 103 swwfile_F = project.friction_dir + sep + 'friction_n=' + str(fric) + '_3135.sww' 104 104 f_F = file_function(swwfile_F, 105 105 quantities = quantities, … … 127 127 128 128 #m = sqrt(uh*uh + vh*vh) #Absolute momentum 129 velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity130 velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity129 velB = ((uhB*uhB + vhB*vhB)**0.5) / (wB + 1.e-30) #Absolute velocity 130 velF = ((uhF*uhF + vhF*vhF)**0.5) / (wF + 1.e-30) #Absolute velocity 131 131 stages_B.append(wB) 132 132 stages_F.append(wF) … … 139 139 norm_F = err(Ar_F, Ar_B, 2, relative = True) # 2nd norm (rel. RMS) test 140 140 Normal.append(norm_F) 141 fd.write(str(fric) + ', ' + str(norm_F) + '\n') 141 142 if norm_F < least_norm: 142 143 least_norm = norm_F 143 144 fric_OK = fric 144 145 prev_index = Friction.index(fric) 145 fd.write(str(fric) + ', ' + str(norm_F) + '\n') 146 #elif norm_F > least_norm: 147 # print fric, " NOT OK" 148 else: 149 150 break 146 147 else: 148 print "not OK" 149 #break 151 150 152 151 print fric_OK, " <- This Manning's n is best fit from 2nd norm test" … … 163 162 len_file=Numeric.arrayrange(0,len(B_list),1) 164 163 fd.write('_______________________________________________________' + '\n' ) 165 fd.write( '<<<<< buildings_Str_ Off(hlf)_report Summary >>>>>' + '\n' )164 fd.write( '<<<<< buildings_Str_half_Off_report Summary >>>>>' + '\n' ) 166 165 fd.write( 'width, footprint ratio, mannings n, 2nd norm ' + '\n') 167 166 for i in len_file: -
development/momentum_sink/PCS.py
r2578 r2634 16 16 17 17 #swwfile_B = project.outputdir + sep + 'Buildings_3790.sww' 18 swwfile_B = project.outputdir + sep + 'buildings_Str_Off_BR=15_5_2287.sww' 19 #swwfile_B = project.outputdir + sep + 'friction_n=10_3135.sww' 20 swwfile_F = project.outputdir + sep + 'friction_n=Dbl_33_0.sww' 18 #swwfile_B = project.outputdir + sep + 'buildings_Str_Off(hlf)D=7.44_1092.sww' 19 #swwfile_F = project.outputdir + sep + 'buildings_Str_Off(hlf)D=7.45_1099.sww' 20 swwfile_B = project.outputdir + sep + 'friction_n=0.975_3135.sww' 21 swwfile_F = project.outputdir + sep + 'friction_n=7_3135.sww' 21 22 22 23 # gauge_depth = Numeric.arrayrange(51, 1.5*WidtH, 25) # Random special … … 46 47 47 48 48 T = Numeric.arrayrange( 0,1000,10)49 T = Numeric.arrayrange(700,1000,10) 49 50 #T = [ 20, 50, 100, 150, 200 ] 50 51 -
development/momentum_sink/Sorter.py
r2578 r2634 1 1 2 2 3 def Sorter(B_list_unsorted) 4 import os 5 import string 6 import operator 3 import os 4 import string 5 import operator 7 6 8 B_list_unsorted=os.listdir("buildings_straight")9 10 11 12 13 14 15 7 B_list_unsorted=os.listdir("buildings_Str_half_Off") 8 B_strings=[] 9 B_list=[] 10 for B_L in B_list_unsorted: 11 A = B_L.split('=')[0] + '=' # first part of string 12 B = float(B_L.split('=')[1].split('_')[0]) # middle part of string 13 C = '_' + B_L.split('=')[1].split('_')[1] # last part of string 14 B_current = [A,B,C]; B_strings.append(B_current) 16 15 17 B_strings.sort(key=operator.itemgetter(1)) 16 B_strings.sort(key=operator.itemgetter(1)) 17 #B_strings.sort(lambda x, y: cmp(x[1],y[1])) 18 18 19 for stt in B_strings: 20 stt[1]=str(stt[1]) 21 final=string.join(stt).replace(' ','') 22 B_list.append(final) 23 return B_list 19 for stt in B_strings: 20 stt[1]=str(stt[1]) 21 final=string.join(stt).replace(' ','') 22 B_list.append(final) 23 print B_list 24 print "you suck222222222" -
development/momentum_sink/create_buildings.py
r2578 r2634 3 3 import math 4 4 import random 5 import polygon 6 import array 5 7 # add inundation dir to your pythonpath 6 8 from pmesh.mesh import Mesh … … 52 54 53 55 for i,D in enumerate(Depths): 54 Breadths = Breadths + ((-1)**i)*( 0.5*BL/2) #Used to offset buildings56 Breadths = Breadths + ((-1)**i)*(BL/2) #Used to offset buildings 55 57 for B in Breadths: 56 58 wh1 = (-whs) * math.cos(Th) + (-lhs) * math.sin(Th) … … 62 64 wh4 = (-whs) * math.cos(Th) + (+lhs) * math.sin(Th) 63 65 lh4 = (+lhs) * math.cos(Th) - (-whs) * math.sin(Th) 64 polygon = [[D+wh1,B+lh1],[D+wh2,B+lh2],[D+wh3,B+lh3],[D+wh4,B+lh4]] 65 m.add_hole_from_polygon(polygon, tags={'wall':[0,1,2,3]}) 66 house = [[D+wh1,B+lh1],[D+wh2,B+lh2],[D+wh3,B+lh3],[D+wh4,B+lh4]] 67 point_indexes=polygon.inside_polygon(house, outer_polygon) 68 house_cropped=array.tolist(Numeric.take(house,point_indexes)) 69 walls = range(len(house_cropped)) 70 m.add_hole_from_polygon(house_cropped, tags={'wall':walls}) 66 71 # Th = Th + (37.3 *(3.14159/180)) # keeps rotating individual buildings. 67 72 #left_polygon = [[0,WidtH],[5*WidtH,WidtH],[5*WidtH,WidtH+BL],[0,WidtH+BL]] … … 76 81 else: 77 82 if triangles_in_name is True: 78 mesh_file = mesh_file[:-4] + '_Str_Off (hlf)D=' + str(depth) + '_' + str(triangle_count) \83 mesh_file = mesh_file[:-4] + '_Str_Off_D=' + str(depth) + '_' + str(triangle_count) \ 79 84 + mesh_file[-4:] 80 85 m.export_mesh_file(mesh_file) -
development/momentum_sink/loop_buildings.py
r2580 r2634 21 21 22 22 23 DR = list(Numeric.arange( 12.8,23.2,0.2))23 DR = list(Numeric.arange(3,23.2,0.2)) 24 24 #[3,5,7,9,11,13,15,17,19,21,23] 25 25 for depth in DR: … … 44 44 45 45 46 domain.set_name(project.basename + '_Str_Off (hlf)D=%s_%d' %(str(depth), triagle_count))46 domain.set_name(project.basename + '_Str_Off_D=%s_%d' %(str(depth), triagle_count)) 47 47 domain.set_datadir(project.outputdir) 48 48 domain.store = True -
development/momentum_sink/project.py
r2298 r2634 23 23 meshdir = home+sep+scenario_dir_name+sep+'meshes'+sep 24 24 outputdir = home+sep+scenario_dir_name+sep+'output'+sep 25 25 building_dir = home+sep+scenario_dir_name+sep+'output'+sep+'buildings_Str_half_Off'+sep 26 friction_dir = home+sep+scenario_dir_name+sep+'output'+sep+'friction_files'+sep 26 27 meshname = meshdir + basename + '.tsh' 27 28 outputname = outputdir + basename + '.sww' #Used by post processing
Note: See TracChangeset
for help on using the changeset viewer.