def test_best_method_pot(self):
        catchment = Catchment("Aberdeen", "River Dee")
        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), 2.0, 0.5),
                                             PotRecord(date(1999, 12, 31), 1.0, 0.5)]
        self.assertAlmostEqual(catchment.qmed(), 1.6696)
 def test_pot_2_years(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.pot_dataset = PotDataset(start_date=date(1998, 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(QmedAnalysis(catchment).qmed(method='pot_records'), 1.8789, 4)
 def test_best_method_pot_over_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)]
     catchment.pot_dataset = PotDataset(start_date=date(1998, 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.8789, 4)
 def test_pot_records_by_month(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.pot_dataset = PotDataset(start_date=date(1998, 10, 1), end_date=date(2000, 1, 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, 2, 15), 2.0, 0.5),
                                          PotRecord(date(1999, 12, 31), 1.0, 0.5)]
     analysis = QmedAnalysis(catchment)
     records_by_month = analysis._pot_month_counts(catchment.pot_dataset)
     expected = [2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2]
     result = [len(month) for month in records_by_month]
     self.assertEqual(result, expected)
 def test_pot_complete_years(self):
     catchment = Catchment("Aberdeen", "River Dee")
     catchment.pot_dataset = PotDataset(start_date=date(1998, 10, 1), end_date=date(2000, 1, 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, 2, 15), 2.0, 0.5),
                                          PotRecord(date(1999, 12, 31), 1.0, 0.5)]
     analysis = QmedAnalysis(catchment)
     records, n = analysis._complete_pot_years(catchment.pot_dataset)
     result = [record.date for record in records]
     expected = [date(1999, 2, 1),
                 date(1999, 2, 15),
                 date(1999, 12, 31)]
     self.assertEqual(result, expected)