ZJUT_Nav/tools/plot.py

61 lines
1.3 KiB
Python
Raw Normal View History

import numpy as np
2022-11-28 21:52:36 +08:00
import pandas as pd
from readpos import readpos
import math
from geopy.distance import geodesic
import matplotlib.pyplot as plt
2022-11-28 21:52:36 +08:00
LG69T_path = "./llh.csv"
TC_Nav_path = "/Users/wakanda_shaw/Desktop/TC_Nav_Zjut/TC_NAV_Zjut_post/data/630_3/llh.pos"
D2R = math.pi/180
# 从.pos文件得到python lsit 格式数据
llh = readpos(TC_Nav_path)
LG69T_data = pd.read_csv(LG69T_path,names=['tow','lat','lon'],dtype=np.float64)
2022-11-28 21:52:36 +08:00
# list 转换到 dataframe
TC_Nav_data = pd.DataFrame(llh,columns=['tow','lat','lon'])
x=[]
y=[]
2022-11-28 21:52:36 +08:00
for i in range(len(TC_Nav_data)):
tow = TC_Nav_data.iloc[i,0]
if(tow==367036):
break
TC_lat = TC_Nav_data.iloc[i,1].round(10)
TC_lon = TC_Nav_data.iloc[i,2].round(10)
if tow==17 or tow==89:
continue
try:
LG_lat = LG69T_data.loc[(LG69T_data['tow']-18)==tow,['lat']]
LG_lat = LG_lat.iloc[0,0].round(10)
LG_lon = LG69T_data.loc[(LG69T_data['tow']-18)==tow,['lon']]
LG_lon = LG_lon.iloc[0,0].round(10)
except:
print(i,"pass")
continue
2022-11-28 21:52:36 +08:00
distance = geodesic((TC_lat,TC_lon),(LG_lat,LG_lon)).m
print(i,"距离:{:.3f}m".format(distance))
x.append(tow)
y.append(distance)
plt.plot(x,y,label='TC_Nav#C')
plt.legend(loc = 'upper right')
plt.grid() # 生成网格
plt.xlabel("time(s)")
plt.ylabel("distance(m)")
plt.show()
2022-11-28 21:52:36 +08:00