Skip to content

Commit

Permalink
redefinition of hwp_angle
Browse files Browse the repository at this point in the history
  • Loading branch information
paganol committed Oct 31, 2024
1 parent d49fc33 commit 62550ae
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 16 additions & 6 deletions litebird_sim/hwp.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _get_ideal_hwp_angle(
for sample_idx in range(output_buffer.size):
angle = (
start_angle_rad
+ (start_time_s + delta_time_s * sample_idx) * 2 * ang_speed_radpsec
+ (start_time_s + delta_time_s * sample_idx) * ang_speed_radpsec
) % (2 * np.pi)

output_buffer[sample_idx] = angle
Expand All @@ -139,7 +139,14 @@ def _get_ideal_hwp_angle(
def _add_ideal_hwp_angle(
pointing_buffer, start_time_s, delta_time_s, start_angle_rad, ang_speed_radpsec
):
detectors, samples, _ = pointing_buffer.shape
shape = pointing_buffer.shape
if len(shape) == 3:
detectors, samples, _ = shape
elif len(shape) == 2:
detectors, samples = shape
else:
ValueError("Wrong shape for the pointing_buffer")

hwp_angles = np.empty(samples, dtype=pointing_buffer.dtype)
_get_ideal_hwp_angle(
output_buffer=hwp_angles,
Expand All @@ -148,9 +155,12 @@ def _add_ideal_hwp_angle(
start_angle_rad=start_angle_rad,
ang_speed_radpsec=ang_speed_radpsec,
)

for det_idx in range(detectors):
pointing_buffer[det_idx, :, 2] += hwp_angles
if len(shape) == 3:
for det_idx in range(detectors):
pointing_buffer[det_idx, :, 2] += 2 * hwp_angles
elif len(shape) == 2:
for det_idx in range(detectors):
pointing_buffer[det_idx, :] += 2 * hwp_angles


class IdealHWP(HWP):
Expand Down Expand Up @@ -202,7 +212,7 @@ def apply_hwp_to_pointings(
bore2ecl_quaternions_inout: npt.NDArray, # Boresight→Ecliptic quaternions at 19 Hz
hwp_angle_out: npt.NDArray,
) -> None:
# We do not touch `bore2ecl_quaternions_inout`, as an ideal HWP does not
# We do not touch `bore2ecl_quaternions_input`, as an ideal HWP does not
# alter the (θ, φ) direction of the boresight nor the orientation ψ
self.get_hwp_angle(
output_buffer=hwp_angle_out,
Expand Down
4 changes: 2 additions & 2 deletions litebird_sim/scan_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def scan_map(
input_T=maps_det[0, pixel_ind_det],
input_Q=maps_det[1, pixel_ind_det],
input_U=maps_det[2, pixel_ind_det],
pol_angle_det=curr_pointings_det[:, 2] + hwp_angle,
pol_angle_det=curr_pointings_det[:, 2] + 2 * hwp_angle,
)

elif interpolation == "linear":
Expand All @@ -102,7 +102,7 @@ def scan_map(
input_U=hp.get_interp_val(
maps_det[2, :], curr_pointings_det[:, 0], curr_pointings_det[:, 1]
),
pol_angle_det=curr_pointings_det[:, 2] + hwp_angle,
pol_angle_det=curr_pointings_det[:, 2] + 2 * hwp_angle,
)

else:
Expand Down

0 comments on commit 62550ae

Please sign in to comment.