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)
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)
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)
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()
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
def test_bad_options(): with pytest.raises(KeyError): set_options(no_this_option=3)
def test_cache_size(): with set_options(global_cache_size=100): cache = GlobalCache.get() assert cache.cache.available_bytes == 100
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)]