def test_dry_spells(self): "Test dry_spells" rainfall = self.rainfall dates = rainfall.dates control_dates_onstart = dates[[4, 6, 13, 22]] control_dates_onend = dates[[4, 9, 20, 22]] spells = [1, 4, 8, 1] # _test = dry_spells(rainfall, threshold=0.254) assert_equal(_test, spells) assert_equal(_test.dates, control_dates_onstart) _test = dry_spells(rainfall, threshold=0.254, start=False) assert_equal(_test, spells) assert_equal(_test.dates, control_dates_onend)
def test_dry_spells_on_list(self): "Test dry spells on list" data = self.data spells = [1, 4, 8, 1] _test = dry_spells(data, threshold=0.254) assert_equal(_test, spells) self.failUnless(getattr(_test, 'dates', None) is None) assert (isinstance(_test, np.ndarray))
def test_wet_and_dry_spells(self): "Test wet and dry spells" data = self.data + [-3] rainfall = hydro.time_series(data, mask=24 * [0] + [1], start_date=hydro.Date("M", "2001-01")) threshold = 0.254 dspells = dry_spells(rainfall, threshold=threshold) wspells = wet_spells(rainfall, threshold=threshold) assert_equal(dspells.sum() + wspells.durations.sum(), rainfall.count())
def test_dry_spells_on_list(self): "Test dry spells on list" data = self.data spells = [1, 4, 8, 1] _test = dry_spells(data, threshold=0.254) assert_equal(_test, spells) self.failUnless(getattr(_test, "dates", None) is None) assert isinstance(_test, np.ndarray)
def test_wet_and_dry_spells(self): "Test wet and dry spells" data = self.data + [-3] rainfall = hydro.time_series(data, mask=24 * [0] + [1], start_date=hydro.Date('M', '2001-01')) threshold = 0.254 dspells = dry_spells(rainfall, threshold=threshold) wspells = wet_spells(rainfall, threshold=threshold) assert_equal(dspells.sum() + wspells.durations.sum(), rainfall.count())