-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotter.py
More file actions
59 lines (52 loc) · 1.75 KB
/
plotter.py
File metadata and controls
59 lines (52 loc) · 1.75 KB
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
53
54
55
56
57
58
59
import numpy as np
import pandas as pd
from scipy.stats import norm
from dash import Dash, html, dash_table, dcc, callback, Output, Input
import plotly.express as px
import plotly.graph_objs as go
from loader import hist_data
plotter_attributes = [
"RS_E_InAirTemp_PC1",
"RS_E_InAirTemp_PC2",
"RS_E_WatTemp_PC1",
"RS_E_WatTemp_PC2",
"RS_T_OilTemp_PC1",
"RS_T_OilTemp_PC2",
"RS_E_OilPress_PC1",
"RS_E_OilPress_PC2",
"RS_E_RPM_PC1",
"RS_E_RPM_PC2",
]
plotter_data = {attribute: hist_data[attribute] for attribute in plotter_attributes}
plotterTab = dcc.Tab(label='Plotter', children=[
dcc.Dropdown(
id='plotter-x-dropdown',
options=plotter_attributes,
value=plotter_attributes[0]
),
dcc.Dropdown(
id='plotter-y-dropdown',
options=plotter_attributes,
value=plotter_attributes[1]
),
dcc.Dropdown(
id='plotter_anomaly',
options=[
{'label': 'Train engine anomaly', 'value': 'failed_engine'},
{'label': 'Water/Oil cooling anomaly', 'value': 'wo'},
{'label': 'No anomaly', 'value': 'nothing'}
],
value='nothing'
),
dcc.Graph(figure={}, id='plotter-graph'),
])
@callback(
Output(component_id='plotter-graph', component_property='figure'),
Input(component_id='plotter-x-dropdown', component_property='value'),
Input(component_id='plotter-y-dropdown', component_property='value'),
Input(component_id='plotter_anomaly', component_property='value'),
)
def update_graph(x_value, y_value, anomalie):
dff = hist_data[hist_data['Anomalie_type'] == anomalie]
df = pd.DataFrame({x_value: dff[x_value], y_value: dff[y_value]})
return px.scatter(df, x=x_value, y=y_value, title='Scatter Plot')