forked from WMJason/demo-RSI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rwis_page.py
128 lines (117 loc) · 4.19 KB
/
rwis_page.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
from datetime import datetime as dt
from datetime import date, timedelta
import os
from statistics import mean
import random
from random import randint, shuffle
import pandas as pd
import plotly.graph_objs as go
import dash
import dash_html_components as html
import dash_core_components as dcc
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
from app import app
import index_page
import utils
import callbacks
#load RWIS data
df_rwis_all = index_page.df_rwis_all
locations = [go.Scattermapbox(
lon=df_rwis_all['lon'],
lat=df_rwis_all['lat'],
mode='markers',
marker={'color': df_rwis_all['estimate_ratio'], 'size': 20, 'opacity': 0.6,
'showscale': True,
'colorbar': {'len': 0.8, 'title': '0 = no snow; 1 = full snow'},},
showlegend=True,
hoverinfo='text',
hovertext=df_rwis_all['stid'],
customdata=df_rwis_all['img_path'],
name='RWIS',
)]
mapbox_access_token = "pk.eyJ1IjoibWluZ2ppYW53dSIsImEiOiJja2V0Y2lneGQxbzM3MnBuaWltN3RrY2QyIn0.P9tqv8lRlKbVw0_Tz2rPPw"
map_layout = go.Layout(
mapbox=go.layout.Mapbox(
accesstoken=mapbox_access_token,
center=go.layout.mapbox.Center(lat=mean(df_rwis_all['lat']), lon=mean(df_rwis_all['lon'])),
style="dark",
zoom=7,
pitch=0,
),
height=740,
margin=dict(l=15, r=15, t=15, b=15),
paper_bgcolor="#303030",
font_color="white"
)
def NamedGroup(children, label, **kwargs):
return dbc.FormGroup(
[
dbc.Label(label),
children
],
**kwargs
)
def HomePage():
layout = html.Div(
[
dbc.Row(
[
dbc.Col(
md=4,
children=[
dbc.Card(
style={'height': '42vh'},
children=[
dbc.CardHeader("Real-Time RWIS Image"),
dbc.CardBody(
html.Pre(
id="rwis_img_link",
children=[],
),
)
]
),
html.Br(),
dbc.Card(
style={'height': '42vh'},
children=[
dbc.CardHeader(
"Drivable Areas Prediction"
),
dbc.CardBody(
html.Pre(
id="drivable_areas",
children=[],
),
)
]
),
],
),
html.Br(),
dbc.Col(
md=8,
children=[
dbc.Card(
children=[
dbc.CardHeader(
"Real-Time RWIS Monitoring"
),
dbc.CardBody(
dcc.Graph(
id="rwis_map",
figure=go.Figure(data=locations, layout=map_layout),
config={'displayModeBar': False, 'scrollZoom': True},
),
)
]
),
html.Br(),
],
),
]
),
],
)
return layout