vaccination state corrected (first vs second dose), small cleanup

This commit is contained in:
fordprefect
2021-02-17 13:50:18 +01:00
parent aa8faf634e
commit 15784f7e72
3 changed files with 43 additions and 31 deletions

View File

@@ -30,17 +30,32 @@ def plot(data, countries, pop, metadata, **kwargs):
# is this country vaccinating?
is_vaccinating = True if data[loc]['total_vaccinations'][-1] > 0 else False
if is_vaccinating:
first_vac_report = np.argwhere(np.isnan(data[loc]['total_vaccinations']))[-1][0] + 1
vac_text = f"<tr><td>Impfstart</td><td>{data[loc]['time'][first_vac_report]}</td></tr>"
vac_text = ""
try:
vac_rate = data[loc]['total_vaccinations'][-1]/metadata[loc]['population']*100
vac_text+= f"<tr><td>Impfrate</td><td>{vac_rate:1.3f} %</td></tr>"
first_vac_report = np.argwhere(np.isnan(data[loc]['total_vaccinations']))[-1][0] + 1
vac_text += f"<tr><td>Impfstart</td><td>{data[loc]['time'][first_vac_report]}</td></tr>"
except:
print("------> country details: strange error, ignoring")
try:
if not (np.isnan(data[loc]['people_fully_vaccinated'])).all():
vac_rate = data[loc]['people_fully_vaccinated'][-1]/metadata[loc]['population']*100
vac_text += f"<tr><td>Impfrate</td><td>{vac_rate:1.3f} %</td></tr>"
else:
vac_text += f"<tr><td>Impfrate</td><td>n/a</td></tr>"
except:
pass
try:
immune_rate = (data[loc]['total_vaccinations'][-1] + data[loc]['total_cases'][-1])/metadata[loc]['population']*100
vac_text += f"<tr><td>Immunrate</td><td>{immune_rate:1.3f} %</td></tr>"
vac_text += f"<tr><td>Geimpfte</td><td>{data[loc]['total_vaccinations'][-1]}</td></tr>"
if not (np.isnan(data[loc]['people_fully_vaccinated'])).all():
immune_rate = (data[loc]['people_fully_vaccinated'][-1] + data[loc]['total_cases'][-1])/metadata[loc]['population']*100
vac_text += f"<tr><td>Immunrate</td><td>{immune_rate:1.3f} %</td></tr>"
vac_text += f"<tr><td>verabreichte Impfdosen</td><td>{data[loc]['total_vaccinations'][-1]}</td></tr>"
vac_text += f"<tr><td>vollständig Geimpfte</td><td>{int(data[loc]['people_fully_vaccinated'][-1])}</td></tr>"
else:
vac_text += f"<tr><td>Immunrate</td><td>n/a %</td></tr>"
vac_text += f"<tr><td>verabreichte Impfdosen</td><td>{data[loc]['total_vaccinations'][-1]}</td></tr>"
vac_text += f"<tr><td>vollständig Geimpfte</td><td>n/a</td></tr>"
except:
pass
try:
@@ -103,7 +118,10 @@ Letztes Update: {datetime.datetime.strftime(datetime.datetime.now(), "%Y-%m-%d")
<details open><summary>Testsituation</summary><img src=https://dukun.de/corona/{path}/tests.png />
<br>
Testing dataset: Hasell, J., Mathieu, E., Beltekian, D. et al. A cross-country database of COVID-19 testing. Sci Data 7, 345 (2020). <a href=https://doi.org/10.1038/s41597-020-00688-8>DOI:10.1038/s41597-020-00688-8</a></details>
<details open><summary>Impfsituation</summary><img src=https://dukun.de/corona/{path}/vaccinations.png /></details>
<details open><summary>Impfsituation</summary><img src=https://dukun.de/corona/{path}/vaccinations.png />
<br>
Immunität: Vollständige Impfung oder durchgemachte Erkrankung. Unterschätzung durch vernachlässigte Schutzwirkung der ersten Impfung. Überschätzung durch noch nicht beendete Erkrankungen.
</details>
<br><br>
<a href=https://dukun.de/corona>Zurück</a><br>
@@ -221,13 +239,13 @@ Ein Infoservice von <a href=dukun.de>dukun.de</a>; Anregungen gern <a href="mail
if not np.isnan(new_vaccinations).all():
ax1.plot(np.array(time), new_vaccinations, color="grey", linestyle="--", linewidth=1, label="new vaccinations")
if not np.isnan(total_vaccinations).all():
ax2.plot(np.array(time), total_vaccinations, color="blue", linestyle="-", linewidth=1, label="total vaccinations")
ax2.plot(np.array(time), total_vaccinations, color="blue", linestyle="-", linewidth=1, label="total vaccination doses")
if not np.isnan(people_fully_vaccinated).all():
ax2.plot(np.array(time), people_fully_vaccinated, color="black", linestyle="-", linewidth=1, label="people fully vaccinated")
immune_mask = ~np.isnan(total_vaccinations) & ~np.isnan(total_cases)
assert len(total_vaccinations) == len(total_cases)
total_immune = np.array(total_vaccinations) + np.array(total_cases)
immune_mask = ~np.isnan(people_fully_vaccinated) & ~np.isnan(total_cases)
assert len(people_fully_vaccinated) == len(total_cases)
total_immune = np.array(people_fully_vaccinated) + np.array(total_cases)
ax2.plot(np.array(time)[immune_mask], total_immune[immune_mask], color="green", linestyle="-", linewidth=1, label="total immune")
ax1.set_ylabel(f"new vaccinations")