Skip to content

Commit

Permalink
fix the other modules and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paganol committed Oct 31, 2024
1 parent 62550ae commit 5f96d92
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
2 changes: 1 addition & 1 deletion litebird_sim/hwp_diff_emiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# here we calculate 2f directly.
@njit
def compute_2f_for_one_sample(angle_rad, amplitude_k, monopole_k):
return amplitude_k * np.cos(angle_rad) + monopole_k
return amplitude_k * np.cos(2 * angle_rad) + monopole_k


@njit(parallel=True)
Expand Down
18 changes: 7 additions & 11 deletions litebird_sim/hwp_sys/hwp_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ def fill_tod(
If ``observations`` is a list, ``pointings`` must be a list of same length.
hwp_angle (optional): `2ωt`, hwp rotation angles (radians). If ``pointings`` is passed,
hwp_angle (optional): `ωt`, hwp rotation angles (radians). If ``pointings`` is passed,
``hwp_angle`` must be passed as well, otherwise both must be ``None``.
If not passed, it is computed on the fly (generated by :func:`lbs.get_pointings`
per detector).
Expand Down Expand Up @@ -1297,7 +1297,7 @@ def fill_tod(
mUQ=self.mUQ,
mQU=self.mQU,
pixel_ind=pix,
theta=cur_hwp_angle / 2, # hwp angle returns 2ωt
theta=cur_hwp_angle,
psi=psi,
xi=xi,
maps=self.maps,
Expand All @@ -1315,7 +1315,7 @@ def fill_tod(
mUQ=self.mUQ,
mQU=self.mQU,
pixel_ind=pix,
theta=cur_hwp_angle / 2, # hwp angle returns 2ωt
theta=cur_hwp_angle,
psi=psi,
xi=xi,
maps=self.maps,
Expand All @@ -1340,7 +1340,7 @@ def fill_tod(
mUQs=self.mUQs,
mQUs=self.mQUs,
pixel_ind=pix,
theta=cur_hwp_angle / 2, # hwp angle returns 2ωt
theta=cur_hwp_angle,
psi=psi,
xi=xi,
)
Expand All @@ -1359,19 +1359,15 @@ def fill_tod(
mUQs=self.mUQs,
mQUs=self.mQUs,
pixel_ind=pix,
theta=cur_hwp_angle / 2, # hwp angle returns 2ωt
theta=cur_hwp_angle,
psi=psi,
xi=xi,
)

else:
# in this case factor 4 included here
ca = np.cos(
2 * cur_point[:, 2] + 4 * cur_hwp_angle / 2
) # hwp angle returns 2ωt
sa = np.sin(
2 * cur_point[:, 2] + 4 * cur_hwp_angle / 2
) # hwp angle returns 2ωt
ca = np.cos(2 * cur_point[:, 2] + 4 * cur_hwp_angle)
sa = np.sin(2 * cur_point[:, 2] + 4 * cur_hwp_angle)

self.atd[pix, 0] += tod * 0.5
self.atd[pix, 1] += tod * ca * 0.5
Expand Down
4 changes: 2 additions & 2 deletions test/test_scan_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ def test_scan_map_no_interpolation():
pixind = hpx.ang2pix(pointings[idet, :, 0:2])
obs2.tod[idet, :] = (
maps[0, pixind]
+ np.cos(2 * (pointings[idet, :, 2] + hwp_angle)) * maps[1, pixind]
+ np.sin(2 * (pointings[idet, :, 2] + hwp_angle)) * maps[2, pixind]
+ np.cos(2 * pointings[idet, :, 2] + 4 * hwp_angle) * maps[1, pixind]
+ np.sin(2 * pointings[idet, :, 2] + 4 * hwp_angle) * maps[2, pixind]
)

out_map2 = lbs.make_binned_map(
Expand Down
2 changes: 1 addition & 1 deletion test/test_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_simulation_pointings_hwp_mjd(tmp_path):

pointings_and_orientation, hwp_angle = obs.get_pointings("all")

pointings_and_orientation[..., 2] += hwp_angle
pointings_and_orientation[..., 2] += 2 * hwp_angle

filename = Path(__file__).parent / f"reference_obs_pointings_hwp{idx:03d}.npy"
reference = np.load(filename, allow_pickle=False)
Expand Down

0 comments on commit 5f96d92

Please sign in to comment.