Skip to content

Commit

Permalink
2020-04-04: new plots included Bavarian average to the DT plots and f…
Browse files Browse the repository at this point in the history
…ixed April formatting on log plot
  • Loading branch information
koepferl committed Apr 4, 2020
1 parent 79e6d13 commit 7fcf532
Show file tree
Hide file tree
Showing 102 changed files with 103 additions and 14 deletions.
Binary file removed DT.pdf
Binary file not shown.
Binary file added DT_Bavaria.pdf
Binary file not shown.
21 changes: 18 additions & 3 deletions Documentation_COVID19_Local.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
"This is currently work in progress before using convince yourself that the analysis and numbers are correct. No guarantee is given.\n",
"\n",
"#### Credit\n",
"When using this dataset or code please reference accordingly: <a href=\"https://zenodo.org/badge/latestdoi/252294531\"><img src=\"https://zenodo.org/badge/252294531.svg\" alt=\"DOI\"></a>\n",
"When using this dataset or code please reference accordingly: \n",
"\n",
"<a href=\"https://zenodo.org/badge/latestdoi/252294531\"><img src=\"Release 2020-04-02 https://zenodo.org/badge/252294531.svg\" alt=\"DOI\"></a>\n",
"\n",
"\n",
"* Christine Greif http://www.usm.uni-muenchen.de/~koepferl\n",
"* Images are licensed under CC-BY-SA 4.0\n",
"* Data source: NPGEO-DE\n",
Expand Down Expand Up @@ -102,9 +106,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"=> see ``DT.pdf`` on https://github.com/koepferl/COVID19Dahoam/blob/master/DT.pdf \n",
"=> see ``DT_Bavaria.pdf`` on https://github.com/koepferl/COVID19Dahoam/blob/master/DT_Bavaria.pdf \n",
"\n",
"![title](DT.pdf)"
"![title](DT_Bavaria.pdf)"
]
},
{
Expand All @@ -125,6 +129,17 @@
"\n",
"However I need to emphasize that even though an improve in the doubling times and a turn over in case numbers in the logarithmic plot is visible (e. g. LK Miesbach), still the capacities of the local hospital facilities are limited. \n",
"\n",
"### Dataset downloaded 2020-04-04\n",
"\n",
"* News: I included the average of the State Bavaria in the DT_Bavaria.pdf. Everything above that average doubling time is encouraging. For the counties below, the situation is not as good. Unfortunately some counties are lacking behind in their data transmission, or correcting some numbers afterwards, this is why there might be still some fluctuation (see above).\n",
"* Semi-log plot: Many counties show flattening now. No flattening can be seen in:\n",
" * Conties with no flattening: SK Amberg, SK Ansbach, SK Hof, SK Kempten\n",
" * Counties with steeper slopes (!!!): LK Amberg-Sulzbach, LK Donau-Ries, LK Erlangen-Hoechstadt, LK Regen, LK Straubing-Bogen, SK Erlangen, SK Straubing, SK Weiden i.d.OPf. \n",
"* DT evolution: \n",
" * Most counties move towards the 8 day margin, however there are still many with relative low doubling times (the lower the DT, the faster the spread of COVID19). \n",
" * Counties larger smaller than 5 days: SK Ingolstadt, SK Amberg, LK Straubing-Bogen, LK Neustadt a.d.Waldnaab, LK Donau-Ries, LK Amberg-Sulzbach \n",
"* Task: Find reliable numbers of the ventilation capacities in as many counties as possible to populate the traffic light estimation (e.g. LK Miesbach).\n",
"\n",
"More interpretation follows tomorrow.\n",
"\n",
"## Recommendation\n",
Expand Down
19 changes: 15 additions & 4 deletions Documentation_COVID19_Local_German.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
"Es handelt sich hier um Analysen an einem täglich ändernden Datensatz. Bevor die Erkenntnisse dieser Arbeit zur Anwendung kommen, muss der Benutzer sich klar gemacht haben, dass die Datensatz und Analysen korrekt sind. Es wird keine Garantie jedweder Art gegeben. \n",
"\n",
"#### Copyright\n",
"Bei Anwendung der Abbildungen oder Software bitte folgende Referenzen angeben: \n",
"<a href=\"https://zenodo.org/badge/latestdoi/252294531\"><img src=\"https://zenodo.org/badge/252294531.svg\" alt=\"DOI\"></a>\n",
"Bei Anwendung der Abbildungen oder Software bitte folgende Referenzen angeben:\n",
"\n",
"Release 2020-04-02 <a href=\"https://zenodo.org/badge/latestdoi/252294531\"><img src=\"https://zenodo.org/badge/252294531.svg\" alt=\"DOI\"></a>\n",
"* Christine Greif http://www.usm.uni-muenchen.de/~koepferl\n",
"* Abbildungen fallen unter die Lizenz CC-BY-SA 4.0\n",
"* Datenquelle: NPGEO-DE\n",
Expand Down Expand Up @@ -100,9 +101,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"=> siehe ``DT.pdf`` auf https://github.com/koepferl/COVID19Dahoam/blob/master/DT.pdf \n",
"=> siehe ``DT_Bavaria.pdf`` auf https://github.com/koepferl/COVID19Dahoam/blob/master/DT_Bavaria.pdf \n",
"\n",
"![title](DT.pdf)"
"![title](DT_Bavaria.pdf)"
]
},
{
Expand All @@ -123,6 +124,16 @@
"\n",
"Es muss betont werden, dass obwohl sich die Verlangsamung der Fallzahlen auch lokal erkennen lassen (Abknicken, höher Verdopplungszeiten), kann dennoch das Gesundheitsgefüge im einen oder anderen Kreis an seine Grenzen stoßen (siehe exemplarisch Darstellung für den LK Miesbach). \n",
"\n",
"### Datendownload 2020-04-04\n",
"* Neu: Nun ist die durchschnittliche Verdopplungszeit für Bayern auch eingetragen. Kreis darüber sind auf einen sehr guten Weg, Kreise darunter müssen noch zulegen. Leider sind von einigen Kreisen die Zahlen noch nicht übermittelt worden und einige werden sicher wieder korregieren oder nachmelden. Deshalb kann es auch noch zu Fluktuationen kommen (siehe oben). \n",
"* Logarithmisches Diagramm: Viele Kreise zeigen nun ein Abflachen exponentiellen Entwicklung. Leider kein Abflachen in folgenden Kreisen:\n",
" * Kein Abflachen: SK Amberg, SK Ansbach, SK Hof, SK Kempten\n",
" * Ansteigen (!!!): LK Amberg-Sulzbach, LK Donau-Ries, LK Erlangen-Hoechstadt, LK Regen, LK Straubing-Bogen, SK Erlangen, SK Straubing, SK Weiden i.d.OPf. \n",
"* Entwicklung der Verdopplungszeiten (um so höher, umso besser): \n",
" * Die meisten Kreise haben bewegen sich auf die 8 Tage Marke zu, aber es gibt immer noch einige mit relativ kleinen Verdopplungszeiten (um so kleiner, umso schneller verbreitet sich COVID19). \n",
" * Kreise kleiner als 5 Tage: SK Ingolstadt, SK Amberg, LK Straubing-Bogen, LK Neustadt a.d.Waldnaab, LK Donau-Ries, LK Amberg-Sulzbach \n",
"* Aufgabe: Finde verlässliche Zahlen für die Beatmungsgerätkapazitäten für möglichst viele Landkreise um die Ampel-Darstellung zu vervollständigen (e.g. LK Miesbach).\n",
"\n",
"Mehr Diskussion folgt morgen.\n",
"\n",
"## Handlungsempfehlung\n",
Expand Down
75 changes: 69 additions & 6 deletions cov19_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Load of Input Data (Daten laden) #
####################################

def load_RKI(filename, LandkreisID):
def load_RKI(filename, LandkreisID, state_name ='Bavaria'):
'''
Reads file of the RKI database and selects the relevant data for the specific county.
Expand All @@ -17,6 +17,9 @@ def load_RKI(filename, LandkreisID):
LandkreisID : str
String with 5 number entries to select the specific county.
state_name : str, default = 'Bavaria'
Name of the state.
return
======
Expand All @@ -35,6 +38,9 @@ def load_RKI(filename, LandkreisID):
dic_LK : dict={'name', 'ID'}
Alphabetical sorted names of counties and corresponding IDs
state : li[dat_state, num_state, name_state]
List of dates, cumulative case numbers and state name
'''

import numpy as np
Expand All @@ -45,6 +51,14 @@ def load_RKI(filename, LandkreisID):
dtype={'names': ('lkID', 'lk_name', 'datum', 'fall', 'tod'), 'formats': ( 'S6', 'S40', 'S10', 'i4', 'i4')})


# state average
dat_state = np.unique(daten_RKI['datum'])
case_state = []

for dat in dat_state:
case_state.append(np.sum(daten_RKI['fall'][daten_RKI['datum'] == dat]))
num_state = np.cumsum(np.array(case_state))

# select unique region
indexes = np.unique(daten_RKI['lkID'], return_index=True)[1]
uID = daten_RKI['lkID'][indexes]
Expand Down Expand Up @@ -108,7 +122,7 @@ def load_RKI(filename, LandkreisID):
umonth[i] = RKI_tab['month'][cond][0]
uyear[i] = RKI_tab['year'][cond][0]

return np.cumsum(ufall), uday, umonth, region_name, dic_LK#, uyear, udate
return np.cumsum(ufall), uday, umonth, region_name, dic_LK, [num_state, dat_state, state_name]#, uyear, udate

##################################################################################################
# Logarithmic Plot of Cumulative Cases (Logarithmische Darstellung der aufsummierten Fallzahlen) #
Expand Down Expand Up @@ -176,6 +190,7 @@ def plot_corona(num, day, month, name, geraet_min=None, geraet_max=None, anteil_
####
# move to March time frame
#########
day_real = np.copy(day)
day[month == 2] = day[month == 2] - 29
day[month == 1] = day[month == 1] - 29 - 31
day[month == 4] = day[month == 4] + 31
Expand Down Expand Up @@ -228,8 +243,9 @@ def func(x, a, b):#, c):
########
# plot fit
#########
day_label = 'Fit am ' + str(int(day_real[cut-1])) + '.' + str(int(month[cut-1]))
plt.semilogy(x, func(x, *popt), '-', color=plt.cm.viridis(int(col)),
label='Fit am ' + str(int(day[cut-1])) + '.3')
label=day_label)

colapp.append(int(col))
col = col + 256 / len(data_points)
Expand Down Expand Up @@ -310,7 +326,7 @@ def func(x, a, b):#, c):
# Doubeling Time (Verdopplungszeit) #
#####################################

def plot_DT(DT, ncol=4, nrow=3):
def plot_DT(DT, state, ncol=4, nrow=3):
'''
Plots day-dependent doubling time against time for the selected counties.
Expand All @@ -330,6 +346,9 @@ def plot_DT(DT, ncol=4, nrow=3):
val_DT : list
list containing the calculated day-depending doubling times
state : list
output from load_RKI
ncol : int
Number of columns in plot (should not be changed for now.)
Expand All @@ -342,7 +361,48 @@ def plot_DT(DT, ncol=4, nrow=3):
Saves diagram as PDF.
'''

######################################
# DT for state
#######################

####
# move to March time frame
#########

dat_states = state[1]

state_day = []
for i in range(len(dat_states)):
y, m, d = dat_states[i].split('-')
if m == '01': state_day.append(int(d) - 29 - 31)
if m == '02': state_day.append(int(d) - 29)
if m == '03': state_day.append(int(d))
if m == '04': state_day.append(int(d) + 31)

#########
# fit
#########
def func(x, a, b):#, c):
return a * np.exp(b * x)# + c
#return a * b**(c*x)

x = np.arange(10,40,0.5)

# fit only when there are more than 8 data points and cases every day.
data_points = range(8, len(state_day)+1)
state_day = np.array(state_day)
state_num = np.array(state[0])
DTs_state = []

from scipy.optimize import curve_fit
for cut in data_points:
popt, pcov = curve_fit(func, state_day[cut-8:cut], state_num[cut-8:cut])

#########
# doubling time
#########
DT_state = np.round(np.log(2) / popt[1],2)
DTs_state.append(DT_state)

fig, axs = plt.subplots(nrow, ncol, figsize=(28,21))
plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=0.05, hspace=0.05)
Expand Down Expand Up @@ -430,7 +490,10 @@ def plot_DT(DT, ncol=4, nrow=3):
line_col = 20 + 30 * (96 - i)

key = sorted_keys[i]
if i in [0, 8 ,16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]:
ax.plot(state_day[7:], DTs_state, '.:k', label= state[2] + ' average')
ax.plot(DT[key][1], DT[key][2], '.-', c = cmap(line_col), label=DT[key][0])


######
# axis
Expand Down Expand Up @@ -461,4 +524,4 @@ def plot_DT(DT, ncol=4, nrow=3):
ax.text(31, -0.9, 'April')

#plt.show()
fig.savefig('DT.pdf', dpi=300, overwrite=True, bbox_inches='tight')
fig.savefig('DT_' + state[2] + '.pdf', dpi=300, overwrite=True, bbox_inches='tight')
Binary file modified plots/LK Aichach-Friedberg.pdf
Binary file not shown.
Binary file modified plots/LK Altoetting.pdf
Binary file not shown.
Binary file modified plots/LK Amberg-Sulzbach.pdf
Binary file not shown.
Binary file modified plots/LK Ansbach.pdf
Binary file not shown.
Binary file modified plots/LK Aschaffenburg.pdf
Binary file not shown.
Binary file modified plots/LK Augsburg.pdf
Binary file not shown.
Binary file modified plots/LK Bad Kissingen.pdf
Binary file not shown.
Binary file modified plots/LK Bad Toelz-Wolfratshausen.pdf
Binary file not shown.
Binary file modified plots/LK Bamberg.pdf
Binary file not shown.
Binary file modified plots/LK Bayreuth.pdf
Binary file not shown.
Binary file modified plots/LK Berchtesgadener Land.pdf
Binary file not shown.
Binary file modified plots/LK Cham.pdf
Binary file not shown.
Binary file modified plots/LK Coburg.pdf
Binary file not shown.
Binary file modified plots/LK Dachau.pdf
Binary file not shown.
Binary file modified plots/LK Deggendorf.pdf
Binary file not shown.
Binary file modified plots/LK Dillingen a.d.Donau.pdf
Binary file not shown.
Binary file modified plots/LK Dingolfing-Landau.pdf
Binary file not shown.
Binary file modified plots/LK Donau-Ries.pdf
Binary file not shown.
Binary file modified plots/LK Ebersberg.pdf
Binary file not shown.
Binary file modified plots/LK Eichstaett.pdf
Binary file not shown.
Binary file modified plots/LK Erding.pdf
Binary file not shown.
Binary file modified plots/LK Erlangen-Hoechstadt.pdf
Binary file not shown.
Binary file modified plots/LK Forchheim.pdf
Binary file not shown.
Binary file modified plots/LK Freising.pdf
Binary file not shown.
Binary file modified plots/LK Freyung-Grafenau.pdf
Binary file not shown.
Binary file modified plots/LK Fuestenfeldbruck.pdf
Binary file not shown.
Binary file modified plots/LK Fueth.pdf
Binary file not shown.
Binary file modified plots/LK Garmisch-Partenkirchen.pdf
Binary file not shown.
Binary file modified plots/LK Guenzburg.pdf
Binary file not shown.
Binary file modified plots/LK Hassberge.pdf
Binary file not shown.
Binary file modified plots/LK Hof.pdf
Binary file not shown.
Binary file modified plots/LK Kelheim.pdf
Binary file not shown.
Binary file modified plots/LK Kitzingen.pdf
Binary file not shown.
Binary file modified plots/LK Kronach.pdf
Binary file not shown.
Binary file modified plots/LK Kulmbach.pdf
Binary file not shown.
Binary file modified plots/LK Landsberg a.Lech.pdf
Binary file not shown.
Binary file modified plots/LK Landshut.pdf
Binary file not shown.
Binary file modified plots/LK Lichtenfels.pdf
Binary file not shown.
Binary file modified plots/LK Lindau.pdf
Binary file not shown.
Binary file modified plots/LK Main-Spessart.pdf
Binary file not shown.
Binary file modified plots/LK Miesbach.pdf
Binary file not shown.
Binary file modified plots/LK Miltenberg.pdf
Binary file not shown.
Binary file modified plots/LK Muehldorf a.Inn.pdf
Binary file not shown.
Binary file modified plots/LK Muenchen.pdf
Binary file not shown.
Binary file modified plots/LK Neu-Ulm.pdf
Binary file not shown.
Binary file modified plots/LK Neuburg-Schrobenhausen.pdf
Binary file not shown.
Binary file modified plots/LK Neumarkt i.d.OPf..pdf
Binary file not shown.
Binary file modified plots/LK Neustadt a.d.Aisch-Bad Windsheim.pdf
Binary file not shown.
Binary file modified plots/LK Neustadt a.d.Waldnaab.pdf
Binary file not shown.
Binary file modified plots/LK Nuenberger Land.pdf
Binary file not shown.
Binary file modified plots/LK Oberallgaeu.pdf
Binary file not shown.
Binary file modified plots/LK Ostallgaeu.pdf
Binary file not shown.
Binary file modified plots/LK Passau.pdf
Binary file not shown.
Binary file modified plots/LK Pfaffenhofen a.d.Ilm.pdf
Binary file not shown.
Binary file modified plots/LK Regen.pdf
Binary file not shown.
Binary file modified plots/LK Regensburg.pdf
Binary file not shown.
Binary file modified plots/LK Rhoen-Grabfeld.pdf
Binary file not shown.
Binary file modified plots/LK Rosenheim.pdf
Binary file not shown.
Binary file modified plots/LK Roth.pdf
Binary file not shown.
Binary file modified plots/LK Rottal-Inn.pdf
Binary file not shown.
Binary file modified plots/LK Schwandorf.pdf
Binary file not shown.
Binary file modified plots/LK Schweinfurt.pdf
Binary file not shown.
Binary file modified plots/LK Starnberg.pdf
Binary file not shown.
Binary file modified plots/LK Straubing-Bogen.pdf
Binary file not shown.
Binary file modified plots/LK Tirschenreuth.pdf
Binary file not shown.
Binary file modified plots/LK Traunstein.pdf
Binary file not shown.
Binary file modified plots/LK Unterallgaeu.pdf
Binary file not shown.
Binary file modified plots/LK Weilheim-Schongau.pdf
Binary file not shown.
Binary file modified plots/LK Weissenburg-Gunzenhausen.pdf
Binary file not shown.
Binary file modified plots/LK Wuezburg.pdf
Binary file not shown.
Binary file modified plots/LK Wunsiedel i.Fichtelgebirge.pdf
Binary file not shown.
Binary file modified plots/SK Amberg.pdf
Binary file not shown.
Binary file modified plots/SK Ansbach.pdf
Binary file not shown.
Binary file modified plots/SK Aschaffenburg.pdf
Binary file not shown.
Binary file modified plots/SK Augsburg.pdf
Binary file not shown.
Binary file modified plots/SK Bamberg.pdf
Binary file not shown.
Binary file modified plots/SK Bayreuth.pdf
Binary file not shown.
Binary file modified plots/SK Coburg.pdf
Binary file not shown.
Binary file modified plots/SK Erlangen.pdf
Binary file not shown.
Binary file modified plots/SK Fueth.pdf
Binary file not shown.
Binary file modified plots/SK Hof.pdf
Binary file not shown.
Binary file modified plots/SK Ingolstadt.pdf
Binary file not shown.
Binary file modified plots/SK Kaufbeuren.pdf
Binary file not shown.
Binary file modified plots/SK Kempten.pdf
Binary file not shown.
Binary file modified plots/SK Landshut.pdf
Binary file not shown.
Binary file modified plots/SK Memmingen.pdf
Binary file not shown.
Binary file modified plots/SK Muenchen.pdf
Binary file not shown.
Binary file modified plots/SK Nuenberg.pdf
Binary file not shown.
Binary file modified plots/SK Passau.pdf
Binary file not shown.
Binary file modified plots/SK Regensburg.pdf
Binary file not shown.
Binary file modified plots/SK Rosenheim.pdf
Binary file not shown.
Binary file modified plots/SK Schwabach.pdf
Binary file not shown.
Binary file modified plots/SK Schweinfurt.pdf
Binary file not shown.
Binary file modified plots/SK Straubing.pdf
Binary file not shown.
Binary file modified plots/SK Weiden i.d.OPf..pdf
Binary file not shown.
Binary file modified plots/SK Wuezburg.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
geraet_min=kapazitaet[0], geraet_max=kapazitaet[1], anteil_beatmung=0.05)

# doubeling time plot - Verdopplungszeitdiagramm
plot_DT(DT)
plot_DT(DT, state)

0 comments on commit 7fcf532

Please sign in to comment.