def test_descriptors_1999_2(self): catchment = Catchment("Aberdeen", "River Dee") catchment.descriptors = Descriptors(dtm_area=2.345, bfihost=0, sprhost=100, saar=2000, farl=0.5, urbext2000=0) self.assertAlmostEqual(QmedAnalysis(catchment).qmed(method='descriptors_1999'), 0.3729, 4)
def test_descriptors_2008_1(self): catchment = Catchment("Aberdeen", "River Dee") catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext2000=0) self.assertAlmostEqual(QmedAnalysis(catchment).qmed(method='descriptors_2008'), 0.5907, 4)
def test_descriptors_2008_urban_adjustment(self): catchment = Catchment("Aberdeen", "River Dee") catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext2000=1) self.assertAlmostEqual(QmedAnalysis(catchment, year=2000).urban_adj_factor(), 2.970205798, 4)
def test_best_method_descriptors(self): catchment = Catchment("Aberdeen", "River Dee") catchment.channel_width = 1 catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext2000=0) self.assertAlmostEqual(catchment.qmed(), 0.5907, 4)
def test_descriptors_2008_urban(self): catchment = Catchment("Aberdeen", "River Dee") catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext2000=1) self.assertAlmostEqual(QmedAnalysis(catchment, year=2000).qmed(method='descriptors_2008', as_rural=False), 1.7546, 4)
def test_best_method_order(self): catchment = Catchment("Aberdeen", "River Dee") catchment.channel_width = 1 catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 1.0, 0.5), AmaxRecord(date(2000, 12, 31), 1.0, 0.5)] catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1) self.assertEqual(catchment.qmed(), 1.0)
def test_find_donors_exclude_urban(self): other_catchment = Catchment(location="Burn A", watercourse="Village B") other_catchment.id = 999 other_catchment.is_suitable_for_pooling = True other_catchment.descriptors = Descriptors(urbext2000=0.031) self.db_session.add(other_catchment) gauged_catchments = CatchmentCollections(self.db_session) analysis = GrowthCurveAnalysis(self.catchment, gauged_catchments) analysis.find_donor_catchments() donor_ids = [d.id for d in analysis.donor_catchments] self.assertEqual([10002, 10001], donor_ids)
def test_all(self): catchment = Catchment("Aberdeen", "River Dee") catchment.channel_width = 1 catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 1.0, 0.5), AmaxRecord(date(2000, 12, 31), 1.0, 0.5)] catchment.descriptors = Descriptors(dtm_area=1, bfihost=0.50, sprhost=50, saar=1000, farl=1, urbext2000=0) qmeds = QmedAnalysis(catchment).qmed_all_methods() self.assertEqual(qmeds['amax_records'], 1) self.assertEqual(qmeds['channel_width'], 0.182) self.assertEqual(qmeds['area'], 1.172) self.assertAlmostEqual(qmeds['descriptors_1999'], 0.2671, 4)
def test_best_method_area(self): catchment = Catchment("Aberdeen", "River Dee") catchment.descriptors = Descriptors(dtm_area=1) self.assertEqual(catchment.qmed(), 1.172)