def test_record_start_end(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 3.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 2.0, 0.5),
                               AmaxRecord(date(2001, 12, 31), 1.0, 0.5)]
     self.assertEqual(catchment.amax_records_start(), 1999)
     self.assertEqual(catchment.amax_records_end(), 2001)
 def test_amax_long_records(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 5.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 1.0, 0.5),
                               AmaxRecord(date(2001, 12, 31), 4.0, 0.5),
                               AmaxRecord(date(2002, 12, 31), 2.0, 0.5),
                               AmaxRecord(date(2003, 12, 31), 3.0, 0.5)]
     self.assertEqual(QmedAnalysis(catchment).qmed(method='amax_records'), 3)
 def test_add_catchment_with_amax(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 3.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 2.0, 0.5),
                               AmaxRecord(date(2001, 12, 31), 1.0, 0.5)]
     self.db_session.add(catchment)
     result = self.db_session.query(Catchment).filter_by(location="Aberdeen", watercourse="River Dee").one()
     self.assertEqual(catchment, result)
     self.assertEqual(catchment.amax_records, result.amax_records)
 def test_best_method_amax_over_pot(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 2.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 1.0, 0.5)]
     catchment.pot_dataset = PotDataset(start_date=date(1999, 1, 1), end_date=date(1999, 12, 31))
     catchment.pot_dataset.pot_records = [PotRecord(date(1999, 1, 1), 3.0, 0.5),
                                          PotRecord(date(1999, 2, 1), 2.0, 0.5),
                                          PotRecord(date(1999, 12, 31), 1.0, 0.5)]
     self.assertAlmostEqual(catchment.qmed(), 1.5)
 def test_record_start_end(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [
         AmaxRecord(date(1999, 12, 31), 3.0, 0.5),
         AmaxRecord(date(2000, 12, 31), 2.0, 0.5),
         AmaxRecord(date(2001, 12, 31), 1.0, 0.5)
     ]
     self.assertEqual(catchment.amax_records_start(), 1999)
     self.assertEqual(catchment.amax_records_end(), 2001)
 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_add_catchment_with_amax(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [
         AmaxRecord(date(1999, 12, 31), 3.0, 0.5),
         AmaxRecord(date(2000, 12, 31), 2.0, 0.5),
         AmaxRecord(date(2001, 12, 31), 1.0, 0.5)
     ]
     self.db_session.add(catchment)
     result = self.db_session.query(Catchment).filter_by(
         location="Aberdeen", watercourse="River Dee").one()
     self.assertEqual(catchment, result)
     self.assertEqual(catchment.amax_records, result.amax_records)
 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_amax(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 1.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 1.0, 0.5)]
     self.assertEqual(catchment.qmed(), 1.0)
 def test_amax_rejected_record(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.amax_records = [AmaxRecord(date(1999, 12, 31), 2.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 1.0, 0.5),
                               AmaxRecord(date(2000, 12, 31), 99.0, 0.5, flag=2)]
     self.assertEqual(QmedAnalysis(catchment).qmed(method='amax_records'), 1.5)