123 lines
3.8 KiB
Python
123 lines
3.8 KiB
Python
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 = 2
|
|
channels = [1, 1, 1, 1, 1, 1]
|
|
|
|
xborders=False
|
|
begin=0;
|
|
end=0;
|
|
|
|
path = '/home/danila/Danila/work/MVN/Soft/asotr_csv/data/'
|
|
fname = 'asotr01_data_T.csv'
|
|
fname_pow = 'asotr01_data_P.csv'
|
|
pict_name = path + "ASOTR1_flight_T_P_all"
|
|
ox_dtime_format = '%d.%m.%Y %H:%M'
|
|
|
|
legend=['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7']
|
|
width=[1, 1, 1, 1, 1, 1]
|
|
|
|
marker = ['-', '-', '-', '-', '-', '-'];
|
|
width_arr = [1, 0.5, 0.2, 0.1, 1, 1]
|
|
|
|
fname = [path + fname, path + fname_pow]
|
|
|
|
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)]
|
|
|
|
ch= [[], [], [], [], [], []]
|
|
ch_signs = ["temp", "pow"]
|
|
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= [[], [], [], [], [], []]
|
|
|
|
len_data = [len(data_dict['temp'][0]), len(data_dict['pow'][0])]
|
|
len_ = min(len_data)
|
|
|
|
if xborders == False:
|
|
begin = 0
|
|
end = len_ - 1
|
|
|
|
if plot_windows == 1:
|
|
fig, ax = plt.subplots(figsize=(print_width, print_height), dpi=200)
|
|
|
|
i = 0
|
|
for elem in data_dict['temp']:
|
|
if channels[i] == 1:
|
|
plt.plot(data_dict['time'][begin:end], elem[begin:end], 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()
|
|
|
|
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()
|
|
|