add feature
This commit is contained in:
parent
6df0ea83bb
commit
f33ea984f0
17
color.py
17
color.py
@ -77,6 +77,23 @@ def get_color_from_value(
|
|||||||
return tuple(current_color)
|
return tuple(current_color)
|
||||||
|
|
||||||
|
|
||||||
|
def get_color_from_value(value: float, color_mapping: Dict[int, Tuple[int, int, int, int]]) -> Tuple[int, int, int, int]:
|
||||||
|
"""
|
||||||
|
根据输入的值,从颜色映射字典中查找对应的颜色
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
value: 输入值
|
||||||
|
color_mapping: 颜色映射字典
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple[int, int, int, int]: RGBA颜色元组
|
||||||
|
"""
|
||||||
|
# 找到小于等于输入值的最大分界值
|
||||||
|
max_key = max([k for k in color_mapping if k <= value])
|
||||||
|
|
||||||
|
return color_mapping[max_key]
|
||||||
|
|
||||||
|
|
||||||
# 使用示例:
|
# 使用示例:
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# 生成原始序列
|
# 生成原始序列
|
||||||
|
42
read_dat.py
42
read_dat.py
@ -22,23 +22,33 @@ def read_binary_file(file_path):
|
|||||||
date = struct.unpack("<d", date_bytes)[0]
|
date = struct.unpack("<d", date_bytes)[0]
|
||||||
print(f"Date: {date}")
|
print(f"Date: {date}")
|
||||||
|
|
||||||
while True:
|
# 第一个时间戳所有数据
|
||||||
# print("index", index)
|
|
||||||
if index > 335:
|
|
||||||
break
|
|
||||||
time_bytes = file.read(8)
|
|
||||||
time = struct.unpack("<d", time_bytes)[0]
|
|
||||||
# print(f"time: {time}")
|
|
||||||
|
|
||||||
# 读取数据矩阵
|
time_bytes = file.read(8)
|
||||||
data_size = column_count_int * 8 # 每个数据点8个字节
|
time = struct.unpack("<d", time_bytes)[0]
|
||||||
data_bytes = file.read(data_size)
|
print(f"Time: {time}")
|
||||||
data_matrix = struct.unpack(f"<{column_count_int}d", data_bytes)
|
for i in range(column_count_int):
|
||||||
data_matrix = [data_matrix]
|
print(i)
|
||||||
new_df = pd.DataFrame(data_matrix)
|
data_bytes = file.read(8)
|
||||||
df = pd.concat([df, new_df], ignore_index=True)
|
data = struct.unpack("<d", data_bytes)[0]
|
||||||
# print(f"Data Matrix: {data_matrix}")
|
print(f"Data: {data}")
|
||||||
index = index + 1
|
# while True:
|
||||||
|
# # print("index", index)
|
||||||
|
# if index > 335:
|
||||||
|
# break
|
||||||
|
# time_bytes = file.read(8)
|
||||||
|
# time = struct.unpack("<d", time_bytes)[0]
|
||||||
|
# # print(f"time: {time}")
|
||||||
|
|
||||||
|
# # 读取数据矩阵
|
||||||
|
# data_size = column_count_int * 8 # 每个数据点8个字节
|
||||||
|
# data_bytes = file.read(data_size)
|
||||||
|
# data_matrix = struct.unpack(f"<{column_count_int}d", data_bytes)
|
||||||
|
# data_matrix = [data_matrix]
|
||||||
|
# new_df = pd.DataFrame(data_matrix)
|
||||||
|
# df = pd.concat([df, new_df], ignore_index=True)
|
||||||
|
# # print(f"Data Matrix: {data_matrix}")
|
||||||
|
# index = index + 1
|
||||||
|
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user