From 2e005f1df2050f2624ad5171bb996d5c347902b2 Mon Sep 17 00:00:00 2001 From: unknown <asoalexandros@gmail.com> Date: Tue, 3 Dec 2024 14:56:41 +0100 Subject: [PATCH] Sentech Evaluation completed --- sentech/evaluation.py | 51 ++++++++++++++++++++++++++++-- sentech/interface_evaluation.ipynb | 25 ++++++++++++--- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/sentech/evaluation.py b/sentech/evaluation.py index 7793229..e7bd841 100644 --- a/sentech/evaluation.py +++ b/sentech/evaluation.py @@ -2,6 +2,7 @@ import ipywidgets as widgets import matplotlib.pyplot as plt import pandas as pd import os +import numpy as np import tkinter as tk from tkinter import filedialog @@ -82,9 +83,11 @@ dir_button = widgets.Button(description = 'Choose Folder') plot_button = widgets.Button(description = 'Plot') next_file = widgets.Button(description = 'Next File') previous_file = widgets.Button(description = 'Previous file') -current_file = widgets.Text(description = 'Current File',disabled = True) +current_file = widgets.Text(description = 'Current File',disabled = True,value = 'No File Selected') x_axis = widgets.Dropdown(description = 'X-Axis',disabled = True) y_axis = widgets.Dropdown(description = 'Y-Axis') +x_scale = widgets.Dropdown(description ='X-Scale',options = ['linear','log'],value = 'linear') +y_scale = widgets.Dropdown(description ='Y-Scale',options = ['linear','log'],value = 'linear') output = widgets.Output() counter = 0 @@ -96,16 +99,19 @@ device = None buttons = widgets.HBox([dir_button,plot_button,previous_file,next_file]) config = widgets.HBox([x_axis,y_axis,current_file]) +scale = widgets.HBox([x_scale,y_scale]) display(buttons) display(config) +display(scale) display(output) -all_widgets = [dir_button,plot_button,previous_file,next_file,y_axis] +all_widgets = [dir_button,plot_button,previous_file,next_file,y_axis,x_scale,y_scale] def on_choose_folder_clicked(b): global counter,folder,files,df,start_time,device with output: change_state(all_widgets) + current_file.value = 'No File Selected' folder = choose_folder() os.chdir(folder) #change current working directory files = os.listdir(os.getcwd()) #get the files from the chosen directory @@ -172,9 +178,48 @@ def on_next_file_clicked(b): change_state(all_widgets) next_file.on_click(on_next_file_clicked) - + +def on_plot_clicked(b): + global counter,folder,files,df,start_time,device + with output: + change_state(all_widgets) + if current_file.value != 'No File Selected': #there is a file to plot + fig,ax = plt.subplots() + fig.suptitle(device +" "+ start_time) + if x_scale.value == 'log': + x = np.absolute(df[x_axis.value]) + ax.set_xscale('log') + else: + x = df[x_axis.value] + ax.set_xscale('linear') + + if y_scale.value == 'log': + y = np.absolute(df[y_axis.value]) + ax.set_yscale('log') + else: + y = df[y_axis.value] + ax.set_yscale('linear') + + ax.set_xlabel(x_axis.value) + ax.set_ylabel(y_axis.value) + + ax.plot(x,y,color = 'b') + + mng = plt.get_current_fig_manager() + mng.window.state('zoomed') + mng.window.attributes('-topmost', 1) + plt.show(block= True) + + else: + information_box("No file to plot!") + change_state(all_widgets) + +plot_button.on_click(on_plot_clicked) + + + diff --git a/sentech/interface_evaluation.ipynb b/sentech/interface_evaluation.ipynb index 0bde064..93b2800 100644 --- a/sentech/interface_evaluation.ipynb +++ b/sentech/interface_evaluation.ipynb @@ -9,7 +9,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "10b418b71d7240bb9a7b4847970f5732", + "model_id": "31e5cb6d8eff449a9135e0c48265e012", "version_major": 2, "version_minor": 0 }, @@ -23,7 +23,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "67de78df200741548f24348ae8d5e349", + "model_id": "8548005931624344acaf30e06d1c041c", "version_major": 2, "version_minor": 0 }, @@ -37,7 +37,21 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "e1dd9aefebfe4462b1cbc4b931c652d9", + "model_id": "d5fe062acf8b460da0c1a6e4464359e1", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "HBox(children=(Dropdown(description='X-Scale', options=('linear', 'log'), value='linear'), Dropdown(descriptio…" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "cf6a0450d737405da18a17adeaf888bb", "version_major": 2, "version_minor": 0 }, @@ -50,13 +64,14 @@ } ], "source": [ + "%matplotlib tk\n", "%run evaluation.py" ] }, { "cell_type": "code", "execution_count": null, - "id": "3773b35c-de0e-4515-b1a2-ed0e92d63c6e", + "id": "150e0b0a-18c8-4e4e-b3cc-41ba2c1a66ad", "metadata": {}, "outputs": [], "source": [] @@ -64,7 +79,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, -- GitLab