def test_single_year(self, tas_series): a = np.zeros(366) + K2C ts = tas_series(a, start="1/1/2000") tt = (ts.time.dt.month >= 5) & (ts.time.dt.month <= 8) offset = np.random.uniform(low=5.5, high=23, size=(tt.sum().values, )) ts[tt] = ts[tt] + offset out = atmos.growing_season_length(ts) np.testing.assert_array_equal(out, tt.sum())
def test_convert_units(self, tas_series): a = np.zeros(366) ts = tas_series(a, start='1/1/2000') ts.attrs['units'] = 'C' tt = (ts.time.dt.month >= 5) & (ts.time.dt.month <= 8) offset = np.random.uniform(low=5.5, high=23, size=(tt.sum().values, )) ts[tt] = ts[tt] + offset out = atmos.growing_season_length(ts) np.testing.assert_array_equal(out, tt.sum())
def test_multiyear(self, tas_series): a = np.zeros(366 * 10) ts = tas_series(a, start="1/1/2000") ts.attrs["units"] = "C" tt = (ts.time.dt.month >= 5) & (ts.time.dt.month <= 8) offset = np.random.uniform(low=5.5, high=23, size=(tt.sum().values,)) ts[tt] = ts[tt] + offset out = atmos.growing_season_length(ts) np.testing.assert_array_equal(out[3], tt[0:366].sum().values)
def test_nan_presence(self, tas_series): a = np.zeros(366) a[50] = np.nan ts = tas_series(a, start="1/1/2000") ts.attrs["units"] = "C" tt = (ts.time.dt.month >= 5) & (ts.time.dt.month <= 8) offset = np.random.uniform(low=5.5, high=23, size=(tt.sum().values,)) ts[tt] = ts[tt] + offset out = atmos.growing_season_length(ts) np.testing.assert_array_equal(out, [np.nan])