|
25 | 25 | ########
|
26 | 26 |
|
27 | 27 |
|
28 |
| -def display_header( |
29 |
| - st, |
30 |
| - total_infections, |
31 |
| - initial_infections, |
32 |
| - detection_prob, |
33 |
| - current_hosp, |
34 |
| - hosp_rate, |
35 |
| - S, |
36 |
| - market_share, |
37 |
| - recovery_days, |
38 |
| - r_naught, |
39 |
| - doubling_time, |
40 |
| - relative_contact_rate, |
41 |
| - r_t, |
42 |
| - doubling_time_t, |
43 |
| -): |
| 28 | +def display_header(st, p): |
44 | 29 |
|
45 | 30 | detection_prob_str = (
|
46 |
| - "{detection_prob:.0%}".format(detection_prob=detection_prob) |
47 |
| - if detection_prob is not None |
| 31 | + "{detection_prob:.0%}".format(detection_prob=p.detection_probability) |
| 32 | + if p.detection_probability |
48 | 33 | else "unknown"
|
49 | 34 | )
|
50 | 35 | st.markdown(
|
@@ -78,19 +63,19 @@ def display_header(
|
78 | 63 | **Mitigation**: A **{relative_contact_rate:.0%}** reduction in social contact after the onset of the
|
79 | 64 | outbreak reduces the doubling time to **{doubling_time_t:.1f}** days, implying an effective $R_t$ of **${r_t:.2f}$**.
|
80 | 65 | """.format(
|
81 |
| - total_infections=total_infections, |
82 |
| - initial_infections=initial_infections, |
| 66 | + total_infections=p.infected, |
| 67 | + initial_infections=p.known_infected, |
83 | 68 | detection_prob_str=detection_prob_str,
|
84 |
| - current_hosp=current_hosp, |
85 |
| - hosp_rate=hosp_rate, |
86 |
| - S=S, |
87 |
| - market_share=market_share, |
88 |
| - recovery_days=recovery_days, |
89 |
| - r_naught=r_naught, |
90 |
| - doubling_time=doubling_time, |
91 |
| - relative_contact_rate=relative_contact_rate, |
92 |
| - r_t=r_t, |
93 |
| - doubling_time_t=doubling_time_t, |
| 69 | + current_hosp=p.current_hospitalized, |
| 70 | + hosp_rate=p.hospitalized.rate, |
| 71 | + S=p.susceptible, |
| 72 | + market_share=p.market_share, |
| 73 | + recovery_days=p.recovery_days, |
| 74 | + r_naught=p.r_naught, |
| 75 | + doubling_time=p.doubling_time, |
| 76 | + relative_contact_rate=p.relative_contact_rate, |
| 77 | + r_t=p.r_t, |
| 78 | + doubling_time_t=p.doubling_time_t, |
94 | 79 | )
|
95 | 80 | )
|
96 | 81 |
|
@@ -255,12 +240,7 @@ def display_n_days_slider(st, p: Parameters, d: Constants):
|
255 | 240 |
|
256 | 241 | def show_more_info_about_this_tool(
|
257 | 242 | st,
|
258 |
| - recovery_days, |
259 |
| - doubling_time, |
260 |
| - r_naught, |
261 |
| - relative_contact_rate, |
262 |
| - doubling_time_t, |
263 |
| - r_t, |
| 243 | + parameters, |
264 | 244 | inputs: Constants,
|
265 | 245 | notes: str = ''
|
266 | 246 | ):
|
@@ -332,12 +312,12 @@ def show_more_info_about_this_tool(
|
332 | 312 | - $\\gamma$: the CDC is recommending 14 days of self-quarantine, we'll use $\\gamma = 1/{recovery_days}$.
|
333 | 313 | - To estimate $$\\beta$$ directly, we'd need to know transmissibility and social contact rates. since we don't know these things, we can extract it from known _doubling times_. The AHA says to expect a doubling time $T_d$ of 7-10 days. That means an early-phase rate of growth can be computed by using the doubling time formula:
|
334 | 314 | """.format(
|
335 |
| - doubling_time=doubling_time, |
336 |
| - recovery_days=recovery_days, |
337 |
| - r_naught=r_naught, |
338 |
| - relative_contact_rate=relative_contact_rate, |
339 |
| - doubling_time_t=doubling_time_t, |
340 |
| - r_t=r_t, |
| 315 | + doubling_time=parameters.doubling_time, |
| 316 | + recovery_days=parameters.recovery_days, |
| 317 | + r_naught=parameters.r_naught, |
| 318 | + relative_contact_rate=parameters.relative_contact_rate, |
| 319 | + doubling_time_t=parameters.doubling_time_t, |
| 320 | + r_t=parameters.r_t, |
341 | 321 | )
|
342 | 322 | )
|
343 | 323 | st.latex("g = 2^{1/T_d} - 1")
|
@@ -390,16 +370,21 @@ def show_additional_projections(
|
390 | 370 | st,
|
391 | 371 | alt,
|
392 | 372 | charting_func,
|
393 |
| - i, |
394 |
| - r, |
| 373 | + parameters, |
395 | 374 | as_date: bool = False,
|
396 |
| - max_y_axis: int = None |
397 | 375 | ):
|
398 | 376 | st.subheader(
|
399 | 377 | "The number of infected and recovered individuals in the hospital catchment region at any given moment"
|
400 | 378 | )
|
401 | 379 |
|
402 |
| - st.altair_chart(charting_func(alt, i, r, as_date=as_date, max_y_axis=max_y_axis), use_container_width=True) |
| 380 | + st.altair_chart( |
| 381 | + charting_func( |
| 382 | + alt, |
| 383 | + parameters.infected_v, |
| 384 | + parameters.recovered_v, |
| 385 | + as_date=as_date, |
| 386 | + max_y_axis=parameters.max_y_axis), |
| 387 | + use_container_width=True) |
403 | 388 |
|
404 | 389 |
|
405 | 390 | ##########
|
@@ -444,10 +429,13 @@ def draw_census_table(st, census_df: pd.DataFrame, as_date: bool = False):
|
444 | 429 | return None
|
445 | 430 |
|
446 | 431 |
|
447 |
| -def draw_raw_sir_simulation_table(st, n_days, s, i, r, as_date: bool = False): |
448 |
| - days = np.arange(0, n_days + 1) |
449 |
| - data_list = [days, s, i, r] |
450 |
| - data_dict = dict(zip(["day", "susceptible", "infections", "recovered"], data_list)) |
| 432 | +def draw_raw_sir_simulation_table( |
| 433 | + st, |
| 434 | + parameters, |
| 435 | + as_date: bool = False): |
| 436 | + days = np.arange(0, parameters.n_days + 1) |
| 437 | + data_list = [days, parameters.susceptible_v, parameters.infected_v, parameters.recovered_v] |
| 438 | + data_dict = dict(zip(["day", "Susceptible", "Infections", "Recovered"], data_list)) |
451 | 439 | projection_area = pd.DataFrame.from_dict(data_dict)
|
452 | 440 | infect_table = (projection_area.iloc[::7, :]).apply(np.floor)
|
453 | 441 | infect_table.index = range(infect_table.shape[0])
|
|
0 commit comments