Changeset 6019


Ignore:
Timestamp:
Nov 28, 2008, 11:35:01 AM (15 years ago)
Author:
kristy
Message:

restructured and added more function to the script, now saving a new file into the time_dir folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/busselton/run_building_inundation.py

    r4314 r6019  
    2121from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage
    2222import project
     23import csv
    2324
    24 # Inputs
    25 #timestampdir = '20060704_063005' # HAT
    26 #timestampdir = '20060704_063112' # LAT
    27 #timestampdir = '20060704_063234' # MSL
    28 timestampdir = '20060515_001733' # DTED MSL
    29 file_loc = project.outputdir + timestampdir + sep
    30 swwfile = file_loc + project.basename + '.sww'
    31 buildings_filename = project.buildings_filename
    32 buildings_filename_out = file_loc + project.buildings_filename_out
     25directory = project.output_dir
    3326
    34 #add_depth_and_momentum2csv(swwfile, buildings_filename, buildings_filename_out)
    35 inundation_damage(swwfile, buildings_filename, buildings_filename_out)
     27time_dir1 = '20081009_184721_run_final_0.6_68693_alpha0.1_kvanputt'
     28time_dir2 = '20081031_120515_run_final_0_27255_alpha0.1_kvanputt'
     29time_dir3 = '20081031_120753_run_final_0.6_27283_alpha0.1_kvanputt'
     30time_dir4 = '20081031_120642_run_final_0_27283_alpha0.1_kvanputt'
     31time_dir5 = '20081031_120316_run_final_0_68693_alpha0.1_kvanputt'
     32time_dir6 = '20081111_113832_run_final_0.6_27255_alpha0.1_kvanputt'
    3633
    37 print '\n Augmented building file written to %s \n' \
    38       %buildings_filename_out
     34time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]
     35
     36buildings = project.building_in_dir_name
     37
     38for time_dir in time_dirs:
     39    building_marker = '_modified'
     40    name = directory+time_dir+sep+project.scenario_name #basename for the sww files
     41   
     42    inundation_damage(name, buildings, building_marker)
     43    #add_depth_and_momentum2csv(name, buildings, building_marker)
     44   
     45    building_marker_dir_name = project.gauges_dir + project.building + building_marker + '.csv'
     46    out_file = directory+time_dir+ sep+project.scenario_name+'_res.csv'
     47    print 'out file %s' %out_file
     48    print 'building_marker_dir_name %s' %building_marker_dir_name
     49    csv_fd = open(building_marker_dir_name, 'r')
     50    output_file = open(out_file, 'w')
     51
     52    reader = csv.reader(csv_fd)
     53    writer = csv.writer(output_file, lineterminator='\n')
     54
     55    for record in reader:
     56       newline = record[-8:]
     57       newline.insert(0,record[0])
     58       writer.writerow(newline)
     59       
     60    print 'output file printed to: %s' %out_file
     61    csv_fd.close()
     62    output_file.close()
     63     
     64
     65   
Note: See TracChangeset for help on using the changeset viewer.