コード例 #1
0
ファイル: test_catalogmesh.py プロジェクト: bccp/nbodykit
def test_paint_chunksize(comm):

    source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42, comm=comm)

    # interlacing with TSC
    mesh = source.to_mesh(resampler='tsc', Nmesh=64, interlaced=True, compensated=True)

    with set_options(paint_chunk_size=source.csize // 4):
        r1 = mesh.compute()

    with set_options(paint_chunk_size=source.csize):
        r2 = mesh.compute()

    assert_allclose(r1, r2)
コード例 #2
0
def test_paint_chunksize(comm):

    source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42, comm=comm)

    # interlacing with TSC
    mesh = source.to_mesh(window='tsc',
                          Nmesh=64,
                          interlaced=True,
                          compensated=True)

    with set_options(paint_chunk_size=source.csize // 4):
        r1 = mesh.compute()

    with set_options(paint_chunk_size=source.csize):
        r2 = mesh.compute()

    assert_allclose(r1, r2)
コード例 #3
0
ファイル: test_catalogmesh.py プロジェクト: bccp/nbodykit
def test_shotnoise(comm):

    source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42, comm=comm)
    source['Weight'] = source.rng.uniform()

    # interlacing with TSC
    mesh = source.to_mesh(resampler='tsc', Nmesh=64, interlaced=True, compensated=True, weight='Weight')

    with set_options(paint_chunk_size=source.csize // 4):
        r1 = mesh.compute()

    with set_options(paint_chunk_size=source.csize):
        r2 = mesh.compute()
    assert_allclose(r1, r2)

    # expected shotnoise for uniform weights between 0 and 1
    SN = 4 / 3.0 * 1 / (3e-4)
    assert_allclose(r1.attrs['shotnoise'], SN, rtol=1e-2)
    assert_allclose(r2.attrs['shotnoise'], SN, rtol=1e-2)
コード例 #4
0
ファイル: test_catalogmesh.py プロジェクト: bccp/nbodykit
def test_odd_chunksize(comm):
    # no errors shall occur. This is a regression test.

    source = ArrayCatalog({
        'Position': numpy.ones((2000, 3)),
    }, BoxSize=512., comm=comm)

    # make the mesh
    mesh = source.to_mesh(resampler='cic', Nmesh=64, interlaced=True, compensated=True)
    
    with set_options(paint_chunk_size=1111):
        mesh.compute()
コード例 #5
0
ファイル: test_catalogmesh.py プロジェクト: twobombs/nbodykit
def test_shotnoise(comm):

    source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42, comm=comm)
    source['Weight'] = source.rng.uniform()

    # interlacing with TSC
    mesh = source.to_mesh(resampler='tsc',
                          Nmesh=64,
                          interlaced=True,
                          compensated=True,
                          weight='Weight')

    with set_options(paint_chunk_size=source.csize // 4):
        r1 = mesh.compute()

    with set_options(paint_chunk_size=source.csize):
        r2 = mesh.compute()
    assert_allclose(r1, r2)

    # expected shotnoise for uniform weights between 0 and 1
    SN = 4 / 3.0 * 1 / (3e-4)
    assert_allclose(r1.attrs['shotnoise'], SN, rtol=1e-2)
    assert_allclose(r2.attrs['shotnoise'], SN, rtol=1e-2)
コード例 #6
0
def test_set_options(comm):

    with CurrentMPIComm.enter(comm):
        with set_options(global_cache_size=5e9, dask_chunk_size=75):
            s = UniformCatalog(1000, 1.0)

            # check cache size
            cache = GlobalCache.get()
            assert cache.cache.available_bytes == 5e9

            # check chunk size
            assert s['Position'].chunks[0][0] == 75

        s = UniformCatalog(1000, 1.0)
        assert s['Position'].chunks[0][0] == s.size
コード例 #7
0
ファイル: test_lab.py プロジェクト: bccp/nbodykit
def test_set_options(comm):

    with CurrentMPIComm.enter(comm):
        with set_options(global_cache_size=5e9, dask_chunk_size=75):
            s = UniformCatalog(1000, 1.0)

            # check cache size
            cache = GlobalCache.get()
            assert cache.cache.available_bytes == 5e9

            # check chunk size
            assert s['Position'].chunks[0][0] == 75

        s = UniformCatalog(1000, 1.0)
        assert s['Position'].chunks[0][0] == s.size
コード例 #8
0
ファイル: test_catalogmesh.py プロジェクト: twobombs/nbodykit
def test_odd_chunksize(comm):
    # no errors shall occur. This is a regression test.

    source = ArrayCatalog({
        'Position': numpy.ones((2000, 3)),
    },
                          BoxSize=512.,
                          comm=comm)

    # make the mesh
    mesh = source.to_mesh(resampler='cic',
                          Nmesh=64,
                          interlaced=True,
                          compensated=True)

    with set_options(paint_chunk_size=1111):
        mesh.compute()
コード例 #9
0
def test_bad_options():
    with pytest.raises(KeyError):
        set_options(no_this_option=3)
コード例 #10
0
def test_cache_size():
    with set_options(global_cache_size=100):
        cache = GlobalCache.get()
        assert cache.cache.available_bytes == 100
コード例 #11
0
is obscured by the galaxy.
FIXME: the conversion between redshift of source plane and comoving distance of
source plane uses a hardcoded Planck15 cosmology. Since we never talk about redshift
in an accurate way for wlen, this is probably OK for now. 
"""

import nbodykit
from nbodykit.lab import BigFileCatalog
from nbodykit.transform import ConcatenateSources, CartesianToEquatorial
from nbodykit.cosmology import Planck15
import numpy
import bigfile

from mpi4py import MPI
nbodykit.setup_logging()
nbodykit.set_options(dask_chunk_size=1024 * 1024)
nbodykit.set_options(global_cache_size=0)

from nbodykit.utils import DistributedArray, GatherArray

#nbodykit.set_options(global_cache_size=128)

import dask.array as da

# formula (from Sukhdeep Singh)

# int dss  Ps(zs) [ int dxl omega_m / sigma(zs, zl) delta_m(t, zl)]

# sukhdeep swapped the integral order

# int dxl delta_m(t, xl) [ int dzs Pl(zs) 1.5 omega_m / sigma(zs, zl)]
コード例 #12
0
ファイル: test_options.py プロジェクト: bccp/nbodykit
def test_cache_size():
    with set_options(global_cache_size=100):
        cache = GlobalCache.get()
        assert cache.cache.available_bytes == 100
コード例 #13
0
ファイル: test_options.py プロジェクト: bccp/nbodykit
def test_bad_options():
    with pytest.raises(KeyError):
        set_options(no_this_option=3)