Ignore:
Timestamp:
Sep 28, 2007, 5:15:52 PM (17 years ago)
Author:
duncan
Message:

ticket#196

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/damage_modelling/inundation_damage.py

    r4585 r4742  
    99from Numeric import array, ravel, Float, zeros
    1010from random import choice
     11from types import StringType
    1112
    1213try: 
     
    4142CONT_VALUE_LABEL = 'CONT_VALUE'
    4243
    43 def inundation_damage(sww_base_name, exposure_file_in,
    44                       exposure_file_out=None,
     44def inundation_damage(sww_base_name, exposure_files_in,
     45                      exposure_file_out_marker=None,
    4546                      ground_floor_height=0.3,
    4647                      overwrite=False, verbose=True,
     
    5960    These calculations are done over all the sww files with the sww_base_name
    6061    in the specified directory.
    61     """
    62 
    63     csv = Exposure_csv(exposure_file_in,
    64                        title_check_list=[SHORE_DIST_LABEL,WALL_TYPE_LABEL,
    65                                          STR_VALUE_LABEL,CONT_VALUE_LABEL])
    66     geospatial = csv.get_location()
    67     geospatial = ensure_absolute(geospatial)
    68     max_depths, max_momentums = calc_max_depth_and_momentum(sww_base_name,
    69                                     geospatial,
    70                                     ground_floor_height=ground_floor_height,
    71                                     verbose=verbose,
    72                                     use_cache=use_cache)
    73     edm = EventDamageModel(max_depths,
    74                            csv.get_column(SHORE_DIST_LABEL),
    75                            csv.get_column(WALL_TYPE_LABEL),
    76                            csv.get_column(STR_VALUE_LABEL),
    77                            csv.get_column(CONT_VALUE_LABEL)
    78                            )
    79     results_dic = edm.calc_damage_and_costs(verbose_csv=True, verbose=verbose)
    80     for title, value in results_dic.iteritems():
    81         csv.set_column(title, value, overwrite=overwrite)
    82    
    83     # Save info back to csv file
    84     if exposure_file_out == None:
    85         exposure_file_out = exposure_file_in
    86     csv.save(exposure_file_out)
    87     if verbose: print '\n Augmented building file written to %s \n' %exposure_file_out
     62
     63    exposure_files_in - a file or a list of files to input from
     64    exposure_file_out_marker -  this string will be added to the input file
     65                                name to get the output file name
     66    """
     67    if type(exposure_files_in) == StringType:
     68        exposure_files_in = [exposure_files_in]
     69
     70
     71    for exposure_file_in in exposure_files_in:
     72        csv = Exposure_csv(exposure_file_in,
     73                           title_check_list=[SHORE_DIST_LABEL,WALL_TYPE_LABEL,
     74                                             STR_VALUE_LABEL,CONT_VALUE_LABEL])
     75        geospatial = csv.get_location()
     76        geospatial = ensure_absolute(geospatial)
     77        max_depths, max_momentums = calc_max_depth_and_momentum(sww_base_name,
     78                        geospatial,
     79                        ground_floor_height=ground_floor_height,
     80                        verbose=verbose,
     81                        use_cache=use_cache)
     82        edm = EventDamageModel(max_depths,
     83                               csv.get_column(SHORE_DIST_LABEL),
     84                               csv.get_column(WALL_TYPE_LABEL),
     85                               csv.get_column(STR_VALUE_LABEL),
     86                               csv.get_column(CONT_VALUE_LABEL)
     87                               )
     88        results_dic = edm.calc_damage_and_costs(verbose_csv=True,
     89                                                verbose=verbose)
     90        for title, value in results_dic.iteritems():
     91            csv.set_column(title, value, overwrite=overwrite)
     92   
     93        # Save info back to csv file
     94        if exposure_file_out_marker == None:
     95            exposure_file_out = exposure_file_in
     96        else:
     97            name, extension = exposure_file_in.split('.')
     98            exposure_file_out = name + exposure_file_out_marker + \
     99                                '.' + extension
     100        csv.save(exposure_file_out)
     101        if verbose: print '\n Augmented building file written to %s \n' %exposure_file_out
    88102   
    89103def add_depth_and_momentum2csv(sww_base_name, exposure_file_in,
Note: See TracChangeset for help on using the changeset viewer.