Fix vaccination numbers by filling voids, move data to subfolder
This commit is contained in:
@@ -19,7 +19,8 @@ corr = {"Chile": 10000,
|
|||||||
"Peru": 10000,
|
"Peru": 10000,
|
||||||
"Bolivia": 3000,
|
"Bolivia": 3000,
|
||||||
"Yemen": 220,
|
"Yemen": 220,
|
||||||
"Turkey": 100000,
|
"Turkey": 40000,
|
||||||
|
"Spain": 30000,
|
||||||
}
|
}
|
||||||
|
|
||||||
def plot(data, countries, pop, **kwargs):
|
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, 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)
|
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")
|
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")
|
ax2.plot(time, np.array(total_vaccinations), label=f"Total vaccinations", marker="", linestyle="-.", color="crimson")
|
||||||
|
|
||||||
# fix lower bound of plot
|
# fix lower bound of plot
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ def get_data():
|
|||||||
dataurl = "https://covid.ourworldindata.org/data/owid-covid-data.csv"
|
dataurl = "https://covid.ourworldindata.org/data/owid-covid-data.csv"
|
||||||
date = datetime.date.today()
|
date = datetime.date.today()
|
||||||
|
|
||||||
datafile = f"{date}-full-data.csv"
|
datafile = f"data/{date}-full-data.csv"
|
||||||
|
|
||||||
if not os.path.isfile(datafile):
|
if not os.path.isfile(datafile):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user