def checker(path_to_input, path_to_output):
    true_output = {}
    user_output = {}

    with open(path_to_input, 'r') as f:
        true_len = int(f.readline())
        true_inp_pts = [
            list(map(float,
                     f.readline().split())) for _ in range(true_len)
        ]

    true_pts = ConvexHull(true_inp_pts).vertices
    true_pts = [true_inp_pts[x] for x in true_pts]
    true_pts += [true_pts[0]]
    if isinstance(true_pts, np.ndarray):
        true_pts = true_pts.tolist()

    true_pts = true_pts[:-1]

    true_pts = [true_inp_pts.index(x) + 1 for x in true_pts]

    with open(path_to_output, 'r') as f:
        t = float(f.readline())
        output_len = int(f.readline())
        # output_pts = [list(map(float, f.readline().split())) for _ in range(output_len)]
        output_pts = list(map(int, f.readline().split()))

        user_output['list'] = output_pts

    true_output['list'] = true_pts
    print(t)
    return user_output, true_output, output_pts == true_pts
Пример #2
0
    def convexhull(self, vertices=True):
        if vertices:
            hull = ConvexHull(self.points).vertices
            return [
                self.points[vertex, :2].reshape(1, -1)
                for vertex in hull.tolist()
            ]

        else:
            return ConvexHull(self.points)
Пример #3
0
 def CH_vertices(l):
     point = SA.get_point(l)
     hull = CH(point).vertices
     hull = hull.tolist()
     count = 0
     result = []
     while len(hull) != 0:
         if count in hull:
             result.append(point[count])
             hull.remove(count)
         count += 1
     return result
Пример #4
0
def calc_plot_json(observer, sat_id, radial, angular, long, lat):

    if sat_id == 0:

        v = plot_update(radial, angular, -long, lat)

        v = rotation(observer.observer_coordinate.lon / u.deg + 90, -observer.observer_coordinate.lat / u.deg, v, n)

    else:
        v = plot_update(radial, angular, -long, lat)

        v = rotation(observer.observer_coordinate.lon / u.deg + 90, observer.observer_coordinate.lat / u.deg, v, n)

    points = np.array(list(zip(np.ravel(v[0]), np.ravel(v[2]))))
    hull = ConvexHull(points, qhull_options='QbB')

    # sun center point on the picture
    # obtains CRVAL1 = r_x and CRVAL = r_y
    sun_x_center, sun_y_center = observer.reference_pixel

    # used to determine how far the lemniscate must be moved
    # due to the picture not having the sun in the exact center
    # 128 = have of the dimensions of the plot

    x_translate = (sun_x_center / u.pix) - 128
    y_translate = (sun_y_center / u.pix) - 128

    # determines aspect ratio for distance from satellite
    pic_width_ratio = pic_wcs_length(observer, 256, 128, r_x=128, r_y=128)

    lem_distance_c_ratio = (AU_REFERENCE_CUBE * u.AU).to(u.km) / pic_width_ratio

    hull = np.array(((points[hull.vertices, 0] * lem_distance_c_ratio + x_translate),
                     (points[hull.vertices, 1] * lem_distance_c_ratio + y_translate)))

    return json.dumps(hull.tolist())