Example #1
0
def test_continents_not_normalised():
    p = GeoPickler('', 'out_dir')

    data_dict = {}
    data_dict['A_DIV'] = (np.random.randn(9, 18) * 255).astype(np.int8)
    data_dict['A_cont'] = (np.random.randn(9, 18) * 255).astype(np.int8)

    old_max = np.max(data_dict['A_cont'].ravel())
    old_min = np.min(data_dict['A_cont'].ravel())

    p.normalise_continuous_data(data_dict)

    assert (np.max(data_dict['A_cont'].ravel()) == old_max)
    assert (np.min(data_dict['A_cont'].ravel()) == old_min)

    non_zero = np.where(data_dict['A_cont'] > 0)
    zero = np.where(data_dict['A_cont'] <= 0)
    assert (len(zero) > 0)

    p.process_continents(data_dict)

    assert (np.max(data_dict['cont'].ravel()) == 1)
    assert (np.min(data_dict['cont'].ravel()) == 0)

    assert ((data_dict['cont'][non_zero] == 1).all())
    assert ((data_dict['cont'][zero] == 0).all())
Example #2
0
def test_normalises_continuous_data(fake_geo_data):
    dataroot, _, _, _ = fake_geo_data

    p = GeoPickler(dataroot)

    p.collect_all()

    p.group_by_series()

    data_dict = p.get_data_dict(0, 0)

    p.normalise_continuous_data(data_dict)

    assert (np.max(data_dict['A_DIV'].ravel()) == 1.0)
    assert (np.min(data_dict['A_DIV'].ravel()) == -1.0)

    assert (np.max(data_dict['A_Vx'].ravel()) == 1.0)
    assert (np.min(data_dict['A_Vx'].ravel()) == -1.0)

    assert (np.max(data_dict['A_Vy'].ravel()) == 1.0)
    assert (np.min(data_dict['A_Vy'].ravel()) == -1.0)