feat: Added second vaccinations to days remaining plots
This commit is contained in:
parent
3e9f00ec2b
commit
bef88716d8
1 changed files with 57 additions and 43 deletions
100
plot.py
100
plot.py
|
@ -142,7 +142,7 @@ def parse_rki(filename):
|
||||||
extrapolation_last_rate = extrapolate(data.iloc[-1], to_be_vaccinated)
|
extrapolation_last_rate = extrapolate(data.iloc[-1], to_be_vaccinated)
|
||||||
extrapolation_mean_seven_days = extrapolate(mean_seven_days, to_be_vaccinated)
|
extrapolation_mean_seven_days = extrapolate(mean_seven_days, to_be_vaccinated)
|
||||||
|
|
||||||
mean_vaccination_rates_daily = np.round(cumulative / range(1, len(cumulative) + 1))
|
mean_vaccination_rates_daily = data.expanding().mean() #np.round(cumulative / range(1, len(cumulative) + 1))
|
||||||
vaccination_rates_daily_rolling_average = data.rolling(7).mean()
|
vaccination_rates_daily_rolling_average = data.rolling(7).mean()
|
||||||
|
|
||||||
vaccinations_missing_until_target = einwohner_deutschland * herd_immunity - total
|
vaccinations_missing_until_target = einwohner_deutschland * herd_immunity - total
|
||||||
|
@ -682,29 +682,30 @@ def plot_vaccination_done_days():
|
||||||
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Anzahl Tage, Gesamt und 7 Tage)\n'
|
'Lin. Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Anzahl Tage, Gesamt und 7 Tage)\n'
|
||||||
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
print_stand, print_today
|
print_stand, print_today
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = data_first_vaccination
|
|
||||||
|
|
||||||
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
|
||||||
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
|
||||||
|
|
||||||
ax.set_xlim(start_of_reporting_date, today)
|
ax.set_xlim(start_of_reporting_date, today)
|
||||||
ax.set_ylim(0, 2500)
|
ax.set_ylim(0, 2500)
|
||||||
ax.axhline(days_until_target, label='Impfziel Ende Sommer')
|
ax.axhline(days_until_target, label='Impfziel Ende Sommer')
|
||||||
|
|
||||||
ax.plot(dates, days_remaining_daily, label='Durchschnitt Gesamt', linewidth=0.5)
|
for d, c, l in [(data_first_vaccination, 'blue', 'Erstimpfungen'), (data_second_vaccination, 'lightblue', 'Zweitimpfungen')]:
|
||||||
ax.plot(dates, days_remaining_rolling, label='Durchschnitt 7 Tage', linewidth=2)
|
|
||||||
|
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
||||||
|
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
||||||
|
|
||||||
|
ax.plot(dates, days_remaining_daily, label=f'{l} Durchschnitt Gesamt', linewidth=0.5, color=c)
|
||||||
|
ax.plot(dates, days_remaining_rolling, label=f'{l} Durchschnitt 7 Tage', linewidth=2, color=c)
|
||||||
|
|
||||||
ax.grid(True)
|
ax.grid(True)
|
||||||
|
|
||||||
d = datetime.date(2021, 3, 1)
|
d = datetime.date(2021, 3, 1)
|
||||||
ax.add_patch(Rectangle((d, 0), today - d, 52 * 7, edgecolor='darkgrey', lw=3, fill=False, label='Detailansicht (s.u.)'))
|
ax.add_patch(Rectangle((d, 0), today - d, 52 * 7, edgecolor='darkgrey', lw=3, fill=False, label='Detailansicht (s.u.)'))
|
||||||
|
|
||||||
ax.legend(loc='upper right')
|
ax.legend(loc='lower left')
|
||||||
ax.get_yaxis().get_major_formatter().set_scientific(False)
|
ax.get_yaxis().get_major_formatter().set_scientific(False)
|
||||||
|
|
||||||
ax.set_xlabel('Datum')
|
ax.set_xlabel('Datum')
|
||||||
|
@ -726,27 +727,28 @@ def plot_vaccination_done_weeks():
|
||||||
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Anzahl Wochen, Gesamt und 7 Tage)\n'
|
'Lin. Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Anzahl Wochen, Gesamt und 7 Tage)\n'
|
||||||
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
print_stand, print_today
|
print_stand, print_today
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = data_first_vaccination
|
|
||||||
|
|
||||||
weeks_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily'])) / 7
|
|
||||||
weeks_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average'])) / 7
|
|
||||||
|
|
||||||
ax.set_xlim(datetime.date(2021, 3, 1), today)
|
ax.set_xlim(datetime.date(2021, 3, 1), today)
|
||||||
ax.set_ylim(0, 52)
|
ax.set_ylim(0, 52)
|
||||||
ax.axhline(days_until_target / 7, label='Impfziel Ende Sommer')
|
ax.axhline(days_until_target / 7, label='Impfziel Ende Sommer')
|
||||||
|
|
||||||
ax.plot(dates, weeks_remaining_daily, label='Durchschnitt Gesamt', linewidth=0.5)
|
for d, c, l in [(data_first_vaccination, 'blue', 'Erstimpfungen'), (data_second_vaccination, 'lightblue', 'Zweitimpfungen')]:
|
||||||
ax.plot(dates, weeks_remaining_rolling, label='Durchschnitt 7 Tage', linewidth=2)
|
|
||||||
|
weeks_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily'])) / 7
|
||||||
|
weeks_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average'])) / 7
|
||||||
|
|
||||||
|
ax.plot(dates, weeks_remaining_daily, label=f'{l} Durchschnitt Gesamt', linewidth=0.5, color=c)
|
||||||
|
ax.plot(dates, weeks_remaining_rolling, label=f'{l} Durchschnitt 7 Tage', linewidth=2, color=c)
|
||||||
|
|
||||||
ax.grid(True)
|
ax.grid(True)
|
||||||
|
|
||||||
|
|
||||||
ax.legend(loc='upper right')
|
ax.legend(loc='lower left')
|
||||||
ax.get_yaxis().get_major_formatter().set_scientific(False)
|
ax.get_yaxis().get_major_formatter().set_scientific(False)
|
||||||
|
|
||||||
ax.set_xlabel('Datum')
|
ax.set_xlabel('Datum')
|
||||||
|
@ -769,31 +771,37 @@ def plot_vaccination_done_dates():
|
||||||
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Datum, Gesamt und 7 Tage)\n'
|
'Lin. Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Datum, Gesamt und 7 Tage)\n'
|
||||||
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
print_stand, print_today
|
print_stand, print_today
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = data_first_vaccination
|
|
||||||
|
|
||||||
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
for d, c, l in [(data_first_vaccination, 'blue', 'Erstimpfungen'), (data_second_vaccination, 'lightblue', 'Zweitimpfungen')]:
|
||||||
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
|
||||||
|
|
||||||
dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily]
|
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
||||||
dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()]
|
#days_remaining_daily[np.isnan(days_remaining_daily)] = 10000
|
||||||
|
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
||||||
|
#days_remaining_rolling[np.isnan(days_remaining_rolling)] = 10000
|
||||||
|
|
||||||
|
dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily.dropna()]
|
||||||
|
dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()]
|
||||||
|
|
||||||
|
offset = len(dates) - len(dates_daily)
|
||||||
|
ax.plot(dates[offset:], dates_daily, label=f'{l} Durchschnitt Gesamt', linewidth=0.5, color=c)
|
||||||
|
|
||||||
|
offset = len(dates) - len(dates_rolling)
|
||||||
|
ax.plot(dates[offset:], dates_rolling, label=f'{l} Durchschnitt 7 Tage', linewidth=2, color=c)
|
||||||
|
|
||||||
ax.set_xlim(start_of_reporting_date, today)
|
ax.set_xlim(start_of_reporting_date, today)
|
||||||
ax.set_ylim(today, today + datetime.timedelta(int(np.max(days_remaining_rolling) * 1.05)))
|
ax.set_ylim(today, datetime.date(2025, 7, 1))
|
||||||
|
|
||||||
ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer')
|
ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer')
|
||||||
ax.add_patch(Rectangle((datetime.date(2021, 4, 6), today), today - datetime.date(2021, 4, 6), target_date_for_herd_immunity - today, edgecolor='darkgrey', lw=3, fill=False, label='Detailansicht (s.u.)'))
|
ax.add_patch(Rectangle((datetime.date(2021, 4, 6), today), today - datetime.date(2021, 4, 6), target_date_for_herd_immunity - today, edgecolor='darkgrey', lw=3, fill=False, label='Detailansicht (s.u.)'))
|
||||||
|
|
||||||
ax.plot(dates, dates_daily, label='Durchschnitt Gesamt', linewidth=0.5)
|
|
||||||
ax.plot(dates[6:], dates_rolling, label='Durchschnitt 7 Tage', linewidth=2)
|
|
||||||
|
|
||||||
ax.grid(True)
|
ax.grid(True)
|
||||||
|
|
||||||
|
|
||||||
ax.legend(loc='upper right')
|
ax.legend(loc='lower left')
|
||||||
|
|
||||||
ax.set_xlabel('Datum')
|
ax.set_xlabel('Datum')
|
||||||
ax.set_ylabel('Datum, an dem 70 % erreicht sind')
|
ax.set_ylabel('Datum, an dem 70 % erreicht sind')
|
||||||
|
@ -815,30 +823,36 @@ def plot_vaccination_done_dates_detail():
|
||||||
|
|
||||||
|
|
||||||
plt.title(
|
plt.title(
|
||||||
'Lin. Extrapolation der Erstimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Detail, Datum, Gesamt und 7 Tage)\n'
|
'Lin. Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschn. Impfrate (Detail, Datum, Gesamt und 7 Tage)\n'
|
||||||
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
'Datenquelle: RKI, Stand: {}. Erstellung: {}, Ersteller: Benedikt Bastin, Lizenz: CC BY-SA 4.0\n'.format(
|
||||||
print_stand, print_today
|
print_stand, print_today
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
d = data_first_vaccination
|
|
||||||
|
|
||||||
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
for d, c, l in [(data_first_vaccination, 'blue', 'Erstimpfungen'), (data_second_vaccination, 'lightblue', 'Zweitimpfungen')]:
|
||||||
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
|
||||||
|
|
||||||
dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily]
|
days_remaining_daily = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['mean_vaccination_rates_daily']))
|
||||||
dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()]
|
days_remaining_daily[np.isnan(days_remaining_daily)] = 10000
|
||||||
|
days_remaining_rolling = np.ceil((einwohner_deutschland * herd_immunity - d['cumulative']) / (d['vaccination_rates_daily_rolling_average']))
|
||||||
|
days_remaining_rolling[np.isnan(days_remaining_rolling)] = 10000
|
||||||
|
|
||||||
|
dates_daily = [today + datetime.timedelta(days) for days in days_remaining_daily.dropna()]
|
||||||
|
dates_rolling = [today + datetime.timedelta(days) for days in days_remaining_rolling.dropna()]
|
||||||
|
|
||||||
|
offset = len(dates) - len(dates_daily)
|
||||||
|
ax.plot(dates[offset:], dates_daily, label=f'{l} Durchschnitt Gesamt', linewidth=0.5, color=c)
|
||||||
|
|
||||||
|
offset = len(dates) - len(dates_rolling)
|
||||||
|
ax.plot(dates[offset:], dates_rolling, label=f'{l} Durchschnitt 7 Tage', linewidth=2, color=c)
|
||||||
|
|
||||||
ax.set_xlim(datetime.date(2021, 4, 6), today)
|
ax.set_xlim(datetime.date(2021, 4, 6), today)
|
||||||
ax.set_ylim(today, target_date_for_herd_immunity)
|
ax.set_ylim(today, target_date_for_herd_immunity)
|
||||||
ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer')
|
ax.axhline(target_date_for_herd_immunity - datetime.timedelta(21), label='Impfziel Ende Sommer')
|
||||||
|
|
||||||
ax.plot(dates, dates_daily, label='Durchschnitt Gesamt', linewidth=0.5)
|
|
||||||
ax.plot(dates[6:], dates_rolling, label='Durchschnitt 7 Tage', linewidth=2)
|
|
||||||
|
|
||||||
ax.grid(True)
|
ax.grid(True)
|
||||||
|
|
||||||
|
|
||||||
ax.legend(loc='upper right')
|
ax.legend(loc='lower left')
|
||||||
|
|
||||||
ax.set_xlabel('Datum')
|
ax.set_xlabel('Datum')
|
||||||
ax.set_ylabel('Datum, an dem 70 % erreicht sind')
|
ax.set_ylabel('Datum, an dem 70 % erreicht sind')
|
||||||
|
@ -928,19 +942,19 @@ def render_dashboard():
|
||||||
},{
|
},{
|
||||||
'index': 10,
|
'index': 10,
|
||||||
'filename': 'vaccination_done_days',
|
'filename': 'vaccination_done_days',
|
||||||
'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Anzahl Tage, Gesamt und 7 Tage)'
|
'caption': 'Lineare Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschnittlichen Impfrate (Anzahl Tage, Gesamt und 7 Tage)'
|
||||||
},{
|
},{
|
||||||
'index': 11,
|
'index': 11,
|
||||||
'filename': 'vaccination_done_weeks',
|
'filename': 'vaccination_done_weeks',
|
||||||
'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Anzahl Wochen, Gesamt und 7 Tage)'
|
'caption': 'Lineare Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschnittlichen Impfrate (Anzahl Wochen, Gesamt und 7 Tage)'
|
||||||
},{
|
},{
|
||||||
'index': 12,
|
'index': 12,
|
||||||
'filename': 'vaccination_done_dates',
|
'filename': 'vaccination_done_dates',
|
||||||
'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)'
|
'caption': 'Lineare Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)'
|
||||||
},{
|
},{
|
||||||
'index': 13,
|
'index': 13,
|
||||||
'filename': 'vaccination_done_dates_detail',
|
'filename': 'vaccination_done_dates_detail',
|
||||||
'caption': 'Lineare Extrapolation bis 70 % der Bevölkerung anhand der Erstimpfungen der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)'
|
'caption': 'Lineare Extrapolation der Erst- und Zweitimpfungen bis 70 % der Bevölkerung anhand der durchschnittlichen Impfrate (Datum, Gesamt und 7 Tage)'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
).dump('site/index.xhtml')
|
).dump('site/index.xhtml')
|
||||||
|
|
Loading…
Reference in a new issue