def test_static_freeze_thaw_cycles(self, tasmax_series, tasmin_series): tasmax, tasmin = self.static_tmax_tmin_setup(tasmax_series, tasmin_series) tasmin -= 15 ft = xci.daily_freezethaw_cycles(tasmax, tasmin, freq="YS") np.testing.assert_array_equal([np.sum(ft)], [4])
def test_uniform_freeze_thaw_cycles(self, tasmax_series, tasmin_series): temp_values = np.zeros(365) tasmax, tasmin = tasmax_series(temp_values + 5 + K2C), tasmin_series(temp_values - 5 + K2C) ft = xci.daily_freezethaw_cycles(tasmax, tasmin, freq="YS") np.testing.assert_array_equal([np.sum(ft)], [365])
def test_simple(self, tasmin_series, tasmax_series): mn = np.zeros(365) mx = np.zeros(365) # 5 days in 1st month mn[10:20] -= 1 mx[10:15] += 1 # 1 day in 2nd month mn[40:44] += [1, 1, -1, -1] mx[40:44] += [1, -1, 1, -1] mn = tasmin_series(mn + K2C) mx = tasmax_series(mx + K2C) out = xci.daily_freezethaw_cycles(mx, mn, freq="M") np.testing.assert_array_equal(out[:2], [5, 1]) np.testing.assert_array_equal(out[2:], 0)