Example #1
0
    def focus_surface(self, surface_to_move: SurfaceData,
                      previous_surface: SurfaceData) -> None:
        """
        move the location of a surface to the closest approach to the target position
        given by the user in the configuration file

        :param surface_to_move: the surface that will be moved
        :param previous_surface: the surface previous to the surface being moved
        :return:
        """
        self.focus_found = True
        # flag surface as being focused
        surface_to_move.target_focused = True
        # surface_to_move.surface_type = 4

        # get position of target
        lla_target = np.asarray([
            self.cnf.surface_focusing_lat, self.cnf.surface_focusing_lon,
            self.cnf.surface_focusing_alt
        ])
        pos_target = lla2ecef(lla_target, self.cst)

        # get current position of focus surface & previous
        pos_focus = np.asmatrix(surface_to_move.ecef_surf)
        pos_prior = np.asmatrix(previous_surface.ecef_surf)

        # calculate along-track direction vector
        along_track = pos_focus - pos_prior
        along_track /= np.linalg.norm(along_track)

        # calculate vector from previous surface to target position
        rel_target = pos_target - pos_prior

        # project relative target vector onto along-track direction
        cos_a = (along_track * rel_target.T) / np.linalg.norm(rel_target)
        rel_focus = (np.linalg.norm(rel_target) * cos_a) * along_track

        # get position to move surface to
        x_move, y_move, z_move = np.ravel(rel_focus)
        focus_x = previous_surface.x_surf + x_move
        focus_y = previous_surface.y_surf + y_move
        focus_z = previous_surface.z_surf + z_move
        focus_ecef = np.asarray([focus_x, focus_y, focus_z])

        # set new position of focus surface
        surface_to_move.x_surf = focus_x
        surface_to_move.y_surf = focus_y
        surface_to_move.z_surf = focus_z

        focus_lla = ecef2lla(focus_ecef, self.cst)
        focus_lat, focus_lon, focus_alt = np.ravel(focus_lla)
        surface_to_move.lat_surf = focus_lat
        surface_to_move.lon_surf = focus_lon
        surface_to_move.alt_surf = focus_alt

        surface_to_move.win_delay_surf =\
            (surface_to_move.alt_sat - surface_to_move.alt_surf) * 2. / self.cst.c