def convert_physical_to_comoving_vol(end_z): z_bins = np.linspace(0, end_z, 1000) comov_vol = WMAP7.comoving_volume(z_bins) comov_shell = comov_vol[:-1] - comov_vol[1:] z_shell = (z_bins[:-1] + z_bins[1:]) / 2.0 a_shell = 1.0 / (1.0 + z_shell) a3_shell = a_shell**3 total_comov_vol = np.sum(comov_shell) total_phys_vol = np.sum(comov_shell * a3_shell) return total_phys_vol / total_comov_vol