59
59
)
60
60
61
61
initial_infections = st .sidebar .number_input (
62
- "Currently Known Regional Infections (only used to compute detection rate - does not change projections) " , value = known_infections , step = 10 , format = "%i"
62
+ "Currently Known Regional Infections" , value = known_infections , step = 10 , format = "%i"
63
63
)
64
64
65
65
total_infections = current_hosp / Penn_market_share / hosp_rate
@@ -286,6 +286,7 @@ def sim_sir(S, I, R, beta, gamma, n_days, beta_decay=None):
286
286
projection_admits = projection .iloc [:- 1 , :] - projection .shift (1 )
287
287
projection_admits [projection_admits < 0 ] = 0
288
288
289
+
289
290
plot_projection_days = n_days - 10
290
291
projection_admits ["day" ] = range (projection_admits .shape [0 ])
291
292
@@ -324,7 +325,7 @@ def new_admissions_chart(projection_admits: pd.DataFrame, plot_projection_days:
324
325
"Projected **census** of COVID-19 patients, accounting for arrivals and discharges at Penn hospitals"
325
326
)
326
327
327
- def _census_table (projection_admits , hosp_los , icu_los , vent_los ) -> pd .DataFrame :
328
+ def _census_df (projection_admits , hosp_los , icu_los , vent_los ) -> pd .DataFrame :
328
329
"""ALOS for each category of COVID-19 case (total guesses)"""
329
330
330
331
los_dict = {
@@ -345,23 +346,16 @@ def _census_table(projection_admits, hosp_los, icu_los, vent_los) -> pd.DataFram
345
346
census_df = pd .DataFrame (census_dict )
346
347
census_df ["day" ] = census_df .index
347
348
census_df = census_df [["day" , "hosp" , "icu" , "vent" ]]
349
+ return census_df
348
350
349
- census_table = census_df [np .mod (census_df .index , 7 ) == 0 ].copy ()
350
- census_table .index = range (census_table .shape [0 ])
351
- census_table .loc [0 , :] = 0
352
- census_table = census_table .dropna ().astype (int )
353
-
354
- return census_table
355
-
356
- census_table = _census_table (projection_admits , hosp_los , icu_los , vent_los )
351
+ census_df = _census_df (projection_admits , hosp_los , icu_los , vent_los )
357
352
358
353
def admitted_patients_chart (census : pd .DataFrame ) -> alt .Chart :
359
354
"""docstring"""
360
355
census = census .rename (columns = {"hosp" : "Hospital Census" , "icu" : "ICU Census" , "vent" : "Ventilated Census" })
361
-
362
356
return (
363
357
alt
364
- .Chart (census )
358
+ .Chart (census . head ( plot_projection_days ) )
365
359
.transform_fold (fold = ["Hospital Census" , "ICU Census" , "Ventilated Census" ])
366
360
.mark_line (point = True )
367
361
.encode (
@@ -373,9 +367,14 @@ def admitted_patients_chart(census: pd.DataFrame) -> alt.Chart:
373
367
.interactive ()
374
368
)
375
369
376
- st .altair_chart (admitted_patients_chart (census_table ), use_container_width = True )
370
+ st .altair_chart (admitted_patients_chart (census_df ), use_container_width = True )
377
371
378
372
if st .checkbox ("Show Projected Census in tabular form" ):
373
+ census_table = census_df [np .mod (census_df .index , 7 ) == 0 ].copy ()
374
+ census_table .index = range (census_table .shape [0 ])
375
+ census_table .loc [0 , :] = 0
376
+ census_table = census_table .dropna ().astype (int )
377
+
379
378
st .dataframe (census_table )
380
379
381
380
def additional_projections_chart (i : np .ndarray , r : np .ndarray ) -> alt .Chart :
0 commit comments