Beispiel #1
0
    def test_simple(self, tas_series, d1, d2, expected):
        # test for different growing length

        # generate a year of data
        tas = tas_series(np.zeros(365), start="2000/1/1")
        warm_period = tas.sel(time=slice(d1, d2))
        tas = tas.where(~tas.time.isin(warm_period.time), 280)
        gsl = xci.growing_season_length(tas)
        np.testing.assert_array_equal(gsl, expected)
Beispiel #2
0
    def test_simple(self, tas_series):
        # test for different growing length

        # generate 5 years of data
        a = np.zeros(366 * 2 + 365 * 3)
        tas = tas_series(a, start="2000/1/1")

        # 2000 : no growing season

        # 2001 : growing season all year
        d1 = "27-12-2000"
        d2 = "31-12-2001"
        buffer = tas.sel(time=slice(d1, d2))
        tas = tas.where(~tas.time.isin(buffer.time), 280)

        # 2002 : growing season in June only
        d1 = "6-1-2002"
        d2 = "6-10-2002"
        buffer = tas.sel(time=slice(d1, d2))
        tas = tas.where(~tas.time.isin(buffer.time), 280)
        #
        # comment:
        # correct answer should be 10 (i.e. there are 10 days
        # with tas > 5 degC) but current definition imposes end
        # of growing season to be equal or later than July 1st.

        # growing season in Aug only
        d1 = "8-1-2003"
        d2 = "8-10-2003"
        buffer = tas.sel(time=slice(d1, d2))
        tas = tas.where(~tas.time.isin(buffer.time), 280)

        # growing season from June to end of July
        d1 = "6-1-2004"
        d2 = "7-31-2004"
        buffer = tas.sel(time=slice(d1, d2))
        tas = tas.where(~tas.time.isin(buffer.time), 280)

        gsl = xci.growing_season_length(tas)
        target = [0, 365, 25, 10, 61]

        np.testing.assert_array_equal(gsl, target)
Beispiel #3
0
 def test_southhemisphere(self, tas_series):
     tas = tas_series(np.zeros(2 * 365), start="2000/1/1")
     warm_period = tas.sel(time=slice("2000-11-01", "2001-03-01"))
     tas = tas.where(~tas.time.isin(warm_period.time), 280)
     gsl = xci.growing_season_length(tas, mid_date="01-01", freq="AS-Jul")
     np.testing.assert_array_equal(gsl.sel(time="2000-07-01"), 121)