Beispiel #1
0
 def test_bootstrap_no_doy(self, tas_series):
     # no "dayofyear" coords on per
     with pytest.raises(KeyError):
         tg10p(tas_series([42]),
               tas_series([42]),
               freq="MS",
               bootstrap=True)
Beispiel #2
0
 def test_bootstrap_full_overlap(self, tas_series):
     # bootstrap is unnecessary when in base and out of base fully overlap
     # -- GIVEN
     tas = tas_series(self.ar1(alpha=0.8, n=int(4 * 365.25)),
                      start="2000-01-01")
     per = percentile_doy(tas, per=90)
     # -- THEN
     with pytest.raises(KeyError):
         # -- WHEN
         tg10p(tas, per, freq="YS", bootstrap=True)
Beispiel #3
0
 def test_bootstrap_no_overlap(self, tas_series):
     # bootstrap is unnecessary when in base and out of base fully overlap
     # -- GIVEN
     tas = tas_series(self.ar1(alpha=0.8, n=int(4 * 365.25)),
                      start="2000-01-01")
     tas_in_base = tas.sel(time=slice("2000-01-01", "2001-12-31"))
     tas_out_base = tas.sel(time=slice("2002-01-01", "2001-12-31"))
     per = percentile_doy(tas_in_base, per=90)
     # -- THEN
     with pytest.raises(KeyError):
         # -- WHEN
         tg10p(tas_out_base, per, freq="MS", bootstrap=True)
Beispiel #4
0
    def test_tg10p_simple(self, tas_series):
        i = 366
        tas = np.array(range(i))
        tas = tas_series(tas, start="1/1/2000")
        t10 = percentile_doy(tas, per=0.1)

        # create cold spell in june
        tas[175:180] = 1

        out = xci.tg10p(tas, t10, freq="MS")
        assert out[0] == 1
        assert out[5] == 5

        with pytest.raises(AttributeError):
            out = xci.tg10p(tas, tas, freq="MS")
Beispiel #5
0
 def test_bootstrap_tg10p(self, tas_series, use_dask):
     self.bootstrap_testor(
         tas_series,
         2,
         lambda x, y, z: tg10p(x, y, freq="MS", bootstrap=z),
         use_dask=use_dask,
     )
Beispiel #6
0
    def test_tg10p_simple(self, tas_series):
        i = 366
        tas = np.array(range(i))
        tas = tas_series(tas, start='1/1/2000')
        t10 = percentile_doy(tas, per=.1)

        # create cold spell in june
        tas[175:180] = 1

        out = xci.tg10p(tas, t10, freq='MS')
        assert out[0] == 1
        assert out[5] == 5