halotools.mock_observables.large_scale_density_spherical_volume(sample, tracers, radius, period=None, sample_volume=None, num_threads=1, approx_cell1_size=None, norm_by_mean_density=False)[source]

Calculate the mean density of the input sample from an input set of tracer particles using a sphere centered on each point in the input sample as the tracer volume.

Around each point in the input sample, a sphere of the input radius is placed and the number of points in the input tracers is counted, optionally accounting for box periodicity. The large_scale_density_spherical_volume function returns the mean number density of tracer particles in each such sphere, optionally normalizing this result by the global mean number density of tracer particles in the entire sample volume.


Npts1 x 3 numpy array containing 3-D positions of points. See the Formatting your xyz coordinates for Mock Observables calculations documentation page, or the Examples section below, for instructions on how to transform your coordinate position arrays into the format accepted by the sample and tracers arguments.


Npts2 x 3 numpy array containing 3-D positions of tracers.


Radius of the sphere used to define the volume inside which the number density of tracers is calculated. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

periodarray_like, optional

Length-3 sequence defining the periodic boundary conditions in each dimension. If you instead provide a single scalar, Lbox, period is assumed to be the same in all Cartesian directions. If set to None (the default option), PBCs are set to infinity, and an input sample_volume must be provided. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

sample_volumefloat, optional

If period is set to None, you must specify the effective volume of the sample. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

num_threadsint, optional

Number of threads to use in calculation, where parallelization is performed using the python multiprocessing module. Default is 1 for a purely serial calculation, in which case a multiprocessing Pool object will never be instantiated. A string ‘max’ may be used to indicate that the pair counters should use all available cores on the machine.

approx_cell1_sizearray_like, optional

Length-3 array serving as a guess for the optimal manner by how points will be apportioned into subvolumes of the simulation box. The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations.

norm_by_mean_densitybool, optional

If set to True, the returned number density will be normalized by the global number density of tracer particles averaged across the entire sample_volume. Default is False.


Length-Npts1 array of number densities


>>> npts1, npts2 = 100, 200
>>> sample = np.random.random((npts1, 3))
>>> tracers = np.random.random((npts2, 3))
>>> radius = 0.1
>>> result = large_scale_density_spherical_volume(sample, tracers, radius, period=1)