adding new graphs
@@ -55,6 +55,18 @@ S = st.sidebar.number_input(
"Regional Population", value=S_default, step=100000, format="%i"
)
+hosp_capacity = st.sidebar.number_input(
+ "Hospital Capacity", value=1000, step=100, format="%i"
+)
+
+icu_capacity = st.sidebar.number_input(
+ "ICU Capacity", value=300, step=50, format="%i"
+)
+
+vent_capacity = st.sidebar.number_input(
+ "Ventilator Capacity", value=200, step=50, format="%i"
+)
+
total_infections = current_hosp / Penn_market_share / hosp_rate
detection_prob = initial_infections / total_infections
@@ -269,6 +281,65 @@ census_table = census_table.dropna().astype(int)
if st.checkbox("Show Projected Census in tabular form"):
st.dataframe(census_table)
+st.subheader("Hospital Capacity")
+st.markdown(
+ "Projected number of hospital resources."
+)
+
+cap_dict = {
+ "hosp": hosp_capacity,
+ "icu": icu_capacity,
+ "vent": vent_capacity,
+}
+
+fig, ax = plt.subplots(1, 1, figsize=(10, 4))
+
+census_dict = {}
+for k, los in los_dict.items():
+ census = cap_dict[k] - (
+ projection_admits.cumsum().iloc[:-los, :]
+ - projection_admits.cumsum().shift(los).fillna(0)
+ ).apply(np.ceil)
+ census_dict[k] = census[k]
+ ax.plot(census.head(plot_projection_days)[k], ".-", label=k + " census")
+ ax.legend(loc=0)
+
+ax.set_xlabel("Days from today")
+ax.grid("on")
+ax.set_ylabel("Number of resources")
+ax.axhline(y=0, color='r', linestyle='-')
+st.pyplot()
+
+census_df = pd.DataFrame(census_dict)
+census_df["day"] = census_df.index
+census_df = census_df[["day", "hosp", "icu", "vent"]]
+
+census_table = census_df[np.mod(census_df.index, 7) == 0].copy()
+census_table.index = range(census_table.shape[0])
+census_table.loc[0, :] = 0
+census_table = census_table.dropna().astype(int)
+
+
+wording_dict = {
+ 'hosp': 'Hospital beds',
+ 'icu': 'ICU beds',
+ 'vent': 'Ventilators'
+}
+
+for k, word in wording_dict.items():
+ try:
+ cap_day = census_df[census_df[k] < 0]['day'].iloc[0]
+ st.markdown(
+ "* {} will reach capacity on day **{}**.".format(word, cap_day)
+ )
+ except Exception as e:
+ print(e)
+
+if st.checkbox("Show Projected Hospital Resources in tabular form"):
+ st.dataframe(census_table)
+
+
+
st.markdown(
"""**Click the checkbox below to view additional data generated by this simulation**"""
)
