Exemplo n.º 1
0
def get_obs_in_CoMRS(source, sat, t):
    """
    Get observation in the Co-Moving Reference System.

    :param source: [source object]
    :param sat: [Satellite object]
    :param t:
    :returns: (:math:`\\alpha, \\delta`) of the observation in CoMRS
    """

    attitude = sat.func_attitude(t)
    phi, zeta = observed_field_angles(
        source, attitude, sat, t,
        double_telescope=False)  # even if we have 2 telescope
    field_index = np.sign(phi)
    eta = field_index * const.Gamma_c / 2

    z_axis = np.array([0, 0, 1])
    quat1 = quaternion.from_rotation_vector(z_axis * eta)
    Sx_rot_eta = ft.rotate_by_quaternion(quat1, np.array([1, 0, 0]))

    vect = np.cross(Sx_rot_eta / np.linalg.norm(Sx_rot_eta), z_axis)
    quat2 = quaternion.from_rotation_vector(vect * zeta)
    Sx_rot_eta_zeta = ft.rotate_by_quaternion(quat2, Sx_rot_eta)

    obs_in_CoMRS = ft.xyz_to_lmn(attitude, Sx_rot_eta_zeta)
    return obs_in_CoMRS
Exemplo n.º 2
0
def get_angular_FFoV_PFoV(sat, t):
    """
    Computes angular positions (righ ascension :math:`\\alpha`, declination
    :math:`\\delta`) of the fields of view as a function of time. The angles are
    as seen from the satellite (Co-Moving Reference System).

    :param sat: [Satellite object]
    :param t: time at which we want the FoVs pointing directions
    :returns: :math:`\\alpha_{PFoV}, \\delta_{PFoV},
     \\alpha_{FFoV},\\delta_{FFoV}`
    """
    z_axis = np.array([0, 0, 1])
    attitude = sat.func_attitude(t)

    angle = const.Gamma_c / 2
    quat_PFoV = quaternion.from_rotation_vector(z_axis * angle)
    quat_FFoV = quaternion.from_rotation_vector(z_axis * (-angle))

    PFoV_SRS = ft.rotate_by_quaternion(quat_PFoV, np.array([1, 0, 0]))
    FFoV_SRS = ft.rotate_by_quaternion(quat_FFoV, np.array([1, 0, 0]))

    PFoV_CoMRS = ft.xyz_to_lmn(attitude, PFoV_SRS)
    FFoV_CoMRS = ft.xyz_to_lmn(attitude, FFoV_SRS)

    alpha_PFoV, delta_PFoV = ft.vector_to_alpha_delta(PFoV_CoMRS)
    alpha_FFoV, delta_FFoV = ft.vector_to_alpha_delta(FFoV_CoMRS)

    return alpha_PFoV, delta_PFoV, alpha_FFoV, delta_FFoV
Exemplo n.º 3
0
def attitude_from_alpha_delta(source, sat, t, vertical_angle_dev=0):
    """
    :param source: [Source object]
    :param sat: [satellite object]
    :param t: [float] time
    :param vertical_angle_dev: how much we deviate from zeta
    """
    Cu = source.unit_topocentric_function(sat, t)
    Su = np.array([1, 0, 0])
    if vertical_angle_dev == 0:
        vector, angle = helpers.get_rotation_vector_and_angle(Cu, Su)
        q_out = quaternion.from_rotation_vector(angle * vector)
    else:
        Cu_xy = helpers.normalize(np.array([Cu[0], Cu[1],
                                            0]))  # Cu on S-[xy] plane
        v1, a1 = helpers.get_rotation_vector_and_angle(Cu_xy, Su)
        q1 = quaternion.from_rotation_vector(v1 * a1)

        Su_xy = ft.rotate_by_quaternion(
            q1.inverse(), Su)  # Su rotated to be on same xy than Cu_xy
        v2, a2 = helpers.get_rotation_vector_and_angle(Cu, Su_xy)
        q2_dev = quaternion.from_rotation_vector(v2 *
                                                 (a2 + vertical_angle_dev))
        # deviaetd_Su = ft.rotate_by_quaternion(q2_dev.inverse(), Su_xy)
        q_out = q1 * q2_dev
        # angle -= 0.2
    return q_out
Exemplo n.º 4
0
def scanning_y_coordinate(source, sat, t):
    raise ValueError('This function is obsolete')
    # raise ValueError('Check that ')
    att = get_fake_attitude(source, sat, t)
    y_vec = ft.rotate_by_quaternion(att, [0, 1, 0])
    # vector = vector/np.linalg.norm(vector)
    # satellite_position = sat.ephemeris_bcrs(t)
    return y_vec
Exemplo n.º 5
0
def scanning_direction(source, sat, t):
    """
    Computes the y-coordinates of the SRS frame, which is an approximation of
    the scanning direction. Use for plotting alone
    """
    raise ValueError('This functinon is obsolete')
    att = sat.func_attitude(t)
    scanning_y_coordinate = ft.rotate_by_quaternion(att, [0, 1, 0])
    return scanning_y_coordinate
Exemplo n.º 6
0
 def test_rotation_with_quat(self):
     v1 = np.random.rand(3)
     v2 = np.random.rand(3)
     v1 = v1 / np.linalg.norm(v1)
     v2 = v2 / np.linalg.norm(v2)
     vector, angle = helpers.get_rotation_vector_and_angle(v1, v2)
     quat = quaternion.from_rotation_vector(vector * angle)
     v2_bis = ft.rotate_by_quaternion(quat, v1)
     for i in range(vector.shape[0]):
         self.assertAlmostEqual(v2[i], v2_bis[i])
Exemplo n.º 7
0
def get_angular_FFoV_PFoV(sat, t):
    """
    return angular positions (alpha, delta) of the fields of view as a
    function of time.
    """
    z_axis = np.array([0, 0, 1])
    attitude = sat.func_attitude(t)

    quat_PFoV = quaternion.from_rotation_vector(z_axis * const.Gamma_c / 2)
    quat_FFoV = quaternion.from_rotation_vector(z_axis * (-const.Gamma_c / 2))

    PFoV_SRS = ft.rotate_by_quaternion(quat_PFoV, np.array([1, 0, 0]))
    FFoV_SRS = ft.rotate_by_quaternion(quat_FFoV, np.array([1, 0, 0]))

    PFoV_CoMRS = ft.xyz_to_lmn(attitude, PFoV_SRS)
    FFoV_CoMRS = ft.xyz_to_lmn(attitude, FFoV_SRS)

    alpha_PFoV, delta_PFoV = ft.vector_to_alpha_delta(PFoV_CoMRS)
    alpha_FFoV, delta_FFoV = ft.vector_to_alpha_delta(FFoV_CoMRS)

    return alpha_PFoV, delta_PFoV, alpha_FFoV, delta_FFoV