move plots to own directory, catch all provided data
This commit is contained in:
60
coronavis.py
60
coronavis.py
@@ -40,6 +40,7 @@ metadata_fields = [
|
||||
"hospital_beds_per_thousand",
|
||||
"life_expectancy",
|
||||
"human_development_index",
|
||||
"tests_units",
|
||||
]
|
||||
|
||||
### manual data
|
||||
@@ -118,12 +119,28 @@ def get_data():
|
||||
new_deaths = tofloat(new_deaths)
|
||||
total_vaccinations = tofloat(total_vaccinations)
|
||||
stringency_index = tofloat(stringency_index)
|
||||
reproduction_rate = tofloat(reproduction_rate)
|
||||
icu_patients = tofloat(icu_patients)
|
||||
hosp_patients = tofloat(hosp_patients)
|
||||
weekly_icu_admissions = tofloat(weekly_icu_admissions)
|
||||
weekly_hosp_admissions = tofloat(weekly_hosp_admissions)
|
||||
new_tests = tofloat(new_tests)
|
||||
total_tests = tofloat(total_tests)
|
||||
positive_rate = tofloat(positive_rate)
|
||||
tests_per_case = tofloat(tests_per_case)
|
||||
|
||||
if location not in data:
|
||||
data[location] = []
|
||||
metadata[location] = {}
|
||||
year, month, day = date.split("-")
|
||||
data[location].append([datetime.date(int(year), int(month), int(day)), new_cases, new_deaths, total_cases, total_deaths, total_vaccinations, stringency_index])
|
||||
|
||||
data[location].append(
|
||||
[datetime.date(int(year), int(month), int(day)),
|
||||
new_cases, new_deaths, total_cases, total_deaths, total_vaccinations,
|
||||
stringency_index, reproduction_rate, icu_patients, hosp_patients,
|
||||
weekly_icu_admissions, weekly_hosp_admissions, new_tests,
|
||||
total_tests, positive_rate, tests_per_case,]
|
||||
)
|
||||
|
||||
|
||||
# catch all data fields
|
||||
#dfields = {field: row[n] for n, field in enumerate(header)}
|
||||
@@ -141,8 +158,18 @@ def get_data():
|
||||
for loc in data:
|
||||
time = []
|
||||
new_cases, new_deaths, total_cases, total_deaths, total_vaccinations, stringency_index = [], [], [], [], [], []
|
||||
reproduction_rate = []
|
||||
icu_patients = []
|
||||
hosp_patients = []
|
||||
weekly_icu_admissions = []
|
||||
weekly_hosp_admissions = []
|
||||
new_tests = []
|
||||
total_tests = []
|
||||
positive_rate = []
|
||||
tests_per_case = []
|
||||
for entry in data[loc]:
|
||||
t_, new_cases_, new_deaths_, total_cases_, total_deaths_, total_vaccinations_, stringency_index_ = entry
|
||||
t_, new_cases_, new_deaths_, total_cases_, total_deaths_, total_vaccinations_, stringency_index_, reproduction_rate_, icu_patients_, hosp_patients_, weekly_icu_admissions_, weekly_hosp_admissions_, new_tests_, total_tests_, positive_rate_, tests_per_case = entry
|
||||
|
||||
time.append(t_)
|
||||
new_cases.append(toint(new_cases_))
|
||||
new_deaths.append(toint(new_deaths_))
|
||||
@@ -150,7 +177,32 @@ def get_data():
|
||||
total_deaths.append(toint(total_deaths_))
|
||||
total_vaccinations.append(toint(total_vaccinations_))
|
||||
stringency_index.append(toint(stringency_index_))
|
||||
data2[loc] = {'time': time, 'new_cases': new_cases, 'new_deaths': new_deaths, 'total_cases': total_cases, 'total_deaths': total_deaths, 'total_vaccinations': total_vaccinations, "stringency_index": stringency_index}
|
||||
reproduction_rate.append(toint(reproduction_rate_))
|
||||
icu_patients.append(toint(icu_patients_))
|
||||
hosp_patients.append(toint(hosp_patients_))
|
||||
weekly_icu_admissions.append(toint(weekly_icu_admissions_))
|
||||
weekly_hosp_admissions.append(toint(weekly_hosp_admissions_))
|
||||
new_tests.append(toint(new_tests_))
|
||||
total_tests.append(toint(total_tests_))
|
||||
positive_rate.append(toint(positive_rate_))
|
||||
tests_per_case.append(toint(tests_per_case_))
|
||||
data2[loc] = {'time': time,
|
||||
'new_cases': new_cases,
|
||||
'new_deaths': new_deaths,
|
||||
'total_cases': total_cases,
|
||||
'total_deaths': total_deaths,
|
||||
'total_vaccinations': total_vaccinations,
|
||||
'stringency_index': stringency_index,
|
||||
'reproduction_rate': reproduction_rate,
|
||||
'icu_patients': icu_patients,
|
||||
'hosp_patients': hosp_patients,
|
||||
'weekly_icu_admissions': weekly_icu_admissions,
|
||||
'weekly_hosp_admissions': weekly_hosp_admissions,
|
||||
'new_tests': new_tests,
|
||||
'total_tests': total_tests,
|
||||
'positive_rate': positive_rate,
|
||||
'tests_per_case': tests_per_case,
|
||||
}
|
||||
return data2, metadata
|
||||
|
||||
data, metadata = get_data()
|
||||
|
||||
Reference in New Issue
Block a user