-
-
Save dj1711572002/e79e2c4ec5a2ceaca7824aa15819521f to your computer and use it in GitHub Desktop.
Python_CSV_DF_ScatterGraph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a sample Python script. | |
import pandas as pd | |
import tkinter | |
import tkinter.filedialog as FileDialog | |
import os | |
import pickle | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# 乱数を生成 | |
#x = np.random.rand(100) | |
#y = np.random.rand(100) | |
# 散布図を描画 | |
#plt.scatter(x, y) | |
#plt.show() | |
# id+PVT33+RELPOSNED 20 | |
#--------------------------------------------MBUX FILES----------------------------------------------------------------- | |
list_PVT = ["id", "iTOW", "year", "month", "day", "hour", "min", "sec", "valid", "tAcc", "nano", "fixtye", "flags", | |
"flags2", "numSV", "lon", "lat", "height", "hMSL", | |
"hAcc", "vAcc", "velN", "velE", "velD", "gSpeed", "headMot", "sAcc", "headAcc", "pDOP", "flags3", | |
"reserved1", "headVeh", "magDec", "magAcc", ""] # 33 | |
list_BasePVT = [s + '_B' for s in list_PVT] | |
list_RoverPVT = [s + '_R' for s in list_PVT] | |
list_RELP = ["version", "reserved2", "refStationId", "iTOWR", "relPosN", "relPosE", "relPosD", "relPosLength", | |
"relPosHeading", "relPosHPN", | |
"relPosHPE", "relPosHPD", "relPosHPLength", "accN", "accE", "accD", "accLength", "accHeading", | |
"reserverd4", "flagsR", "a"] | |
list_BaseRELP = [s + '_B' for s in list_RELP] | |
list_RoverRELP = [s + '_R' for s in list_RELP] | |
# print(list_BasePVT) | |
# print(list_RoverPVT) | |
#--------------------------------------------MovingBase BNO FILES----------------- | |
list_BNO=["bnitow","yaw","pitch","roll","ax","ay","az","com1","com2","com3"] | |
root = tkinter.Tk() | |
root.withdraw() | |
iDir = r'C:/RTK_Log/' | |
fTyp = [("データファイル", "*.csv;*.xlsx;*.xls"), ("すべてのファイル", "*.*")] | |
filename = FileDialog.askopenfilename(parent=root, initialdir=iDir, filetypes=fTyp) | |
# filenameからbasenameをとりだしてファイル種類区別 | |
basename = os.path.basename(filename) | |
if "ubx" in basename: | |
head0 = list_PVT + list_RELP | |
df = pd.read_csv(filename, names=head0, low_memory=True) | |
print("PATH:", filename, "READ:", basename) | |
pd.set_option('display.max_columns', 120) | |
df_Base = df[df.iloc[:, 0] == 'B'] | |
df_Base = df_Base.reset_index() | |
df_Base = df_Base.add_suffix('_B', axis=1) | |
print(df_Base) | |
df_Rover = df[df.iloc[:, 0] == 'R'] | |
df_Rover.reset_index(drop=True, inplace=True) | |
df_Rover = df_Rover.add_suffix('_R', axis=1) | |
print(df_Rover) | |
print("--------------------CONCAT---------------------") | |
result = pd.concat([df_Base, df_Rover], axis=1) | |
result.reset_index() | |
result.to_csv(r'C:/RTK_Log/BR_' + basename) | |
print(result) | |
# =================UBX XYPLOT============================== | |
#df_Base Y:relPosN_B X:relPosE_B | |
print(df_Base.dtypes) | |
df_Base['relPosN_B'] = df_Base['relPosN_B'].astype('int') | |
df_Base['relPosE_B'] = df_Base['relPosE_B'].astype('int') | |
df_Base.plot.scatter(x='relPosE_B', y='relPosN_B') | |
plt.show() | |
elif "bno" in basename: | |
head0=list_BNO | |
df_BNO = pd.read_csv(filename, names=head0, low_memory=True) | |
print("PATH:", filename, "READ:", basename) | |
pd.set_option('display.max_columns', 40) | |
df_BNO.to_csv(r'C:/RTK_Log/BNO_' + basename) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment