import cmath
import re
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import math
from matplotlib.animation import FuncAnimation
import os
azimuth_list = []
distance_list = []
# x_axis = []
# y_axis = []
aoa_loc_data = []
index = 0
curve = 0
output_gif = "output\\gif\\"
output_csv = "output\\csv\\"
output_png = "output\\png\\"
def create_csv(file_input, line, data):
global azimuth
global distance
with open(file_input, 'w') as file_ob:
while line:
line = data.readline()
tmp_distance_re = re.search(r'Distance \d+', line)
tmp_azimuth_re = re.search(r'AoA azimuth -?\d+', line)
if tmp_distance_re and tmp_azimuth_re:
distance = int(tmp_distance_re.group(0).replace('Distance ', ''))
distance /= 100
azimuth = int(tmp_azimuth_re.group(0).replace('AoA azimuth ', ''))
#azimuth = 0
file_ob.write('%.02f,%d\n' % (distance, azimuth))
#
# print('原始:%.02fm %d' % (distance, azimuth))
# azimuth = 0 - azimuth;
# print('镜像:%.02fm %d' % (distance, azimuth))
# #azimuth = azimuth if (azimuth >= 0) else (azimuth + 360)
# azimuth = azimuth * np.pi / 180.
# print("弧度:%.02fm %f" % (distance, azimuth))
# file_ob.write('%.02f,%.02f\n' % (distance, azimuth))
def load_file(file_name):
_log_file_name = file_name + '.log'
_csv_filename = os.path.join(output_csv, file_name)
_csv_filename = _csv_filename + '.csv'
data = open(_log_file_name)
line = data.readline()
create_csv(_csv_filename, line, data)
data.close()
def load_data(file_name):
global aoa_loc_data
#csv_filename = file_name + '.csv'
_csv_filename = os.path.join(output_csv, file_name)
_csv_filename = _csv_filename + '.csv'
load_file(file_name)
aoa_loc_data = pd.read_csv(_csv_filename, header=None)
print(len(aoa_loc_da