forked from COVIDAnalytics/website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
homepage.py
187 lines (162 loc) · 6.44 KB
/
homepage.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
### Data
import datetime
import pandas as pd
### Graphing
import plotly.graph_objects as go
import dash
import dash_table
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from navbar import Navbar
from footer import Footer
from projections.visuals_funcs import build_continent_map
from projections.utils import get_world_map_text
def Homepage():
nav = Navbar()
footer = Footer()
def build_tom_us_map():
tomorrow = datetime.date.today() + datetime.timedelta(days=1)
df_projections = pd.read_csv('data/predicted/Global.csv', sep=",", parse_dates = ['Day'])
df_projections.loc[:,'Day'] = pd.to_datetime(df_projections['Day'], format='y%m%d').dt.date
df_projections = df_projections.loc[df_projections['Day']==tomorrow]
pop_info = pd.read_csv('data/predicted/WorldPopulationInformation.csv', sep=",")
return build_continent_map(df_projections,pop_info,tomorrow)
def build_card(imgTop,titles,text,img,links):
cardbody = []
for i,t in enumerate(titles):
cardbody.append(html.A(t,href=links[i],className="card-title"))
cardbody.append(dcc.Markdown(text[i]))
if imgTop:
card_content = \
[
dbc.CardImg(src=img, top=False),
dbc.CardBody(
cardbody,
className="home-card-body"
),
]
else:
card_content = \
[
dbc.CardBody(
cardbody,
className="home-card-body"
),
dbc.CardImg(src=img, top=True),
]
card = dbc.Card(
card_content,
className="home-card h-100"
)
return dbc.Col(
[card],
style={"margin": "0.5rem"},
)
data_text = '''
130+ international Covid-19 clinical studies,
aggregated into a single dataset.
'''
insights_text = '''
Key characteristics of COVID-19 patients in an
interactive summary. '''
projections_text = '''
Epidemiological predictions of COVID-19 \
infections, hospital stays, and mortalities.
'''
policy_text = '''
Predicting infections and deaths based on various policy \
implementations'''
ventilator_text = '''
Leveraging delays between state peaks to \
optimally re-use ventilators.
'''
mortality_calculator_text = '''
Personalized calculator predicting mortality upon hospitalization.
'''
infection_calculator_text = '''
Personalized calculator predicting results of COVID test.
'''
financial_text = '''
Unemployment is rising. How analytics can help inform COVID-19 related financial decisions.
'''
cards = \
[
{
"titles": ["Data","Insights"],
"text": [data_text,insights_text],
"image": "assets/images/insights-4.png",
"links": ["/dataset","/interactive-graph"]
},
{
"titles": ["Infection risk calculator","Mortality risk calculator"],
"text": [infection_calculator_text,mortality_calculator_text],
"image": "assets/images/infection_logo.jpg",
"links": ["/infection_calculator","/mortality_calculator"]
},
{
"titles": ["Case predictions","Policy evaluations"],
"text": [projections_text,policy_text],
"image": "assets/images/forecast-1.png",
"links": ["/projections","/policies"]
},
{
"titles": ["Ventilator allocation"],
"text": [ventilator_text],
"image": "assets/images/allocation.png",
"links": ["/ventilator_allocation"]
},
{
"titles": ["Financial relief planning"],
"text": [financial_text],
"image": "assets/images/financial_logo.jpeg",
"links": ["/financial_relief","/interactive-graph"]
}
]
body = dbc.Container(
[
dbc.Row(
dbc.Col(
dcc.Markdown(
'''
We are a group of researchers from the [MIT](http://mit.edu/) [Operations Research Center](https://orc.mit.edu/), \
led by Professor [Dimitris Bertsimas](https://www.mit.edu/~dbertsim/). \
We aim to quickly develop and deliver tools for hospitals and policymakers in the US to combat the spread of COVID-19. \
This work represents a collaborative effort with [multiple hospitals](/collaborators) which have been providing us with \
data and support throughout the model creation process.
'''
),
),
),
dbc.Row(
[
build_card(False,cards[0]["titles"],cards[0]["text"],cards[0]["image"],cards[0]["links"]),
build_card(True,cards[1]["titles"],cards[1]["text"],cards[1]["image"],cards[1]["links"]),
build_card(False,cards[2]["titles"],cards[2]["text"],cards[2]["image"],cards[2]["links"]),
build_card(True,cards[3]["titles"],cards[3]["text"],cards[3]["image"],cards[3]["links"]),
build_card(False,cards[4]["titles"],cards[4]["text"],cards[4]["image"],cards[4]["links"]),
],
justify="around",
no_gutters=True,
),
dbc.Row(
[
dbc.Col(
[
html.Div(
id = 'us_map_homepage',
children = build_tom_us_map(),
),
html.P(
children = get_world_map_text(),
style={'color':'gray'},
),
]
)
],
)
],
className="page-body"
)
layout = html.Div([nav, body, footer], className="site")
return layout