1. Add CLI parser, 2. add python script for visualisation data

This commit is contained in:
Danila Gamkov
2025-01-29 18:04:02 +03:00
parent 2abb435f87
commit b94b2c623f
8 changed files with 453 additions and 68466 deletions

BIN
data/mvn_accomp_csv Executable file

Binary file not shown.

114
data/plot_flight_all.py Normal file
View File

@@ -0,0 +1,114 @@
import matplotlib.pyplot as plt
from matplotlib import dates
import pandas as pd
from datetime import datetime
import sys
font = 10
print_width = 20
print_height = 12
width = 1
plot_windows = 1
channels = [1, 1, 1, 1]
path = '/home/danila/Danila/work/MVN/Soft/mvn_accomp_csv/data/'
fname = [path + 'MVN_data_T1MVN.csv',
path + 'MVN_data_T2MVN.csv',
path + 'MVN_data_T3MVN.csv',
path + 'MVN_data_T4MVN.csv']
pict_name = path + "T1_4MVN"
ox_dtime_format = '%d.%m.%Y %H:%M'
legend=['T1МВН', 'T2МВН', 'T3МВН', 'T4МВН']
ch_names=['T1MVN', 'T2MVN', 'T3MVN', 'T4MVN']
width=[1, 1, 1, 1]
marker = ['-', '-', '-', '-'];
width_arr = [1, 0.5, 0.2, 0.1]
dateparse = lambda x: datetime.strptime(x, "%d.%m.%Y %H:%M:%S.%f")
data = [pd.read_csv(fname[0], sep=';', parse_dates=['timestamp'], date_parser=dateparse),
pd.read_csv(fname[1], sep=';', parse_dates=['timestamp'], date_parser=dateparse),
pd.read_csv(fname[2], sep=';', parse_dates=['timestamp'], date_parser=dateparse),
pd.read_csv(fname[3], sep=';', parse_dates=['timestamp'], date_parser=dateparse)]
# data_dict = {"temp": ch, "pow": ch, "time": []}
# data_dict["time"] = data[0]['timestamp']
# col=['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7']
# for j in range(2):
# for index, row, in data[j].iterrows():
# for i in range(6):
# ch[i].append(float(row[col[i]]))
# data_dict[ch_signs[j]] = ch
# ch= [[], [], [], [], [], []]
if plot_windows == 1:
fig, ax = plt.subplots(figsize=(print_width, print_height), dpi=200)
i = 0
for elem in data:
if channels[i] == 1:
plt.plot(elem['timestamp'], elem[ch_names[i]], marker[i], linewidth=width[i], label=legend[i])
i += 1
# ax.axvline(x = data['timestamp'][300], color='r', linestyle='-.', label="power=100")
# ax.axvline(x = data['timestamp'][1500], color='b', linestyle='dotted', label="power=0")
ax.tick_params(axis="both", width=1, labelsize=font)
ax.grid(visible=True, linestyle = 'dotted')
ax.set_ylabel('Температура, $^\circ$C', fontsize=font)
ax.set_xlabel('Время', fontsize=font)
ax.legend(fontsize=font)
date_formatter = dates.DateFormatter(ox_dtime_format)
ax.xaxis.set_major_formatter(date_formatter)
plt.tight_layout()
fig.savefig(pict_name)
plt.show()
sys.exit()
# elif plot_windows == 2:
# fig = plt.figure(figsize=(print_width, print_height), dpi=200)
# ax1 = fig.add_subplot(2, 1, 1)
# ax2 = fig.add_subplot(2, 1, 2, sharex=ax1)
# i = 0
# for elem in data_dict['temp']:
# if channels[i] == 1:
# ax1.plot(data_dict['time'][begin:end], elem[begin:end], marker[i], linewidth=width[i], label=legend[i])
# i += 1
# i = 0
# for elem in data_dict['pow']:
# if channels[i] == 1:
# ax2.plot(data_dict['time'][begin:end], elem[begin:end], marker[i], linewidth=width[i], label=legend[i])
# i += 1
# # ax1.axvline(x = data['timestamp'][300], color='r', linestyle='-.', label="power=100")
# # ax.axvline(x = data['timestamp'][1500], color='b', linestyle='dotted', label="power=0")
# ax1.tick_params(axis="both", width=1, labelsize=font)
# ax1.grid(visible=True, linestyle = 'dotted')
# ax1.set_ylabel('Температура, $^\circ$C', fontsize=font)
# ax1.set_xlabel('Время', fontsize=font)
# ax1.legend(fontsize=font)
# date_formatter = dates.DateFormatter('%d.%m.%Y %H')
# ax1.xaxis.set_major_formatter(date_formatter)
# ax2.tick_params(axis="both", width=1, labelsize=font)
# ax2.grid(visible=True, linestyle = 'dotted')
# ax2.set_ylabel('Мощность, %', fontsize=font)
# ax2.set_xlabel('Время', fontsize=font)
# ax2.legend(fontsize=font)
# date_formatter = dates.DateFormatter(ox_dtime_format)
# ax2.xaxis.set_major_formatter(date_formatter)
# plt.tight_layout()
# fig.savefig(pict_name)
# plt.show()