def test_pot_dataset_record_length_with_gap(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) pot_data_gap = PotDataGap(start_date=date(2001, 1, 1), end_date=date(2001, 1, 31)) pot_dataset.pot_data_gaps.append(pot_data_gap) self.assertAlmostEqual(pot_dataset.record_length(), 0.9150685)
def test_pot_periods(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) pot_data_gap = PotDataGap(start_date=date(2001, 1, 1), end_date=date(2001, 1, 31)) pot_dataset.pot_data_gaps.append(pot_data_gap) self.assertEqual(pot_dataset.continuous_periods(), [ PotPeriod(date(2000, 12, 31), date(2000, 12, 31)), PotPeriod(date(2001, 2, 1), date(2001, 12, 30)) ]) self.assertAlmostEqual(sum(period.period_length() for period in pot_dataset.continuous_periods()), 0.9150685)
def test_pot_periods(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) pot_data_gap = PotDataGap(start_date=date(2001, 1, 1), end_date=date(2001, 1, 31)) pot_dataset.pot_data_gaps.append(pot_data_gap) self.assertEqual(pot_dataset.continuous_periods(), [ PotPeriod(date(2000, 12, 31), date(2000, 12, 31)), PotPeriod(date(2001, 2, 1), date(2001, 12, 30)) ]) self.assertAlmostEqual( sum(period.period_length() for period in pot_dataset.continuous_periods()), 0.9150685)
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)
def test_pot_dataset_record_length(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) self.assertAlmostEqual(pot_dataset.record_length(), 1)
def test_pot_periods_no_gaps(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) self.assertEqual(pot_dataset.continuous_periods(), [ PotPeriod(date(2000, 12, 31), date(2001, 12, 30)) ])
def test_pot_dataset_record_length(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) self.assertAlmostEqual(pot_dataset.record_length, 1)
def test_pot_periods_no_gaps(self): pot_dataset = PotDataset(start_date=date(2000, 12, 31), end_date=date(2001, 12, 30)) self.assertEqual(pot_dataset.continuous_periods(), [PotPeriod(date(2000, 12, 31), date(2001, 12, 30))])