Bug in mean_delta_sigma function for non-periodic-box
aphearin opened this issue · 0 comments
aphearin commented
The mean_delta_sigma function should give identical results if the particles are divided in half and the results on the two halves are summed at the end. As pointed out by @johannesulf this test is successful for the case of a periodic box, but there is a minor discrepancy when the box is not periodic. Here is a minimal reproducer:
from halotools.mock_observables import return_xyz_formatted_array, mean_delta_sigma
import numpy as np
from halotools.sim_manager import CachedHaloCatalog
halocat = CachedHaloCatalog(simname='bolplanck')
halos = halocat.halo_table
ptcls = halocat.ptcl_table
pos_halos = return_xyz_formatted_array(halos['halo_x'], halos['halo_y'],
halos['halo_z'])
pos_ptcls = return_xyz_formatted_array(ptcls['x'], ptcls['y'], ptcls['z'])
rp_bins = np.logspace(-1, +1, 11)
ds_tot = mean_delta_sigma(pos_halos[:10000], pos_ptcls, 1e9, rp_bins)
ds_1 = mean_delta_sigma(pos_halos[:10000], pos_ptcls[::2], 1e9, rp_bins)
ds_2 = mean_delta_sigma(pos_halos[:10000], pos_ptcls[1::2], 1e9, rp_bins)
print(ds_tot)
print(ds_1 + ds_2)
print(ds_tot / (ds_1 + ds_2))