def test_doctest_ndims(self):
     """Replicates doctest to facilitate debugging."""
     tas = open_dataset("ERA5/daily_surface_cancities_1990-1993.nc").tas
     t90 = percentile_doy(tas.sel(time=slice("1990-01-01", "1991-12-31")),
                          window=5,
                          per=90)
     tg90p(tas=tas, t90=t90.isel(percentiles=0), freq="YS", bootstrap=True)
     tg90p(tas=tas, t90=t90, freq="YS", bootstrap=True)
 def test_bootstrap_tg90p(self, tas_series, use_dask):
     self.bootstrap_testor(
         tas_series,
         98,
         lambda x, y, z: tg90p(x, y, freq="MS", bootstrap=z),
         use_dask=use_dask,
     )
 def test_multi_per(self):
     tas = open_dataset("ERA5/daily_surface_cancities_1990-1993.nc").tas
     t90 = percentile_doy(tas.sel(time=slice("1990-01-01", "1991-12-31")),
                          window=5,
                          per=[90, 91])
     res = tg90p(tas=tas, t90=t90, freq="YS", bootstrap=True)
     np.testing.assert_array_equal([90, 91], res.percentiles)
Exemple #4
0
    def test_tg90p_simple(self, tas_series):
        i = 366
        tas = np.array(range(i))
        tas = tas_series(tas, start="1/1/2000")
        t90 = percentile_doy(tas, per=0.1)

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

        out = xci.tg90p(tas, t90, freq="MS")
        assert out[0] == 30
        assert out[1] == 29
        assert out[5] == 25