-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
197 lines (164 loc) · 6.04 KB
/
app.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
from dash.dependencies import Input, Output
from dash import html, dcc
import dash_bootstrap_components as dbc
import predictions
import range_based
import date_based
import upload_train
from init import app, server
import mysql_connect as mc
server = server
# Color
colors = {
'background': '#111111',
'text': '#7FDBFF'
}
df = mc.df
# ---------------------- Callback start --------------------
@app.callback(
Output('page-content', 'children'),
[Input('url', 'pathname')])
def update_content(pathname):
if pathname == "/factors":
return range_based.layout
elif pathname == '/factors_date':
return date_based.layout
elif pathname == '/predictions':
return predictions.layout
elif pathname == '/':
return index_page
elif pathname == '/retrain':
return upload_train.layout
@app.callback(
Output('navbar', 'children'),
[Input('url', 'pathname')])
def update_content(pathname):
if pathname == '/factors':
return navbar
elif pathname == '/factors_date':
return navbar
elif pathname == '/predictions':
return navbar
elif pathname == '/retrain':
return navbar
elif pathname == '/':
return navbar
# ------------------- Callback end -----------------------
app.layout = html.Div(children=[
html.Div(id='navbar'),
dcc.Location(id='url', refresh=False),
html.Div(id='page-content')
])
# Left card
left_card = html.Div([
html.H3("Problem Statement", className="card-title"),
html.P(
"Wind energy plays an increasing role in the supply of energy world-wide."
"The energy output of a wind farm is highly dependent on the wind conditions present at its site."
"If the output can be predicted more accurately, energy suppliers can coordinate the collaborative "
"production of different energy sources more efficiently to avoid costly overproduction."),
html.P(
"Wind power or wind energy is the use of wind to provide the mechanical power through wind turbines"
"to turn electric generators and traditionally to do other work, like milling or pumping. Wind power "
"is a sustainable and renewable energy, and has a much smaller impact on the environment compared to burning "
"fossil fuels. Wind farms consist of many individual wind turbines, which are connected to the electric power "
"transmission network. Onshore wind is an inexpensive source of electric power, competitive with or in many places "
"cheaper than coal or gas plants. Onshore wind farms also have an impact on the landscape, as "
"typically they need to be spread over more land than other power stations and need to be built in wild "
"and rural areas, which can lead to industrialization of the countryside and habitat loss. Offshore "
"wind is steadier and stronger than on land and offshore farms have less visual impact, but construction "
"and maintenance costs are higher. Small onshore wind farms can feed some energy into the grid or provide "
"electric power to isolated off-grid locations."),
dbc.Button("Read More", color="primary", href="")
])
# Right card
right_card = html.Div(
[
html.H3("Alerts", className="card-title"),
html.P("Wind Speed: {} m/s".format(round(df.iloc[5, 2], 3))),
html.P("Wind Driection: {}°".format(round(df.iloc[5, 4], 3))),
html.P("Power Output: {} kw".format(round(df.iloc[5, 1], 3))),
html.H5("Status: "),
dbc.Button("Active", color="success"),
html.Br(),
html.Br(),
dbc.Button("Deatil Predictions", color="warning", href="/predictions")
]
)
# info
info = dbc.Row([
dbc.Col(left_card, width=8),
dbc.Col(width=1),
dbc.Col(right_card, width=3)
])
# --------------------- Navbar ------------------------
navbar = dbc.NavbarSimple(
children=[
dbc.NavItem(dbc.NavLink("Home", active=True, href="/")),
dbc.NavItem(dbc.NavLink("Predictions", href="/predictions")),
dbc.NavItem(dbc.NavLink("Visualizations", href="/factors")),
dbc.NavItem(dbc.NavLink("Retrain", href="/retrain")),
],
brand="PEOWT",
brand_href="/",
color='dark',
dark=True
)
# --------------------- Index page ---------------------
index_page = html.Div(
style={'position': 'absolute', 'height': '100%'},
children=[
# background image
html.Img(
src="./assets/main.jpeg",
style={'width': '100%', 'opacity': '0.6', 'object-fit': 'cover'},
),
# logo
html.H1(
children="PEOWT",
style={
'color': colors['background'],
'textAlign':'center', 'position':'absolute',
'top':'35%',
'left':'50%',
'transform':'translate(-50%, -50%)',
'fontSize': '4vw',
'textDecoration':'underline',
}
),
# description
html.H1(
children='Predicting the energy output of wind turbine based on weather condition',
style={
'color': 'black',
'textAlign': 'center',
'position': 'absolute',
'top': '50%',
'left': '50%',
'transform': 'translate(-50%, -50%)',
'fontSize': '2vw',
}
),
html.P(
dbc.Button("Learn more", color="primary", href="#", className="lead",
style={
'color': 'black',
'textAlign': 'center',
'position': 'absolute',
'top': '60%',
'left': '50%',
'transform': 'translate(-50%, -50%)'
})
),
html.Br(),
html.Br(),
html.Br(),
html.Div(className="container", children=[
info,
html.Br(),
html.Br(),
])
]
)
if __name__ == "__main__":
app.run_server(debug=True)