Esempio n. 1
0
    def test_simulate_water_quality_precolumbian(self):
        """
        Test the water quality simulation in Pre-Columbian times.
        """
        census1 = {
            "cell_count": 3,
            "distribution": {
                "a:rock": {"cell_count": 1},
                "b:herbaceous_wetland": {"cell_count": 1},
                "a:water": {"cell_count": 1},
            },
        }

        census2 = {
            "cell_count": 3,
            "distribution": {
                "a:mixed_forest": {"cell_count": 1},
                "b:herbaceous_wetland": {"cell_count": 1},
                "a:water": {"cell_count": 1},
            },
        }

        def fn(cell, cell_count):
            return simulate_cell_year(cell, cell_count, True)

        simulate_water_quality(census1, 93, fn)
        simulate_water_quality(census2, 93, fn)
        for key in set(census1.keys()) - set(["distribution"]):
            self.assertEqual(census1[key], census2[key])
Esempio n. 2
0
    def test_simulate_water_quality_2(self):
        """
        Test the water quality simulation in the presence of modifications.
        """
        census = {
            "cell_count": 2,
            "distribution": {"a:rock": {"cell_count": 1}, "a:water": {"cell_count": 1}},
            "modifications": [
                {"reclassification": "d:hi_residential", "cell_count": 1, "distribution": {"a:rock": {"cell_count": 1}}}
            ],
        }

        census1 = create_modified_census(census)
        census2 = {
            "cell_count": 2,
            "distribution": {"d:hi_residential": {"cell_count": 1}, "a:water": {"cell_count": 1}},
        }

        def fn(cell, cell_count):
            return simulate_cell_year(cell, cell_count, False)

        simulate_water_quality(census1, 93, fn)
        simulate_water_quality(census2, 93, fn)
        for key in set(census1.keys()) - set(["distribution"]):
            self.assertEqual(census1[key], census2[key])
Esempio n. 3
0
    def test_simulate_water_quality_1(self):
        """
        Test the water quality simulation.
        """
        census = {"cell_count": 5, "distribution": {"a:rock": {"cell_count": 3}, "a:water": {"cell_count": 2}}}

        def fn(cell, cell_count):
            return simulate_cell_year(cell, cell_count, False)

        simulate_water_quality(census, 93, fn)
        left = census["distribution"]["a:rock"]
        right = census["distribution"]["a:water"]
        for key in set(census.keys()) - set(["distribution"]):
            self.assertEqual(left[key] + right[key], census[key])
Esempio n. 4
0
    def test_simulate_water_quality_2(self):
        """
        Test the water quality simulation in the presence of modifications.
        """
        census = {
            "cell_count":
            3,
            "distribution": {
                "a:barren_land": {
                    "cell_count": 2
                },
                "a:open_water": {
                    "cell_count": 1
                }
            },
            "modifications": [{
                "change": "d:developed_med:",
                "cell_count": 1,
                "distribution": {
                    "a:barren_land": {
                        "cell_count": 1
                    }
                }
            }]
        }

        census1 = create_modified_census(census)
        census2 = {
            "cell_count": 3,
            "distribution": {
                "a:barren_land": {
                    "cell_count": 1
                },
                "d:developed_med": {
                    "cell_count": 1
                },
                "a:open_water": {
                    "cell_count": 1
                }
            }
        }

        def fn(cell, cell_count):
            return simulate_cell_day(5, 0.207, cell, cell_count)

        simulate_water_quality(census1, 93, fn)
        simulate_water_quality(census2, 93, fn)
        for key in set(census1.keys()) - set(['distribution']):
            self.assertEqual(census1[key], census2[key])
Esempio n. 5
0
    def test_simulate_water_quality_1(self):
        """
        Test the water quality simulation with unmodified census.
        """
        census = {
            "cell_count": 5,
            "distribution": {
                "a:barren_land": {"cell_count": 3},
                "a:open_water": {"cell_count": 2}
            }
        }

        def fn(cell, cell_count):
            return simulate_cell_day(5, 0.207, cell, cell_count)

        simulate_water_quality(census, 93, fn)
        left = census['distribution']['a:barren_land']
        right = census['distribution']['a:open_water']
        for key in set(census.keys()) - set(['distribution']):
            self.assertEqual(left[key] + right[key], census[key])
Esempio n. 6
0
    def test_simulate_water_quality_2(self):
        """
        Test the water quality simulation in the presence of modifications.
        """
        census = {
            "cell_count": 3,
            "distribution": {
                "a:barren_land": {"cell_count": 2},
                "a:open_water": {"cell_count": 1}
            },
            "modifications": [
                {
                    "change": "d:developed_med:",
                    "cell_count": 1,
                    "distribution": {
                        "a:barren_land": {"cell_count": 1}
                    }
                }
            ]
        }

        census1 = create_modified_census(census)
        census2 = {
            "cell_count": 3,
            "distribution": {
                "a:barren_land": {"cell_count": 1},
                "d:developed_med": {"cell_count": 1},
                "a:open_water": {"cell_count": 1}
            }
        }

        def fn(cell, cell_count):
            return simulate_cell_day(5, 0.207, cell, cell_count)

        simulate_water_quality(census1, 93, fn)
        simulate_water_quality(census2, 93, fn)
        for key in set(census1.keys()) - set(['distribution']):
            self.assertEqual(census1[key], census2[key])
Esempio n. 7
0
    def test_simulate_water_quality_1(self):
        """
        Test the water quality simulation.
        """
        census = {
            "cell_count": 5,
            "distribution": {
                "a:barren_land": {
                    "cell_count": 3
                },
                "a:open_water": {
                    "cell_count": 2
                }
            }
        }

        def fn(cell, cell_count):
            return simulate_cell_day(5, 0.207, cell, cell_count)

        simulate_water_quality(census, 93, fn)
        left = census['distribution']['a:barren_land']
        right = census['distribution']['a:open_water']
        for key in set(census.keys()) - set(['distribution']):
            self.assertEqual(left[key] + right[key], census[key])
Esempio n. 8
0
    def test_simulate_water_quality_precolumbian(self):
        """
        Test the water quality simulation in Pre-Columbian times.
        """
        census1 = {
            "cell_count": 8,
            "distribution": {
                "a:developed_med": {"cell_count": 1},
                "b:no_till": {"cell_count": 1},
                "c:pasture": {"cell_count": 1},
                "d:cultivated_crops": {"cell_count": 1},
                "a:open_water": {"cell_count": 1},
                "b:shrub": {"cell_count": 1},
                "c:barren_land": {"cell_count": 1},
                "d:developed_open": {"cell_count": 1}
            }
        }

        census2 = {
            "cell_count": 8,
            "distribution": {
                "a:mixed_forest": {"cell_count": 1},
                "b:mixed_forest": {"cell_count": 1},
                "c:mixed_forest": {"cell_count": 1},
                "d:mixed_forest": {"cell_count": 2},
                "a:open_water": {"cell_count": 1},
                "b:shrub": {"cell_count": 1},
                "c:barren_land": {"cell_count": 1}
            }
        }

        census3 = census2.copy()

        def fn(cell, cell_count):
            return simulate_cell_day(7, 0.107, cell, cell_count)

        simulate_water_quality(census1, 93, fn, precolumbian=True)
        simulate_water_quality(census2, 93, fn, precolumbian=True)
        simulate_water_quality(census3, 93, fn, precolumbian=False)

        for key in set(census1.keys()) - set(['distribution']):
            self.assertAlmostEqual(census1[key], census2[key])

        for key in set(census1.keys()) - set(['distribution']):
            self.assertAlmostEqual(census2[key], census3[key])
Esempio n. 9
0
    def test_simulate_water_quality_precolumbian(self):
        """
        Test the water quality simulation in Pre-Columbian times.
        """
        census1 = {
            "cell_count": 8,
            "distribution": {
                "a:developed_med": {
                    "cell_count": 1
                },
                "b:no_till": {
                    "cell_count": 1
                },
                "c:pasture": {
                    "cell_count": 1
                },
                "d:cultivated_crops": {
                    "cell_count": 1
                },
                "a:open_water": {
                    "cell_count": 1
                },
                "b:shrub": {
                    "cell_count": 1
                },
                "c:barren_land": {
                    "cell_count": 1
                },
                "d:developed_open": {
                    "cell_count": 1
                }
            }
        }

        census2 = {
            "cell_count": 8,
            "distribution": {
                "a:mixed_forest": {
                    "cell_count": 1
                },
                "b:mixed_forest": {
                    "cell_count": 1
                },
                "c:mixed_forest": {
                    "cell_count": 1
                },
                "d:mixed_forest": {
                    "cell_count": 2
                },
                "a:open_water": {
                    "cell_count": 1
                },
                "b:shrub": {
                    "cell_count": 1
                },
                "c:barren_land": {
                    "cell_count": 1
                }
            }
        }

        census3 = census2.copy()

        def fn(cell, cell_count):
            return simulate_cell_day(7, 0.107, cell, cell_count)

        simulate_water_quality(census1, 93, fn, precolumbian=True)
        simulate_water_quality(census2, 93, fn, precolumbian=True)
        simulate_water_quality(census3, 93, fn, precolumbian=False)

        for key in set(census1.keys()) - set(['distribution']):
            self.assertAlmostEqual(census1[key], census2[key])

        for key in set(census1.keys()) - set(['distribution']):
            self.assertAlmostEqual(census2[key], census3[key])