diff --git a/litebird_sim/quaternions.py b/litebird_sim/quaternions.py index a79d0cce..d8504466 100644 --- a/litebird_sim/quaternions.py +++ b/litebird_sim/quaternions.py @@ -501,17 +501,6 @@ def quat_rotation_brdcast(theta_rad, vec_matrix): [vec_matrix * s, np.cos(theta_rad / 2) * np.ones((vec_matrix.shape[0], 1))] ) -def quat_rotation_brdcast_single_axis(theta_rad_array, vec): - """This function rotates a quaternion by theta_rad about a specific axis. - Args: - theta_rad_array (numpy.array): The angles to rotate the quaternion by in radians. - vec (numpy.array[3]): The vector to rotate the quaternion about. - """ - s = np.sin(theta_rad_array / 2) - c = np.cos(theta_rad_array / 2) - return np.hstack( - [vec * s[:, np.newaxis], c[:, np.newaxis]] - ) def quat_rotation_x_brdcast(theta_rad_array): """Return a quaternion representing a rotation around the x axis diff --git a/litebird_sim/scanning.py b/litebird_sim/scanning.py index 731bc9f4..53ca9e21 100644 --- a/litebird_sim/scanning.py +++ b/litebird_sim/scanning.py @@ -483,19 +483,19 @@ def __mul__(self, other: "RotQuaternion") -> "RotQuaternion": assert ( self.quats.shape == other.quats.shape ), f"quaternions have different shapes: {self.quats.shape} vs {other.quats.shape}" - assert ( - isinstance(self.start_time, type(other.start_time)) + assert isinstance( + self.start_time, type(other.start_time) ), f"start_time must have the same type: {type(self.start_time)} vs {type(other.start_time)}" if isinstance(self.start_time, float): - assert ( - np.isclose(self.start_time, other.start_time) + assert np.isclose( + self.start_time, other.start_time ), f"start_time must be the same value: {self.start_time} vs {other.start_time}" else: assert ( self.start_time == other.start_time ), f"start_time must be the same value: {self.start_time} vs {other.start_time}" - assert ( - np.isclose(self.sampling_rate_hz, other.sampling_rate_hz) + assert np.isclose( + self.sampling_rate_hz, other.sampling_rate_hz ), f"sampling_rate_hz must be the same value: {self.sampling_rate_hz} vs {other.sampling_rate_hz}" result_start_time = self.start_time @@ -540,12 +540,14 @@ def conj(self): return RotQuaternion( start_time=self.start_time, sampling_rate_hz=self.sampling_rate_hz, - quats=np.array([ - -self.quats[:,0], - -self.quats[:,1], - -self.quats[:,2], - self.quats[:,3] - ]), + quats=np.array( + [ + -self.quats[:, 0], + -self.quats[:, 1], + -self.quats[:, 2], + self.quats[:, 3], + ] + ), ) def slerp( diff --git a/test/test_pointing_sys.py b/test/test_pointing_sys.py index 714c5c56..11c62bdb 100644 --- a/test/test_pointing_sys.py +++ b/test/test_pointing_sys.py @@ -10,7 +10,7 @@ import litebird_sim as lbs -make_reference_file = False # if True, generate reference file at `path_of_reference`. +make_reference_file = False # if True, generate reference file at `path_of_reference`. telescopes = ["LFT", "MFT", "HFT"] start_time = 0 @@ -271,7 +271,6 @@ def test_PointingSys_add_single_offset_to_spacecraft( axis = "x" pointing_sys.spacecraft.add_offset(single_offset, axis) - lbs.prepare_pointings( sim.observations, sim.instrument, sim.spin2ecliptic_quats, hwp=sim.hwp ) @@ -314,7 +313,6 @@ def test_PointingSys_add_common_disturb_to_spacecraft( axis = "x" pointing_sys.spacecraft.add_disturb(noise_rad_1d_array, axis) - lbs.prepare_pointings( sim.observations, sim.instrument, sim.spin2ecliptic_quats, hwp=sim.hwp ) @@ -339,6 +337,7 @@ def test_PointingSys_add_common_disturb_to_spacecraft( atol=atol, ) + @pytest.mark.parametrize("telescope", telescopes) def test_PointingSys_add_hwp_rot_disturb( telescope, make_reference_file=make_reference_file @@ -354,10 +353,11 @@ def test_PointingSys_add_hwp_rot_disturb( wedge_angle_rad = np.deg2rad(1.0) refractive_idx = 3.1 tilt_angle_rad = pointing_sys.hwp.get_wedgeHWP_pointing_shift_angle( - wedge_angle_rad, - refractive_idx + wedge_angle_rad, refractive_idx + ) + pointing_sys.hwp.add_hwp_rot_disturb( + tilt_angle_rad, ang_speed_radpsec, tilt_phase_rad ) - pointing_sys.hwp.add_hwp_rot_disturb(tilt_angle_rad, ang_speed_radpsec, tilt_phase_rad) lbs.prepare_pointings( sim.observations, sim.instrument, sim.spin2ecliptic_quats, hwp=sim.hwp