Changeset 2634


Ignore:
Timestamp:
Mar 30, 2006, 9:12:24 AM (18 years ago)
Author:
nicholas
Message:

Corrected folder lookups for CCS.py

Location:
development/momentum_sink
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • development/momentum_sink/CCS.py

    r2578 r2634  
    1212import project
    1313import string
    14 import operator
    1514from pyvolution.util import file_function
    1615from create_buildings import WidtH
    17 from pylab import *
    1816from numerical_tools import norm, corr, err 
    1917
     
    2321#-------------------------------------------------------------------------
    2422# Sorting function used to sort files by
    25 B_list_unsorted=os.listdir("buildings_Str_half_Off") # <<<< place folder name here
     23B_list_unsorted=os.listdir(project.building_dir) # <<<< place folder name here
    2624B_strings=[]
    2725B_list=[]
     
    3230    B_current = [A,B,C]; B_strings.append(B_current)
    3331
    34 B_strings.sort(key=operator.itemgetter(1))
     32B_strings.sort(lambda x, y: cmp(x[1],y[1]))
    3533
    3634for B_str in B_strings:
     
    3836    final=string.join(B_str).replace(' ','')
    3937    B_list.append(final)
    40 
     38print B_list
    4139print ">> ",B_list[0],"<< FIRST file"
    4240print ">> ",B_list[-1],"<< LAST file"
    4341# End of sorting file
    4442#-------------------------------------------------------------------------
    45 
    46 fd = open("buildings_Str_Off(hlf)_report.csv", 'w')
    47 fd.write( 'buildings_Str_Off(hlf)_report. Summary.' + '\n' )
     43raw_input('next')
     44fd = open("buildings_Str_half_Off_report.csv", 'w')
     45fd.write( 'buildings_Str_half_Off_report. Summary.' + '\n' )
    4846
    4947best_fric=[]
     
    5250Breadth=[]
    5351prev_index=0
    54 
     52u=1
    5553
    5654#-------------------------------------------------------------------------
    5755# Buildings scenario loops from sorting.
    5856for B_file in B_list:
    59     swwfile_B = project.outputdir + sep + B_file
     57    swwfile_B = project.building_dir + B_file
    6058    bre = float(B_file.split('=')[1].split('_')[0]) # middle part of string
    6159    print bre, "breadth"
     
    9189    #Friction_log = [0.025, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]
    9290    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]
    9392
    9493    if prev_index < 6:
     
    10099   
    101100
    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'
    104104        f_F = file_function(swwfile_F,
    105105                          quantities = quantities,
     
    127127
    128128            #m = sqrt(uh*uh + vh*vh)   #Absolute momentum
    129             velB = sqrt(uhB*uhB + vhB*vhB) / (wB + 1.e-30) #Absolute velocity
    130             velF = sqrt(uhF*uhF + vhF*vhF) / (wF + 1.e-30) #Absolute velocity                   
     129            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                   
    131131            stages_B.append(wB)
    132132            stages_F.append(wF)
     
    139139        norm_F = err(Ar_F, Ar_B, 2, relative = True)  # 2nd norm (rel. RMS) test
    140140        Normal.append(norm_F)
     141        fd.write(str(fric) + ', ' +  str(norm_F) + '\n')
    141142        if norm_F < least_norm:
    142143            least_norm = norm_F
    143144            fric_OK = fric
    144145            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
    151150
    152151    print fric_OK, " <- This Manning's n is best fit from 2nd norm test"
     
    163162len_file=Numeric.arrayrange(0,len(B_list),1)
    164163fd.write('_______________________________________________________' + '\n' )
    165 fd.write( '<<<<< buildings_Str_Off(hlf)_report Summary >>>>>' + '\n' )
     164fd.write( '<<<<< buildings_Str_half_Off_report Summary >>>>>' + '\n' )
    166165fd.write( 'width, footprint ratio, mannings n, 2nd norm ' + '\n')
    167166for i in len_file:
  • development/momentum_sink/PCS.py

    r2578 r2634  
    1616
    1717#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'
     20swwfile_B = project.outputdir + sep  + 'friction_n=0.975_3135.sww'
     21swwfile_F = project.outputdir + sep  + 'friction_n=7_3135.sww'
    2122
    2223# gauge_depth = Numeric.arrayrange(51, 1.5*WidtH, 25) # Random special
     
    4647
    4748
    48 T = Numeric.arrayrange(0,1000,10)
     49T = Numeric.arrayrange(700,1000,10)
    4950#T = [ 20, 50, 100, 150, 200 ]
    5051
  • development/momentum_sink/Sorter.py

    r2578 r2634  
    11
    22
    3 def Sorter(B_list_unsorted)
    4     import os
    5     import string
    6     import operator
     3import os
     4import string
     5import operator
    76
    8     B_list_unsorted=os.listdir("buildings_straight")
    9     B_strings=[]
    10     B_list=[]
    11     for B_L in B_list_unsorted:
    12         A = B_L.split('=')[0] + '=' # first part of string
    13         B = float(B_L.split('=')[1].split('_')[0]) # middle part of string
    14         C = '_' + B_L.split('=')[1].split('_')[1] # last part of string
    15         B_current = [A,B,C]; B_strings.append(B_current)
     7B_list_unsorted=os.listdir("buildings_Str_half_Off")
     8B_strings=[]
     9B_list=[]
     10for 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)
    1615
    17     B_strings.sort(key=operator.itemgetter(1))
     16B_strings.sort(key=operator.itemgetter(1))
     17#B_strings.sort(lambda x, y: cmp(x[1],y[1]))
    1818
    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
     19for stt in B_strings:
     20    stt[1]=str(stt[1])
     21    final=string.join(stt).replace(' ','')
     22    B_list.append(final)
     23print B_list
     24print "you suck222222222"
  • development/momentum_sink/create_buildings.py

    r2578 r2634  
    33import math
    44import random
     5import polygon
     6import array
    57# add inundation dir to your pythonpath
    68from pmesh.mesh import Mesh
     
    5254
    5355    for i,D in enumerate(Depths):
    54         Breadths = Breadths + ((-1)**i)*(0.5*BL/2) #Used to offset buildings
     56        Breadths = Breadths + ((-1)**i)*(BL/2) #Used to offset buildings
    5557        for B in Breadths:
    5658            wh1 = (-whs) * math.cos(Th) + (-lhs) * math.sin(Th)
     
    6264            wh4 = (-whs) * math.cos(Th) + (+lhs) * math.sin(Th)
    6365            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})       
    6671            # Th = Th + (37.3 *(3.14159/180)) # keeps rotating individual buildings.
    6772    #left_polygon = [[0,WidtH],[5*WidtH,WidtH],[5*WidtH,WidtH+BL],[0,WidtH+BL]]
     
    7681    else:
    7782        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) \
    7984                        + mesh_file[-4:]
    8085        m.export_mesh_file(mesh_file)
  • development/momentum_sink/loop_buildings.py

    r2580 r2634  
    2121
    2222
    23 DR = list(Numeric.arange(12.8,23.2,0.2))
     23DR = list(Numeric.arange(3,23.2,0.2))
    2424#[3,5,7,9,11,13,15,17,19,21,23]
    2525for depth in DR:
     
    4444
    4545
    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))
    4747    domain.set_datadir(project.outputdir)
    4848    domain.store = True
  • development/momentum_sink/project.py

    r2298 r2634  
    2323meshdir = home+sep+scenario_dir_name+sep+'meshes'+sep
    2424outputdir = home+sep+scenario_dir_name+sep+'output'+sep
    25 
     25building_dir = home+sep+scenario_dir_name+sep+'output'+sep+'buildings_Str_half_Off'+sep
     26friction_dir = home+sep+scenario_dir_name+sep+'output'+sep+'friction_files'+sep
    2627meshname = meshdir + basename + '.tsh'
    2728outputname = outputdir + basename  + '.sww' #Used by post processing
Note: See TracChangeset for help on using the changeset viewer.