data = root/"data" figs = root/"figs" total_time = 90 * days lockdown_period = 7 gamma = 0.2 window = 10 CI = 0.95 state_cases = pd.read_csv(data/"Bihar_cases_data_Oct03.csv", parse_dates=["date_reported", "date_status_change"], dayfirst=True) state_cases["geo_reported"] = state_cases.geo_reported.str.strip() state_cases = state_cases[state_cases.date_reported <= "2020-09-30"] state_ts = state_cases["date_reported"].value_counts().sort_index() district_ts = state_cases.groupby(["geo_reported", "date_reported"])["date_reported"].count().sort_index() districts, pops, migrations = etl.district_migration_matrix(data/"Migration Matrix - District.csv") districts = sorted([etl.replacements.get(dn, dn) for dn in districts]) R_mandatory = dict() for district in districts:#district_ts.index.get_level_values(0).unique(): try: (_, Rt, *_) = analytical_MPVS(district_ts.loc[district], CI = CI, smoothing = notched_smoothing(window = 10), totals = False) Rm = np.mean(Rt) except ValueError as v: Rm = 1.5 R_mandatory[district] = Rm R_voluntary = {district: 1.2*R for (district, R) in R_mandatory.items()} si, sf = 0, 10
import etl simplefilter("ignore") (data, figs) = setup() gamma = 0.2 smoothing = 10 CI = 0.95 state_cases = pd.read_csv(data / "Bihar_cases_data_Oct03.csv", parse_dates=["date_reported"], dayfirst=True) state_ts = state_cases["date_reported"].value_counts().sort_index() district_names, population_counts, _ = etl.district_migration_matrix( data / "Migration Matrix - District.csv") populations = dict(zip(district_names, population_counts)) # first, look at state level predictions (dates, Rt_pred, Rt_CI_upper, Rt_CI_lower, T_pred, T_CI_upper, T_CI_lower, total_cases, new_cases_ts, anomalies, anomaly_dates) = analytical_MPVS( state_ts, CI=CI, smoothing=notched_smoothing(window=smoothing), totals=False) plt.Rt(dates, Rt_pred[1:], Rt_CI_upper[1:], Rt_CI_lower[1:], CI, ymin=0, ymax=4)\ .title("\nBihar: Reproductive Number Estimate")\ .annotate(f"data from {str(dates[0]).split()[0]} to {str(dates[-1]).split()[0]}")\ .xlabel("date")\ .ylabel("$R_t$", rotation=0, labelpad=20)\