-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Bug description:
At https://github.com/21cmfast/21cmFAST/blob/main/src/py21cmfast/rsds.py#L106
Fields with RSDs have kinks in the edges when using apply_rsds with periodic=True.
Proof:
This is demonstrated in the following images.
The orange line is the mean of the Tb field of a coeval cube for different redshifts (shown here in pixels). Blue line is the same after using the function apply_rsds with periodic=True. There is an apparent unnatural kink close to the 0th pixel.
For reference, here I plot the same thing, but now with green it's the result using the same function apply_rsds, with periodic=False but manually adding 2 copies of the original box at higher and lower z (i.e,. concatenating the same box at the edges to apply periodic boundary conditions).
To reproduce:
Compare:
lc_with_rsds = apply_rsds(
field = lc,
los_velocity = lc_velocity_z,
redshifts= lc_redshifts,
inputs_dict = inputs_dict,
periodic = True,
n_rsd_subcells = 1,
)
with
pad=lc.shape[0]
inputs_dict['H_at_all_z'] = Planck18.H(padded_lc_redshifts)
padded_lc = np.concatenate([lc[:, :, -pad:],
lc,
lc[:, :, :pad]], axis=2)
padded_lc_velocity_z = np.concatenate([lc_velocity_z[:, :, -pad:],
lc_velocity_z,
lc_velocity_z[:, :, :pad]], axis=2)
lc_with_rsds_padded = RSDs.apply_rsds(
field = padded_lc,
los_velocity = padded_lc_velocity_z,
redshifts= padded_lc_redshifts,
inputs_dict = inputs_dict,
periodic = False,
n_rsd_subcells = 1,
)
lc_with_rsds_correct = lc_with_rsds_padded[:,:,pad:-pad]