Exemplo n.º 1
0
def test_compute_climatology_multi_drop_time_bound(ds):
    dset = open_dataset(ds, decode_times=False)
    dset_time_bound = dset.time.attrs['bounds']
    dset = dset.drop(dset_time_bound)
    del dset.time.attrs['bounds']

    computed_dset = compute_mon_climatology(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]

    computed_dset = compute_ann_mean(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]

    computed_dset = compute_mon_anomaly(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    assert (dset.time.values == computed_dset.time.values).all()
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]
Exemplo n.º 2
0
def test_compute_climatology_daisy_chain(ds):
    dset = open_dataset(ds, decode_times=False)

    computed_dset = compute_mon_climatology(dset)
    assert isinstance(computed_dset, xr.Dataset)

    computed_dset2 = compute_mon_anomaly(computed_dset)
    assert isinstance(computed_dset2, xr.Dataset)

    computed_dset3 = compute_ann_mean(computed_dset)
    assert isinstance(computed_dset3, xr.Dataset)

    computed_dset3 = compute_ann_mean(computed_dset2)
    assert isinstance(computed_dset3, xr.Dataset)
Exemplo n.º 3
0
def test_compute_climatology_multi(ds):
    dset = open_dataset(ds, decode_times=False)
    print(dset)
    computed_dset = compute_mon_climatology(dset)
    print(computed_dset)
    print()
    assert isinstance(computed_dset, xr.Dataset)
    computed_dset = compute_ann_mean(dset)
    print(computed_dset)
    print()
    assert isinstance(computed_dset, xr.Dataset)
    computed_dset = compute_mon_anomaly(dset)
    print(computed_dset)
    print()
    assert isinstance(computed_dset, xr.Dataset)
Exemplo n.º 4
0
def test_compute_climatology_multi_decoded(ds):
    dset = open_dataset(ds, decode_times=True)

    computed_dset = compute_mon_climatology(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]

    computed_dset = compute_ann_mean(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]

    computed_dset = compute_mon_anomaly(dset)
    assert isinstance(computed_dset, xr.Dataset)
    assert computed_dset.time.dtype == dset.time.dtype
    assert (dset.time.values == computed_dset.time.values).all()
    for key, value in dset.time.attrs.items():
        assert key in computed_dset.time.attrs
        assert value == computed_dset.time.attrs[key]
Exemplo n.º 5
0
def test_compute_mon_climatology_values(dset):
    computed_dset = compute_mon_climatology(dset)
    np.testing.assert_equal(computed_dset.variable_1.values, 0.5)
    assert computed_dset.time.dtype == dset.time.dtype
Exemplo n.º 6
0
def test_compute_mon_climatology_times_decoded(dset):
    computed_dset = compute_mon_climatology(dset)
    np.testing.assert_equal(computed_dset.variable_1.values, 0.5)