correct find_best_time_interval function. Create Readme

This commit is contained in:
Danila Gamkov
2025-04-25 12:33:44 +03:00
parent c2f6253575
commit 31cb99ec0c
4 changed files with 107 additions and 25 deletions

View File

@@ -16,7 +16,7 @@ def convert_to_str(lst):
res += f"_{idx + 1}"
return res
def plot_asotr_borders(path_with_data, ch, asotr_kit, begin, end, font=14, cmd=0, show_flag=False):
def plot_asotr_borders(path_with_data, ch, asotr_kit, begin, end, font=14, cmd=0, show_flag=True):
print_width = 20
print_height = 12
width = 1
@@ -74,7 +74,8 @@ def plot_asotr_borders(path_with_data, ch, asotr_kit, begin, end, font=14, cmd=0
plt.tight_layout()
fig.savefig(pict_name)
plt.show()
if show_flag == True:
plt.show()
elif plot_windows == 2:
@@ -85,22 +86,29 @@ def plot_asotr_borders(path_with_data, ch, asotr_kit, begin, end, font=14, cmd=0
if cmd == '1':
fname = './flight_cmd_human.txt'
try:
cmd_human = pd.read_csv('./flight_cmd_human.txt',
cmd_human = pd.read_csv('./data/cmd_human.csv',
delimiter=';', names=['timestamp', 'cmd'])
except Exception as e:
print(f'Error parsing file: {e}')
return
max_temp = max(data_dict['temp'].iloc[:,1])
min_temp = min(data_dict['temp'].iloc[:,1])
# print(cmd_human)
step = 0
for i, row in cmd_human.iterrows():
if i > 20:
row_time = row['timestamp'][0:len(row['timestamp']) - 4]
idx = asotr.find_best_time_idx(data_dict['time_temp'],
row_time, accuracy='minutes')
if idx != -1:
ax1.axvline(x = data_dict['time_temp'][idx], color='r',
linestyle='-.')
ax1.text(data_dict['time_temp'][idx], 30, row['cmd'],
rotation=45, va='bottom', fontsize=font)
row_time = row['timestamp'][0:len(row['timestamp']) - 4]
# print(row_time)
idx = asotr.find_best_time_idx(data_dict['time_temp'],
row_time, accuracy='minutes')
# print(idx)
if idx != -1:
ax1.axvline(x = data_dict['time_temp'][idx], color='r',
linestyle='-.')
ax1.text(data_dict['time_temp'][idx], max_temp - step, row['cmd'],
rotation=45, va='bottom', fontsize=font)
step += (max_temp - min_temp)/20
if plot_task["temp"] == 1:
for i in range(len(channels)):
@@ -176,6 +184,6 @@ if __name__ == '__main__':
argparser.add_argument('-p', '--plot', required=False,
help='display data in plot flag (0/1)')
args = argparser.parse_args()
plot_asotr_borders(args.source, args.channel, args.asotr, args.begin, args.end,
args.font, args.cmd, args.plot)