Beispiel #1
0
def test_1d_load(comm):

    # load plaintext format
    with pytest.warns(FutureWarning):
        ds1 = BinnedStatistic.from_plaintext(['k'], os.path.join(data_dir, 'dataset_1d_deprecated.dat'))

        # wrong dimensions
        with pytest.raises(ValueError):
            ds1 = BinnedStatistic.from_plaintext(['k', 'mu'], os.path.join(data_dir, 'dataset_1d_deprecated.dat'))

    # load from JSON
    ds2 = BinnedStatistic.from_json(os.path.join(data_dir, 'dataset_1d.json'))

    # same data?
    for name in ds1:
        testing.assert_almost_equal(ds1[name], ds2[name])
Beispiel #2
0
def _load(kind, box=None):
    """
    Internal function to load the QPM results.
    """
    d = os.environ['THESIS_DIR']
    d = os.path.join(d, 'boss_dr12_mocks', 'Results', 'QPM', 'nbodykit',
                     'redshift', kind)

    # the pattern
    box = "*" if box is None else "%04d" % box
    if kind == 'power':
        files = glob(
            os.path.join(d,
                         f"pkmu_qpm_unscaled_{box}_0.6452_dk005_Nmu100.dat"))
        dims = ['k', 'mu']
        names = ['k', 'mu', 'power', 'modes']
    else:
        files = glob(
            os.path.join(d,
                         f"poles_qpm_unscaled_{box}_0.6452_dk005_Nmu100.dat"))
        dims = ['k']
        names = ['k', 'power_0', 'power_2', 'power_4', 'modes']

    toret = []
    for f in files:
        d = BinnedStatistic.from_plaintext(dims, f)
        if kind == 'poles':
            for i, name in enumerate(names):
                d.rename_variable('col_%d' % i, name)
        toret.append(d)

    return toret
Beispiel #3
0
def test_1d_load(comm):

    # load plaintext format
    with pytest.warns(FutureWarning):
        ds1 = BinnedStatistic.from_plaintext(['k'], os.path.join(data_dir, 'dataset_1d_deprecated.dat'))

        # wrong dimensions
        with pytest.raises(ValueError):
            ds1 = BinnedStatistic.from_plaintext(['k', 'mu'], os.path.join(data_dir, 'dataset_1d_deprecated.dat'))

    # load from JSON
    ds2 = BinnedStatistic.from_json(os.path.join(data_dir, 'dataset_1d.json'))

    # same data?
    for name in ds1:
        testing.assert_almost_equal(ds1[name], ds2[name])
Beispiel #4
0
def _load(box=None, los=None):
    """
    Internal function to load the N-cubic results.
    """
    d = os.environ['THESIS_DIR']
    d = os.path.join(d, 'boss_dr12_mocks', 'Results', 'ChallengeMocks',
                     'nbodykit', 'power')

    if los is not None:
        assert los in "xyz"

    # the pattern
    box = "*" if box is None else "%d" % box
    los = "*" if los is None else los

    files = glob(
        os.path.join(
            d, f"pkmu_challenge_boxN{box}_unscaled_dk005_Nmu100_{los}los.dat"))

    toret = []
    for f in files:
        toret.append(BinnedStatistic.from_plaintext(['k', 'mu'], f))

    return toret