MoxTools 0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of MoxTools might be problematic. Click here for more details.
- MoxTools-0.1.dist-info/METADATA +6 -0
- MoxTools-0.1.dist-info/RECORD +14 -0
- MoxTools-0.1.dist-info/WHEEL +5 -0
- MoxTools-0.1.dist-info/top_level.txt +1 -0
- MxTools/__init__.py +16 -0
- MxTools/asmt_tool.py +114 -0
- MxTools/chart.py +560 -0
- MxTools/dataIO.py +152 -0
- MxTools/dataProc.py +92 -0
- MxTools/fileMg.py +119 -0
- MxTools/lsf.py +183 -0
- MxTools/radarIO.py +395 -0
- MxTools/radarSP.py +702 -0
- MxTools/testImage.py +59 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
MxTools/__init__.py,sha256=f4ADORxVpJToE8Q3va8yj-pacLQ08wPM-gnVTHphe9M,423
|
|
2
|
+
MxTools/asmt_tool.py,sha256=wjyEtYOqvjFuFGK5M0m4qAYreKzWwDx5acD97S1p_vk,4770
|
|
3
|
+
MxTools/chart.py,sha256=vwFn3G04S4wCQ_V_HdvZDnP8Nf4ahdLSpQu7ieJIu8k,21168
|
|
4
|
+
MxTools/dataIO.py,sha256=3cEWTI3yVD2WKL5NSj0RkRaS4hfSo2ADU1gxxQEv0pk,4657
|
|
5
|
+
MxTools/dataProc.py,sha256=mHmWZbmxYUGz9tLuaItN6qt-S79YT9_blL9VZkwW31g,2810
|
|
6
|
+
MxTools/fileMg.py,sha256=r4h7jxi3o8lpKEgFIU2j_og1F1-_c88tpM4uHUMdO7I,3846
|
|
7
|
+
MxTools/lsf.py,sha256=g47fOz5_hbyL14KGUUZ6iH7nAJn4WNFbj_c6hS8G6Ys,5490
|
|
8
|
+
MxTools/radarIO.py,sha256=vFOhJGJ8pI3eiKpJm0RERq5jwofgsRNDqYLVjwHfufQ,14131
|
|
9
|
+
MxTools/radarSP.py,sha256=NS4OJjd4ta5VSeulkEH_Jbwok90sBVv7nJJsbKem1R4,27999
|
|
10
|
+
MxTools/testImage.py,sha256=nK1WEsAv7-et1p3HKTt2LtYT_B69lI7jGBU8ltSxNKQ,1734
|
|
11
|
+
MoxTools-0.1.dist-info/METADATA,sha256=1aj8R2Ov7pa1pxHqbe1dqYVL5BqniALcYdwdRl4Kl-g,165
|
|
12
|
+
MoxTools-0.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
13
|
+
MoxTools-0.1.dist-info/top_level.txt,sha256=KUyq-tK2RhD20_8ZPc9frOulBxNIVsJ-hPC9UxKeUZQ,8
|
|
14
|
+
MoxTools-0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MxTools
|
MxTools/__init__.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MxTools - A Python toolkit with multiple utilities.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# 讓 main.py 直接 `from MxTools import dataProc`,確保正確載入模組
|
|
6
|
+
from . import dataProc
|
|
7
|
+
from . import radarIO
|
|
8
|
+
from . import fileMg
|
|
9
|
+
from . import chart
|
|
10
|
+
from . import asmt_tool
|
|
11
|
+
|
|
12
|
+
# 讓 `import *` 只載入這些模組
|
|
13
|
+
__all__ = ["dataProc", "radarIO", "fileMg", "chart", "asmt_tool"]
|
|
14
|
+
|
|
15
|
+
# 定義版本號(可選)
|
|
16
|
+
__version__ = "0.1"
|
MxTools/asmt_tool.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# import math
|
|
2
|
+
import re
|
|
3
|
+
import numpy as np
|
|
4
|
+
import logging
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def parse_mcu2DLog(path, parse_asmt=True):
|
|
9
|
+
"""
|
|
10
|
+
Parses MCU log file and returns two structured pandas DataFrames with integer values.
|
|
11
|
+
One for "counter" logs and another for "counter_asmt" logs.
|
|
12
|
+
|
|
13
|
+
example:
|
|
14
|
+
counter:119 raw:1(629,12319,12399,144) clst:1(1749,12267,12402)
|
|
15
|
+
counter_asmt:119 raw:1(823,12370,12399,148) clst:1(1387,12340,12431)
|
|
16
|
+
(x,z,r,pow)(x,z,r)
|
|
17
|
+
|
|
18
|
+
Parameters:
|
|
19
|
+
path (str): Path to the log file.
|
|
20
|
+
parse_asmt (bool): If True, also parse "counter_asmt" logs.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
tuple(pd.DataFrame, pd.DataFrame): (DataFrame for "counter", DataFrame for "counter_asmt").
|
|
24
|
+
"""
|
|
25
|
+
parsed_data = []
|
|
26
|
+
parsed_data_asmt = []
|
|
27
|
+
MAX_RAW = 16 # 限制 num_raw 最大為 16
|
|
28
|
+
MAX_CLST = 10
|
|
29
|
+
|
|
30
|
+
# 定義正則表達式
|
|
31
|
+
counter_pattern = re.compile(r"(counter|counter_asmt):(\d+)")
|
|
32
|
+
raw_pattern = re.compile(r"raw:(\d+)((?:\([-?\d]+,[-?\d]+,[\d]+,[\d]+\))+)") # (x,z,r,pow_r)
|
|
33
|
+
clst_pattern = re.compile(r"clst:(\d+)((?:\([-?\d]+,[-?\d]+,[\d]+\))+)?") # (x,z,r)
|
|
34
|
+
|
|
35
|
+
try:
|
|
36
|
+
with open(path, "r") as f:
|
|
37
|
+
timestamp = 0
|
|
38
|
+
|
|
39
|
+
for line in f.readlines(): # 讀取每一行
|
|
40
|
+
s = line.strip() # 去除換行和空格
|
|
41
|
+
counter_match = counter_pattern.search(s)
|
|
42
|
+
if not counter_match:
|
|
43
|
+
continue
|
|
44
|
+
|
|
45
|
+
counter_type = counter_match.group(1) # `counter` 或 `counter_asmt`
|
|
46
|
+
counter = int(counter_match.group(2)) # 數值
|
|
47
|
+
raw_match = raw_pattern.search(s) # 解析 raw 數據
|
|
48
|
+
clst_match = clst_pattern.search(s) # 解析 clst 數據
|
|
49
|
+
|
|
50
|
+
# 初始化變數
|
|
51
|
+
num_raw = 0
|
|
52
|
+
raw_data = []
|
|
53
|
+
num_clst = 0
|
|
54
|
+
clst_data = []
|
|
55
|
+
|
|
56
|
+
# 只有 `counter` 時更新 timestamp
|
|
57
|
+
if counter_type == "counter":
|
|
58
|
+
timestamp += 30
|
|
59
|
+
|
|
60
|
+
# 提取 raw 數據
|
|
61
|
+
if raw_match:
|
|
62
|
+
num_raw = min(int(raw_match.group(1)), MAX_RAW) # 限制最大為 16
|
|
63
|
+
raw_values = re.findall(r"\((-?\d+),(-?\d+),(\d+),(\d+)\)", raw_match.group(2))
|
|
64
|
+
raw_data = [list(map(int, vals)) for vals in raw_values[:MAX_RAW]] # 最多只取 16 組數據
|
|
65
|
+
|
|
66
|
+
# 提取 clst 數據
|
|
67
|
+
if clst_match:
|
|
68
|
+
num_clst = min(int(clst_match.group(1)), MAX_CLST) # 限制最大為 10
|
|
69
|
+
if clst_match.group(2): # 檢查是否有 clst 數據
|
|
70
|
+
clst_values = re.findall(r"\((-?\d+),(-?\d+),(\d+)\)", clst_match.group(2))
|
|
71
|
+
clst_data = [list(map(int, vals)) for vals in clst_values] # 轉換為整數
|
|
72
|
+
|
|
73
|
+
# 建立數據字典
|
|
74
|
+
row_data = {
|
|
75
|
+
"timestamp": timestamp,
|
|
76
|
+
"counter": counter,
|
|
77
|
+
"num_raw": num_raw,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# 解析 raw 數據並存入對應欄位 (最多 16 組)
|
|
81
|
+
for i in range(MAX_RAW):
|
|
82
|
+
row_data[f"raw_x{i}"] = raw_data[i][0] if i < len(raw_data) else 0
|
|
83
|
+
row_data[f"raw_y{i}"] = 0
|
|
84
|
+
row_data[f"raw_z{i}"] = raw_data[i][1] if i < len(raw_data) else 0
|
|
85
|
+
row_data[f"raw_r{i}"] = raw_data[i][2] if i < len(raw_data) else 0
|
|
86
|
+
row_data[f"raw_pow_r{i}"] = raw_data[i][3] if i < len(raw_data) else 0
|
|
87
|
+
row_data[f"raw_pow_a{i}"] = 0
|
|
88
|
+
|
|
89
|
+
# 存入 num_clst
|
|
90
|
+
row_data["num_clst"] = num_clst
|
|
91
|
+
|
|
92
|
+
# 解析 clst 數據並存入對應欄位
|
|
93
|
+
for i in range(MAX_CLST):
|
|
94
|
+
row_data[f"clst_x{i}"] = clst_data[i][0] if i < len(clst_data) else 0
|
|
95
|
+
row_data[f"clst_y{i}"] = 0
|
|
96
|
+
row_data[f"clst_z{i}"] = clst_data[i][1] if i < len(clst_data) else 0
|
|
97
|
+
row_data[f"clst_r{i}"] = clst_data[i][2] if i < len(clst_data) else 0
|
|
98
|
+
|
|
99
|
+
# 根據 `counter_type` 存入對應 DataFrame
|
|
100
|
+
if counter_type == "counter":
|
|
101
|
+
parsed_data.append(row_data)
|
|
102
|
+
elif counter_type == "counter_asmt" and parse_asmt:
|
|
103
|
+
parsed_data_asmt.append(row_data)
|
|
104
|
+
|
|
105
|
+
except FileNotFoundError as error:
|
|
106
|
+
print(error)
|
|
107
|
+
exit()
|
|
108
|
+
|
|
109
|
+
# 轉換為 DataFrame
|
|
110
|
+
df = pd.DataFrame(parsed_data)
|
|
111
|
+
df_asmt = pd.DataFrame(parsed_data_asmt) if parse_asmt else pd.DataFrame()
|
|
112
|
+
|
|
113
|
+
return df, df_asmt
|
|
114
|
+
|