Changeset 7158


Ignore:
Timestamp:
Jun 9, 2009, 11:19:13 AM (16 years ago)
Author:
kristy
Message:

adding initial conditions read csv2polygon or list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/hobart_2009/setup_model.py

    r7082 r7158  
    147147# Create list of land polygons with initial conditions
    148148project.land_initial_conditions = []
    149 for filename, MSL in project.land_initial_conditions_filename:
    150     polygon = read_polygon(join(project.polygons_folder, filename))
    151     project.land_initial_conditions.append([polygon, MSL])
    152 
     149# if it's a list, then it's a list of land condition filenames
     150# else it's a string - a single file, multiple land conditions
     151if isinstance(project.land_initial_conditions_filename, list):
     152    for filename, MSL in project.land_initial_conditions_filename:
     153        polygon = read_polygon(join(project.polygons_folder, filename))
     154        project.land_initial_conditions.append([polygon, MSL])
     155elif isinstance(project.land_initial_conditions_filename, basestring):
     156    polygons, MSL = csv2polygons(join(project.polygons_folder,
     157                                      project.land_initial_conditions_filename))
     158    for i, key in enumerate(polygons):
     159        if i%100==0: print i
     160        poly = polygons[key]
     161        land = float(MSL[key])
     162        project.land_initial_conditions.append([poly, land])
     163else:
     164    msg = ('project.land_initial_conditions_filename must be a list or '
     165           'string, got %s'
     166           % type(project.land_initial_conditions_filename))
     167    raise Exception, msg
    153168# Create list of interior polygons with scaling factor
    154169project.interior_regions = []
Note: See TracChangeset for help on using the changeset viewer.