Exemplo n.º 1
0
def main():
    text1 = tknzr.tokenize_file("sample_input.txt")
    processed_text1 = preprocess_text(text1)
    v11 = build_vector(processed_text1)
    v12 = build_vector(processed_text1, type="bigram")
    print(v11)
    print(v12)
    text2 = tknzr.tokenize_file("sample_input2.txt")
    processed_text2 = preprocess_text(text2)
    v21 = build_vector(processed_text2)
    v22 = build_vector(processed_text2, type="bigram")
    print(v21)
    print(v22)
    print(ang.angle_between(v11, v21))
    print(ang.angle_between(v12, v22))
def cng_fw(file1, file2):
    vc1 = cng.get_vector(file1)
    vc2 = cng.get_vector(file2)
    vf1 = fw.get_vector(file1)
    vf2 = fw.get_vector(file2)
    v1 = vc1 + vf1
    v2 = vc2 + vf2
    return ang.angle_between(v1, v2)
def png_fw(file1, file2):
    vp1 = png.get_vector(file1)
    vp2 = png.get_vector(file2)
    vf1 = fw.get_vector(file1)
    vf2 = fw.get_vector(file2)
    v1 = vp1 + vf1
    v2 = vp2 + vf2
    return ang.angle_between(v1, v2)
def cng_png(file1, file2):
    vc1 = cng.get_vector(file1)
    vc2 = cng.get_vector(file2)
    vp1 = png.get_vector(file1)
    vp2 = png.get_vector(file2)
    v1 = vc1 + vp1
    v2 = vc2 + vp2
    return ang.angle_between(v1, v2)
def png_cng_fw_freq(file1, file2):
    vc1 = cng.get_vector(file1)
    vc2 = cng.get_vector(file2)
    vp1 = png.get_vector(file1)
    vp2 = png.get_vector(file2)
    vf1 = fw.get_vector(file1)
    vf2 = fw.get_vector(file2)
    f1 = freqd.get_freq(file1, local_thre)
    f2 = freqd.get_freq(file2, local_thre)
    v1 = vc1 + vp1 + vf1
    v1.append(f1 / 50)
    v2 = vc2 + vp2 + vf2
    v2.append(f2 / 50)
    return ang.angle_between(v1, v2)
Exemplo n.º 6
0
    ref_vectors = pd.DataFrame(data_dict_list)
    print("\nWE RCVD:")
    print(ref_vectors)

    # Build a simple list with numpy vectors for easier processing
    obs_positions = [
        np.array([rowt[1]['x'], rowt[1]['y'], rowt[1]['z']])
        for rowt in ref_vectors.iterrows()
    ]

    matches = []
    for i, obs_position in enumerate(obs_positions):
        # Calculate the angles between this observation and all other observations.
        # Find the two obervations which have the smallest angle.
        angels = [
            angle_between(obs_position, other_obs_pos)
            for other_obs_pos in obs_positions
        ]
        closest_obs = np.argsort(angels)[:3]

        # Get the angles as well as the angle between the two closest observations.
        a1 = angels[closest_obs[1]]
        a2 = angels[closest_obs[2]]
        ab = angle_between(obs_positions[closest_obs[1]],
                           obs_positions[closest_obs[2]])

        print(
            f"Two closest observations next to observation {i} are {closest_obs[1]} and {closest_obs[2]}"
        )
        index, error = stars_improved.find_by_angles(a1, a2, ab)
        print(f"Matched star from catalog: {index} (Error: {error:.6})")
def fw_only(file1, file2):
    v1 = fw.get_vector(file1)
    v2 = fw.get_vector(file2)
    return ang.angle_between(v1, v2)
def png_only(file1, file2):
    v1 = png.get_vector(file1)
    v2 = png.get_vector(file2)
    return ang.angle_between(v1, v2)
Exemplo n.º 9
0
def main():
    vec1 = get_vector("sample_input.txt")
    vec2 = get_vector("sample_input2.txt")
    print(ang.angle_between(vec1, vec2))
Exemplo n.º 10
0
#!/usr/bin/env python3
import pandas as pd
import numpy as np

import angle

ref_catalog = pd.read_csv('test.csv')  # import catalog reference vectors

for i, rowt in ref_catalog.iterrows():
    star_cat = np.array([rowt['x'], rowt['y'], rowt['z']])

    next_1_a = np.inf
    next_1_i = None
    next_2_a = np.inf
    next_2_i = None
    for i_t, rowt_t in ref_catalog.iterrows():
        if i == i_t:
            continue
        star_cat_t = np.array([rowt_t['x'], rowt_t['y'], rowt_t['z']])
        a = angle.angle_between(star_cat, star_cat_t)
        if a < next_1_a:
            next_2_a = next_1_a
            next_2_i = next_1_i
            next_1_a = a
            next_1_i = i_t
        elif a < next_2_a:
            next_2_a = a
            next_2_i = i_t
    print("Two closest stars next to", i, ":", next_1_i, next_1_a, next_2_i,
          next_2_a)
Exemplo n.º 11
0
    print(ref_vectors)

    indexes = []
    for i, rowt in ref_vectors.iterrows():
        star_obs = np.array([rowt['x'], rowt['y'], rowt['z']])

        # Find the closest two stars in the observation
        next_1_a = np.inf
        next_1_i = None
        next_2_a = np.inf
        next_2_i = None
        for i_t, rowt_t in ref_vectors.iterrows():
            if i == i_t:
                continue
            star_obs_t = np.array([rowt_t['x'], rowt_t['y'], rowt_t['z']])
            a = angle_between(star_obs, star_obs_t)
            if a < next_1_a:
                next_2_a = next_1_a
                next_2_i = next_1_i
                next_1_a = a
                next_1_i = i_t
            elif a < next_2_a:
                next_2_a = a
                next_2_i = i_t
        print("Two closest stars next to", i, "are :", next_1_i, next_1_a,
              next_2_i, next_2_a)
        index = stars.find_by_angles(next_1_a, next_2_a)
        print("Matched star:", index)
        indexes.append(index)

    # Remove duplicates, take a random subset and build a string