From e2bcf7329f8c3844139e3b6e5574b0538639114a Mon Sep 17 00:00:00 2001 From: fordprefect Date: Mon, 21 Dec 2020 11:07:34 +0100 Subject: [PATCH] Fix vaccination numbers by filling voids, move data to subfolder --- all_countries.py | 12 ++++++++++-- coronavis.py | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/all_countries.py b/all_countries.py index 805bd08..264b139 100644 --- a/all_countries.py +++ b/all_countries.py @@ -19,7 +19,8 @@ corr = {"Chile": 10000, "Peru": 10000, "Bolivia": 3000, "Yemen": 220, - "Turkey": 100000, + "Turkey": 40000, + "Spain": 30000, } def plot(data, countries, pop, **kwargs): @@ -45,8 +46,15 @@ def plot(data, countries, pop, **kwargs): ax1.plot(time, new_cases, label="raw new cases", color="grey", linestyle="-") ax1.plot(time[3:-3], np.convolve(new_cases, np.ones((7,))/7, mode="valid"), label="new cases 7day mean", color="orange", linestyle="-", linewidth=2) - if not np.isnan(total_vaccinations[-1]): + # plot vaccinations + if not np.isnan(total_vaccinations).all() : print(f"{loc} has vaccines, adding to plot") + + # fix data: not all countries report daily + for n in range(1, len(total_vaccinations)): + if np.isnan(total_vaccinations[n]) and not np.isnan(total_vaccinations[n-1]): + total_vaccinations[n] = total_vaccinations[n-1] + ax2.plot(time, np.array(total_vaccinations), label=f"Total vaccinations", marker="", linestyle="-.", color="crimson") # fix lower bound of plot diff --git a/coronavis.py b/coronavis.py index 04aa98d..aaacc94 100644 --- a/coronavis.py +++ b/coronavis.py @@ -70,7 +70,7 @@ def get_data(): dataurl = "https://covid.ourworldindata.org/data/owid-covid-data.csv" date = datetime.date.today() - datafile = f"{date}-full-data.csv" + datafile = f"data/{date}-full-data.csv" if not os.path.isfile(datafile):