forked from priyadivya24/Visualization_Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatplot.py
52 lines (41 loc) · 1.85 KB
/
matplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import pandas as pd
import matplotlib.pyplot as plt
from ipywidgets import interact, Dropdown
# read parquet files
def read_parquet_files(folder_path):
df_list = []
for root, dirs, files in os.walk(folder_path):
for file in files:
if file.endswith('.parquet'):
file_path = os.path.join(root, file)
df = pd.read_parquet(str(file_path))
df_list.append(df)
return pd.concat(df_list)
# create dashboard
def create_dashboard(main1_folder_path):
# update plot based on dropdown selection
def update_plot(selected_xtin_folder, selected_xhexp_folder):
xtin_folder_data = read_parquet_files(
os.path.join(main1_folder_path, 'LASER.LOCK.XLO', 'XTIN.MLO1', selected_xtin_folder))
xhexp_folder_data = read_parquet_files(
os.path.join(main1_folder_path, 'LASER.LOCK.XLO', 'XHEXP1.SLO1', selected_xhexp_folder))
plt.plot(xtin_folder_data['timestamp'], xtin_folder_data['data'], label='XTIN.MLO1')
plt.plot(xhexp_folder_data['timestamp'], xhexp_folder_data['data'], label='XHEXP1.SLO1')
plt.xlabel('Time')
plt.ylabel('Data')
plt.legend()
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
# dropdown
xtins_folder_path = os.path.join(main_folder_path, 'LASER.LOCK.XLO', 'XTIN.MLO1')
xhexps_folder_path = os.path.join(main_folder_path, 'LASER.LOCK.XLO', 'XHEXP1.SLO1')
subfolders_xtin = os.listdir(xtins_folder_path)
subfolders_xhexp = os.listdir(xhexps_folder_path)
interact(update_plot, selected_xtin_folder=Dropdown(options=subfolders_xtin),
selected_xhexp_folder=Dropdown(options=subfolders_xhexp))
# main folder path
main_folder_path = 'XFEL.SYNC'
# Create dashboard
create_dashboard(main_folder_path)