Exemplo n.º 1
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.º 2
0
    def __attitude_spline(self):
        """
        Creates spline for each component of the attitude quaternion:
            s_x, s_y, s_z, s_w

        Attributes
        -----------
        :func_attitude: lambda func, returns: attitude quaternion at time t from spline.
        :func_x_axis_lmn: lambda func, returns: position of x_axis of satellite at time t, in lmn frame.
        :func_z_axis_lmn: lambda func, returns: position of z_axis of satellite at time t, in lmn frame.
        """
        w_list = []
        x_list = []
        y_list = []
        z_list = []
        t_list = []

        for obj in self.storage:
            t_list.append(obj[0])
            x_list.append(obj[4].x)
            y_list.append(obj[4].y)
            z_list.append(obj[4].z)
            w_list.append(obj[4].w)

        # print('t_list:', t_list)  # # TODO: remove this line

        # This should be faster ??
        # t_list = np.array(self.storage)[:, 0]
        # x_list = np.array(self.storage)[:, 4].x
        # y_list = np.array(self.storage)[:, 4].y
        # z_list = np.array(self.storage)[:, 4].z
        # w_list = np.array(self.storage)[:, 4].w

        # Splines for each coordinates i, i_list at each time in t_list of degree k (order = k+1)
        self.s_w = interpolate.InterpolatedUnivariateSpline(
            t_list, w_list, k=self.spline_order)
        self.s_x = interpolate.InterpolatedUnivariateSpline(
            t_list, x_list, k=self.spline_order)
        self.s_y = interpolate.InterpolatedUnivariateSpline(
            t_list, y_list, k=self.spline_order)
        self.s_z = interpolate.InterpolatedUnivariateSpline(
            t_list, z_list, k=self.spline_order)

        # Alternativ efor the splines
        # self.s_w_tck = splrep(t_list, w_list, s=0, k=self.spline_order)
        # self.s_x_tck = splrep(t_list, x_list, s=0, k=self.spline_order)
        # self.s_y_tck = splrep(t_list, y_list, s=0, k=self.spline_order)
        # self.s_z_tck = splrep(t_list, z_list, s=0, k=self.spline_order)

        # Attitude
        self.func_attitude = lambda t: np.quaternion(self.s_w(t), self.s_x(
            t), self.s_y(t), self.s_z(t)).normalized()
        # Attitude in the lmn frame
        self.func_x_axis_lmn = lambda t: ft.xyz_to_lmn(self.func_attitude(
            t), np.array([1, 0, 0]))  # wherewe want to be
        self.func_y_axis_lmn = lambda t: ft.xyz_to_lmn(self.func_attitude(t),
                                                       np.array([0, 1, 0]))
        self.func_z_axis_lmn = lambda t: ft.xyz_to_lmn(self.func_attitude(t),
                                                       np.array([0, 0, 1]))
Exemplo n.º 3
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.º 4
0
def generate_observation_wrt_attitude(attitude):
    """
    returns right ascention and declination corresponding to the direction in
    which the x-vector rotated to *attitude* is pointing
    returns alpha, delta in radians
    """
    artificial_Su = [1, 0, 0]
    artificial_Cu = ft.xyz_to_lmn(attitude, artificial_Su)
    alpha, delta = ft.vector_to_alpha_delta(artificial_Cu)
    return alpha, delta
Exemplo n.º 5
0
    def __init_state(self):
        """
        :return: initial status of satellite
        """
        self.t = 0
        self._lambda = 0
        self._beta = 0
        self.nu = 0
        self.omega = 0

        self.l, self.j, self.k = ft.compute_ljk(self.epsilon)

        self.s = self.l*np.cos(self._lambda) + self.j*np.sin(self._lambda)

        self.attitude = self.__init_attitude()

        self.z = ft.xyz_to_lmn(self.attitude, np.array([0, 0, 1]))
        self.x = ft.xyz_to_lmn(self.attitude, np.array([1, 0, 0]))
        self.w = np.cross(np.array([0, 0, 1]), self.z)
Exemplo n.º 6
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
Exemplo n.º 7
0
def generate_observation_wrt_attitude(attitude):
    """
    Create coordinates of a star in the position of the x-axis of the attitude
    of the satellite

    :param attitude: The attitude of the satellite
    :returns: [tuple of floats] [rads]right ascention and declination
     corresponding to the direction in which the x-vector rotated to *attitude*
     is pointing
    """
    artificial_Su = [1, 0, 0]
    artificial_Cu = ft.xyz_to_lmn(attitude, artificial_Su)
    alpha, delta = ft.vector_to_alpha_delta(artificial_Cu)
    return alpha, delta