Example #1
0
File: model.py Project: lliss/tr-55
def simulate_cell_year(cell, cell_count):
    """
    Simulate a cell-type for an entire year using sample precipitation and
    evapotranspiration data.

    The `cell` parameter is a string with the soil type and land use
    separated by a colon.

    The `cell_count` parameter is the number of cells of this type.

    If the `precolumbian` parameter is true, then the cell is
    simulated under Pre-Columbian circumstances (anything other than
    water, woody wetland, and herbaceous wetland becomes mixed
    forest).
    """
    split = cell.split(':')
    if (len(split) == 2):
        split.append('')
    land_use = split[1]
    bmp = split[2]

    retval = {}
    for day in range(365):
        (precip, evaptrans) = lookup_pet(day, bmp or land_use)
        result = simulate_cell_day(precip, evaptrans, cell, cell_count)
        retval = dict_plus(retval, result)
    return retval
Example #2
0
def simulate_cell_year(cell, cell_count, precolumbian):
    """
    Simulate a cell-type for an entire year using sample precipitation and
    evapotranspiration data.

    The `cell` parameter is a string with the soil type and land use
    separated by a colon.

    The `cell_count` parameter is the number of cells of this type.

    If the `precolumbian` parameter is true, then the cell is
    simulated under Pre-Columbian circumstances (anything other than
    water, woody wetland, and herbaceous wetland becomes mixed
    forest).
    """
    (soil_type, land_use) = cell.split(':')

    if precolumbian:
        land_use = make_precolumbian(land_use)
        cell = soil_type + ':' + land_use

    retval = {}
    for day in range(365):
        pet = lookup_pet(day, land_use)
        retval = dict_plus(retval, simulate_cell_day(pet, cell, cell_count))
    return retval
Example #3
0
 def test_lookup_pet(self):
     """
     Do some spot-checks on the SampleYear data.
     """
     self.assertEqual(lookup_pet(0, 'water')[0], 0.0)
     self.assertEqual(lookup_pet(52, 'hi_residential')[1], 0.0)
     self.assertEqual(lookup_pet(104, 'green_roof')[1], 0.0)
     self.assertEqual(lookup_pet(156, 'cluster_housing')[0], 0.23)
     self.assertEqual(lookup_pet(208, 'grassland')[0], 0.2)
     self.assertEqual(lookup_pet(260, 'woody_wetland')[1], 0.207)
     self.assertEqual(lookup_pet(352, 'hay')[1], 0.207 * 0.6)