@@ -51,14 +51,17 @@ def display_header(st, m, p):
51
51
unsafe_allow_html = True ,
52
52
)
53
53
st .markdown (
54
- """[Documentation](https://code-for-philly.gitbook.io/chime/) | [Github](https://github.com/CodeForPhilly/chime/) | [Slack](https://codeforphilly.org/chat?channel=covid19-chime-penn)"""
54
+ """[Documentation]({docs_url}) | [Github](https://github.com/CodeForPhilly/chime/) |
55
+ [Slack](https://codeforphilly.org/chat?channel=covid19-chime-penn)""" .format (
56
+ docs_url = DOCS_URL
57
+ )
55
58
)
56
59
st .markdown (
57
60
"""*This tool was developed by the [Predictive Healthcare team](http://predictivehealthcare.pennmedicine.org/) at
58
61
Penn Medicine to assist hospitals and public health officials with hospital capacity planning,
59
62
but can be used anywhere in the world.
60
63
Customize it for your region by modifying data inputs in the left panel.*
61
- """ . format ( docs_url = DOCS_URL )
64
+ """
62
65
)
63
66
64
67
st .markdown (
@@ -86,11 +89,14 @@ def display_header(st, m, p):
86
89
relative_contact_rate = p .relative_contact_rate ,
87
90
r_t = m .r_t ,
88
91
doubling_time_t = abs (m .doubling_time_t ),
89
- impact_statement = ("halves the infections every" if m .r_t < 1 else "reduces the doubling time to" ),
92
+ impact_statement = (
93
+ "halves the infections every"
94
+ if m .r_t < 1
95
+ else "reduces the doubling time to"
96
+ ),
90
97
daily_growth = m .daily_growth_rate * 100.0 ,
91
98
daily_growth_t = m .daily_growth_rate_t * 100.0 ,
92
- docs_url = DOCS_URL ,
93
- infected_population_warning_str = infected_population_warning_str
99
+ infected_population_warning_str = infected_population_warning_str ,
94
100
)
95
101
)
96
102
@@ -99,6 +105,7 @@ def display_header(st, m, p):
99
105
100
106
class Input :
101
107
"""Helper to separate Streamlit input definition from creation/rendering"""
108
+
102
109
def __init__ (self , st_obj , label , value , kwargs ):
103
110
self .st_obj = st_obj
104
111
self .label = label
@@ -110,8 +117,20 @@ def __call__(self):
110
117
111
118
112
119
class NumberInput (Input ):
113
- def __init__ (self , st_obj , label , min_value = None , max_value = None , value = None , step = None , format = None , key = None ):
114
- kwargs = dict (min_value = min_value , max_value = max_value , step = step , format = format , key = key )
120
+ def __init__ (
121
+ self ,
122
+ st_obj ,
123
+ label ,
124
+ min_value = None ,
125
+ max_value = None ,
126
+ value = None ,
127
+ step = None ,
128
+ format = None ,
129
+ key = None ,
130
+ ):
131
+ kwargs = dict (
132
+ min_value = min_value , max_value = max_value , step = step , format = format , key = key
133
+ )
115
134
super ().__init__ (st_obj .number_input , label , value , kwargs )
116
135
117
136
@@ -122,8 +141,20 @@ def __init__(self, st_obj, label, value=None, key=None):
122
141
123
142
124
143
class PercentInput (NumberInput ):
125
- def __init__ (self , st_obj , label , min_value = 0.0 , max_value = 100.0 , value = None , step = FLOAT_INPUT_STEP , format = "%f" , key = None ):
126
- super ().__init__ (st_obj , label , min_value , max_value , value * 100.0 , step , format , key )
144
+ def __init__ (
145
+ self ,
146
+ st_obj ,
147
+ label ,
148
+ min_value = 0.0 ,
149
+ max_value = 100.0 ,
150
+ value = None ,
151
+ step = FLOAT_INPUT_STEP ,
152
+ format = "%f" ,
153
+ key = None ,
154
+ ):
155
+ super ().__init__ (
156
+ st_obj , label , min_value , max_value , value * 100.0 , step , format , key
157
+ )
127
158
128
159
def __call__ (self ):
129
160
return super ().__call__ () / 100.0
@@ -161,40 +192,37 @@ def display_sidebar(st, d: Parameters) -> Parameters:
161
192
doubling_time_input = NumberInput (
162
193
st_obj ,
163
194
"Doubling time before social distancing (days)" ,
164
- min_value = FLOAT_INPUT_MIN ,
195
+ min_value = 0.5 ,
165
196
value = d .doubling_time ,
166
- step = FLOAT_INPUT_STEP ,
197
+ step = 0.25 ,
167
198
format = "%f" ,
168
199
)
169
200
current_date_input = DateInput (
170
- st_obj ,
171
- "Current date (Default is today)" ,
172
- value = d .current_date ,
201
+ st_obj , "Current date (Default is today)" , value = d .current_date ,
173
202
)
174
203
date_first_hospitalized_input = DateInput (
175
- st_obj ,
176
- "Date of first hospitalized case" ,
204
+ st_obj , "Date of first hospitalized case - Enter this date to have chime estimate the initial doubling time" ,
177
205
value = d .date_first_hospitalized ,
178
206
)
179
207
relative_contact_pct_input = PercentInput (
180
208
st_obj ,
181
- "Social distancing (% reduction in social contact)" ,
209
+ "Social distancing (% reduction in social contact going forward)" ,
210
+ min_value = 0.0 ,
211
+ max_value = 100.0 ,
182
212
value = d .relative_contact_rate ,
213
+ step = 1.0 ,
183
214
)
184
215
hospitalized_pct_input = PercentInput (
185
- st_obj ,
186
- "Hospitalization %(total infections)" ,
187
- value = d .hospitalized .rate ,
216
+ st_obj , "Hospitalization %(total infections)" , value = d .hospitalized .rate ,
188
217
)
189
- icu_pct_input = PercentInput (
190
- st_obj ,
218
+ icu_pct_input = PercentInput (st_obj ,
191
219
"ICU %(total infections)" ,
220
+ min_value = 0.0 ,
192
221
value = d .icu .rate ,
222
+ step = 0.05
193
223
)
194
224
ventilated_pct_input = PercentInput (
195
- st_obj ,
196
- "Ventilated %(total infections)" ,
197
- value = d .ventilated .rate ,
225
+ st_obj , "Ventilated %(total infections)" , value = d .ventilated .rate ,
198
226
)
199
227
hospitalized_days_input = NumberInput (
200
228
st_obj ,
@@ -223,14 +251,14 @@ def display_sidebar(st, d: Parameters) -> Parameters:
223
251
market_share_pct_input = PercentInput (
224
252
st_obj ,
225
253
"Hospital Market Share (%)" ,
226
- min_value = FLOAT_INPUT_MIN ,
254
+ min_value = 0.5 ,
227
255
value = d .market_share ,
228
256
)
229
257
population_input = NumberInput (
230
258
st_obj ,
231
259
"Regional Population" ,
232
260
min_value = 1 ,
233
- value = (d .region . population or d . population ),
261
+ value = (d .population ),
234
262
step = 1 ,
235
263
format = "%i" ,
236
264
)
@@ -242,22 +270,39 @@ def display_sidebar(st, d: Parameters) -> Parameters:
242
270
step = 1 ,
243
271
format = "%i" ,
244
272
)
245
- max_y_axis_set_input = CheckboxInput (st_obj , "Set the Y-axis on graphs to a static value" )
246
- max_y_axis_input = NumberInput (st_obj , "Y-axis static value" , value = 500 , format = "%i" , step = 25 )
273
+ max_y_axis_set_input = CheckboxInput (
274
+ st_obj , "Set the Y-axis on graphs to a static value"
275
+ )
276
+ max_y_axis_input = NumberInput (
277
+ st_obj , "Y-axis static value" , value = 500 , format = "%i" , step = 25
278
+ )
247
279
248
280
# Build in desired order
281
+ st .sidebar .markdown (
282
+ """**CHIME [v1.1.0](https://github.com/CodeForPhilly/chime/releases/tag/v1.1.0) (2020/03/30)**"""
283
+ )
284
+
249
285
current_date = current_date_input ()
250
286
251
- st .sidebar .markdown ("### Regional Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
287
+ st .sidebar .markdown (
288
+ "### Regional Parameters [ℹ]({docs_url}/what-is-chime/parameters#regional-parameters)" .format (
289
+ docs_url = DOCS_URL
290
+ )
291
+ )
252
292
population = population_input ()
253
293
market_share = market_share_pct_input ()
254
- #known_infected = known_infected_input()
294
+ # known_infected = known_infected_input()
255
295
current_hospitalized = current_hospitalized_input ()
256
296
257
- st .sidebar .markdown ("### Spread and Contact Parameters [ℹ]({docs_url}/what-is-chime/parameters)"
258
- .format (docs_url = DOCS_URL ))
297
+ st .sidebar .markdown (
298
+ "### Spread and Contact Parameters [ℹ]({docs_url}/what-is-chime/parameters#spread-and-contact-parameters)" .format (
299
+ docs_url = DOCS_URL
300
+ )
301
+ )
259
302
260
- if st .sidebar .checkbox ("I know the date of the first hospitalized case in the region." ):
303
+ if st .sidebar .checkbox (
304
+ "I know the date of the first hospitalized case in the region."
305
+ ):
261
306
date_first_hospitalized = date_first_hospitalized_input ()
262
307
doubling_time = None
263
308
else :
@@ -266,7 +311,11 @@ def display_sidebar(st, d: Parameters) -> Parameters:
266
311
267
312
relative_contact_rate = relative_contact_pct_input ()
268
313
269
- st .sidebar .markdown ("### Severity Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
314
+ st .sidebar .markdown (
315
+ "### Severity Parameters [ℹ]({docs_url}/what-is-chime/parameters#severity-parameters)" .format (
316
+ docs_url = DOCS_URL
317
+ )
318
+ )
270
319
hospitalized_rate = hospitalized_pct_input ()
271
320
icu_rate = icu_pct_input ()
272
321
ventilated_rate = ventilated_pct_input ()
@@ -275,7 +324,11 @@ def display_sidebar(st, d: Parameters) -> Parameters:
275
324
icu_days = icu_days_input ()
276
325
ventilated_days = ventilated_days_input ()
277
326
278
- st .sidebar .markdown ("### Display Parameters [ℹ]({docs_url}/what-is-chime/parameters)" .format (docs_url = DOCS_URL ))
327
+ st .sidebar .markdown (
328
+ "### Display Parameters [ℹ]({docs_url}/what-is-chime/parameters#display-parameters)" .format (
329
+ docs_url = DOCS_URL
330
+ )
331
+ )
279
332
n_days = n_days_input ()
280
333
max_y_axis_set = max_y_axis_set_input ()
281
334
@@ -289,7 +342,6 @@ def display_sidebar(st, d: Parameters) -> Parameters:
289
342
icu = Disposition (icu_rate , icu_days ),
290
343
relative_contact_rate = relative_contact_rate ,
291
344
ventilated = Disposition (ventilated_rate , ventilated_days ),
292
-
293
345
current_date = current_date ,
294
346
date_first_hospitalized = date_first_hospitalized ,
295
347
doubling_time = doubling_time ,
@@ -302,11 +354,7 @@ def display_sidebar(st, d: Parameters) -> Parameters:
302
354
303
355
304
356
def display_more_info (
305
- st ,
306
- model : Model ,
307
- parameters : Parameters ,
308
- defaults : Parameters ,
309
- notes : str = "" ,
357
+ st , model : Model , parameters : Parameters , defaults : Parameters , notes : str = "" ,
310
358
):
311
359
"""a lot of streamlit writing to screen."""
312
360
st .subheader (
@@ -398,12 +446,6 @@ def display_more_info(
398
446
""" .format (
399
447
notes = notes
400
448
)
401
- + "- "
402
- + "| \n " .join (
403
- f"{ key } = { value } "
404
- for key , value in defaults .region .__dict__ .items ()
405
- if key != "_s"
406
- )
407
449
)
408
450
return None
409
451
@@ -412,7 +454,9 @@ def write_definitions(st):
412
454
st .subheader ("Guidance on Selecting Inputs" )
413
455
st .markdown (
414
456
"""**This information has been moved to the
415
- [User Documentation]({docs_url}/what-is-chime/parameters#guidance-on-selecting-inputs)**""" .format (docs_url = DOCS_URL )
457
+ [User Documentation]({docs_url}/what-is-chime/parameters)**""" .format (
458
+ docs_url = DOCS_URL
459
+ )
416
460
)
417
461
418
462
@@ -421,13 +465,19 @@ def write_footer(st):
421
465
st .markdown (
422
466
"""* AHA Webinar, Feb 26, James Lawler, MD, an associate professor University of Nebraska Medical Center, What Healthcare Leaders Need To Know: Preparing for the COVID-19
423
467
* We would like to recognize the valuable assistance in consultation and review of model assumptions by Michael Z. Levy, PhD, Associate Professor of Epidemiology, Department of Biostatistics, Epidemiology and Informatics at the Perelman School of Medicine
468
+ * Finally we'd like to thank [Code for Philly](https://codeforphilly.org/) and the many members of the open-source community that [contributed](https://github.com/CodeForPhilly/chime/graphs/contributors) to this project.
424
469
"""
425
470
)
426
471
st .markdown ("© 2020, The Trustees of the University of Pennsylvania" )
427
472
428
473
429
474
def display_download_link (st , filename : str , df : pd .DataFrame ):
430
475
csv = dataframe_to_base64 (df )
431
- st .markdown ("""
476
+ st .markdown (
477
+ """
432
478
<a download="{filename}" href="data:file/csv;base64,{csv}">Download {filename}</a>
433
- """ .format (csv = csv ,filename = filename ), unsafe_allow_html = True )
479
+ """ .format (
480
+ csv = csv , filename = filename
481
+ ),
482
+ unsafe_allow_html = True ,
483
+ )
0 commit comments