From bede2322ac002e463d7b3e70972a0721ebe12357 Mon Sep 17 00:00:00 2001 From: Danila Gamkov Date: Fri, 21 Feb 2025 20:14:54 +0300 Subject: [PATCH] remove consecutive repeated values in data --- data/plot_flight_all.py | 44 ++++++++++++++++++++++++++++++----------- src/main.rs | 1 + 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/data/plot_flight_all.py b/data/plot_flight_all.py index 2176b0b..c8f9634 100644 --- a/data/plot_flight_all.py +++ b/data/plot_flight_all.py @@ -4,9 +4,9 @@ import pandas as pd from datetime import datetime import sys -font = 10 -print_width = 20 -print_height = 12 +font = 8 +print_width = 10 +print_height = 8 width = 1 plot_windows = 2 channels = [1, 1, 1, 1, 1, 1] @@ -15,22 +15,37 @@ xborders=False begin=0; end=0; +path_B = '/home/danila/Danila/work/MVN/flight/beta_forecast/' +fname_B = 'beta_2025.xlsx' 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' +fname = 'asotr02_data_T.csv' +fname_pow = 'asotr02_data_P.csv' +pict_name = path + "ASOTR2_flight_T_P_all" +ox_dtime_format = '%d %H:%M' -legend=['ch1', 'ch2', 'ch3', 'ch4', 'ch5', 'ch6', 'ch7'] +legend=['БРД1', 'БРД2', 'БРД3', 'БРД4', 'плита МУП МВН, датчик1', 'плита МУП МВН, датчик 2'] width=[1, 1, 1, 1, 1, 1] -marker = ['-', '-', '-', '-', '-', '-']; +marker = ['-', '-', '-', '-', '--', '-']; width_arr = [1, 0.5, 0.2, 0.1, 1, 1] fname = [path + fname, path + fname_pow] +fname_b = path_B + fname_B + dateparse = lambda x: datetime.strptime(x, "%d.%m.%Y %H:%M:%S.%f") +dparse_b = lambda x: datetime.strptime(x, '%Y-%m-%d %H:%M:%S') + +data_b = pd.read_excel(fname_b, + sheet_name=0, + usecols=[0,1,2], + header=4, + names=['turn_num', 'beta_angle', 'timestamp'], + parse_dates=['timestamp'], + date_parser=dparse_b) + + 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)] @@ -60,7 +75,7 @@ if plot_windows == 1: 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]) + ax.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") @@ -90,6 +105,11 @@ elif plot_windows == 2: ax1.plot(data_dict['time'][begin:end], elem[begin:end], marker[i], linewidth=width[i], label=legend[i]) i += 1 + ax3 = ax1.twinx() + ax3.plot(data_b['timestamp'], data_b['beta_angle'], marker[4], linewidth=width[5], label='угол Бета') + ax3.set_ylabel('Угол Бета', fontsize=font) + ax3.legend(fontsize=font, loc='upper right') + i = 0 for elem in data_dict['pow']: if channels[i] == 1: @@ -102,7 +122,7 @@ elif plot_windows == 2: ax1.grid(visible=True, linestyle = 'dotted') ax1.set_ylabel('Температура, $^\circ$C', fontsize=font) ax1.set_xlabel('Время', fontsize=font) - ax1.legend(fontsize=font) + ax1.legend(fontsize=font, loc='lower right') date_formatter = dates.DateFormatter('%d.%m.%Y %H') ax1.xaxis.set_major_formatter(date_formatter) @@ -111,7 +131,7 @@ elif plot_windows == 2: ax2.grid(visible=True, linestyle = 'dotted') ax2.set_ylabel('Мощность, %', fontsize=font) ax2.set_xlabel('Время', fontsize=font) - ax2.legend(fontsize=font) + ax2.legend(fontsize=font, loc='lower right') date_formatter = dates.DateFormatter(ox_dtime_format) ax2.xaxis.set_major_formatter(date_formatter) diff --git a/src/main.rs b/src/main.rs index b374cbe..d3ef644 100644 --- a/src/main.rs +++ b/src/main.rs @@ -125,6 +125,7 @@ pub mod asotr_data { } data.sort(); + data.dedup(); if disp { disp_data(&data, &patterns_disp[i])?; }