Skip to content

Commit

Permalink
2020-04-12: new data plus added recovered (o) and fatal cases (*), re…
Browse files Browse the repository at this point in the history
…moved lines with negative markers of data output
  • Loading branch information
koepferl committed Apr 12, 2020
1 parent 7f5de1f commit c59b503
Show file tree
Hide file tree
Showing 104 changed files with 41,603 additions and 18 deletions.
Binary file modified DT_Bavaria.pdf
Binary file not shown.
33 changes: 33 additions & 0 deletions Documentation_COVID19_Local.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"#### Data points\n",
"The data points of the cumulative evolution over time are shown with black + signs. The data was extracted from the online catalog of the Robert-Koch-Institute at https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0?orderBy=IdLandkreis&orderByAsc=false&where=Bundesland%20%3D%20%27Bayern%27 .\n",
"\n",
"After 2020-04-12 also recovered cases (o) and fatal cases (*) added.\n",
"\n",
"#### Fitting \n",
"Once eight data points are available a non-linear least square fit is performed for a specific date. For the following dates also a similar fit is performed also using the eight most recent available data points. In this case the fit is weighted towards the most recent development and is not contaminated by the early evolution with is currently of secondary interest. Fits of early dates are dark blue. Most recent fits are yellow. \n",
"\n",
Expand Down Expand Up @@ -268,6 +270,37 @@
" Compare with https://www.youtube.com/watch?v=54XLXg4fYsc and https://aatishb.com/covidtrends/\n",
"\n",
"\n",
"### Dataset downloaded 2020-04-12\n",
"\n",
"* NEW: Added reported numbers of deaths (*) and recovered cases (o).\n",
"* DT evolution https://github.com/koepferl/COVID19Dahoam/blob/master/DT_Bavaria.pdf: \n",
" Most counties have now higher doubling times (average is 17.69 d), isolation works. Stay put.\n",
" * Counties smaller than 10 days (the larger the better): \n",
" * 5.70 10.4 LK Amberg-Sulzbach\n",
" * 7.47 10.4 SK Amberg\n",
" * 8.85 42 SK Ingolstadt\n",
" * 9.31 10.4 LK Weissenburg-Gunzenhausen\n",
" * 9.47 11.4 LK Traunstein\n",
" * 9.49 11.4 LK Altoetting\n",
" * 9.59 8.4 LK Coburg\n",
" * 9.95 42 SK Ansbach\n",
"\n",
" * Counties larger than 30 days (the larger the better):\n",
" * 39.99 11.4 LK Weilheim-Schongau\n",
" * 33.55 11.4 SK Wuezburg\n",
" * 31.24 10.4 LK Starnberg\n",
" * 30.23 10.4 LK Garmisch-Partenkirchen\n",
"\n",
"\n",
"* Semi-log plots https://github.com/koepferl/COVID19Dahoam/tree/master/plots: \n",
"\n",
" Counties with very low DTs show also no flattening; with high DT almost a horizontal trend.\n",
" \n",
" \n",
"* loglog plot https://github.com/koepferl/COVID19Dahoam/blob/master/loglog_Bavaria.pdf: \n",
"\n",
" The number of total cases until a certain day (y axis) is plotted against the number of new cases in the past week for a certain day (x axis). Once there are fewer new infections the curve will drop downwards. Once this drops steep the uncontroled exponential growth is broken. You can see a beginning trend for with high DTs.\n",
" Compare with https://www.youtube.com/watch?v=54XLXg4fYsc and https://aatishb.com/covidtrends/\n",
"\n",
"More interpretation follows tomorrow.\n",
"\n",
Expand Down
28 changes: 28 additions & 0 deletions Documentation_COVID19_Local_German.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
"#### Datenpunkte\n",
"Die aufsummierte Entwicklung der Fallzahlen (Datenpunkte) wird durch schwarze + gekennzeichnet. Die Daten stammen vom Onlinekathalog des Robert-Koch-Instituts bereitgestelt auf https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0?orderBy=IdLandkreis&orderByAsc=false&where=Bundesland%20%3D%20%27Bayern%27 .\n",
"\n",
"Ab 2020-04-12 auch gemeldte Todeszahlen (*) und gemeldete Genesungszahlen (o).\n",
"\n",
"#### Fit \n",
"Mittels der Methode des nichtlineares Nähern der kleinsten Quadrate werden jeweils acht Datenpunkte benutzt um ein passendes theoretisches Model zu finden. Dies wird für alle paare von acht Datenpunkten wiederholt. Durch die Auswahl von lediglich acht Datenpunkten repräsentiert das genäherte Model stärker die aktuelle Lage und wird wenig von der frühen Entwicklung beeinflusst. Die frühen genäherten Modelle sind dunkelblau und die aktuellsten gelb. \n",
"\n",
Expand Down Expand Up @@ -261,6 +263,32 @@
"\n",
" Die Gesamtzahl der Fallzahlen an einem bestimmten Tag (y Achse) wurde gegen die Fallzahlen der letzten Woche für diesen Tag (x Achse) aufgetragen. Sobald es weniger Infektionen gibt fällt die Kurve ab. Ein besonders starker abfall wird erwartet, wenn das uncontrollierte exponentielle Wachstum beendet ist. Man sieht schon einen beginnenden Trend für Kreise mit sehr hohen DTs.\n",
" Siehe auch https://www.youtube.com/watch?v=54XLXg4fYsc and https://aatishb.com/covidtrends/\n",
" \n",
"\n",
"### Datendownload 2020-04-12\n",
"\n",
"* NEU: Gemeldete Todesfälle (*) und gemeldete Genesene (o) mit im semi-log plot.\n",
"* DT Entwicklung https://github.com/koepferl/COVID19Dahoam/blob/master/DT_Bavaria.pdf: \n",
" Die meisten Kreisen haben höhere Verdopplungszeiten (Durchschnitt ist 17.69 Tage), Isolation funktioniert. Bleibt dahoam.\n",
" * Kreise mit Verdopplungszeiten (DT) kleiner als 10 Tage (je länge desto besser): \n",
" * 5.75d 8.4 SK Amberg\n",
" * 5.79d 9.4 LK Amberg-Sulzbach\n",
" * 6.23d 9.4 SK Ansbach\n",
" * 7.06d 9.4 SK Ingolstadt\n",
" * Kreise mit Verdopplungszeiten (DT) größer als 30 Tage (je länge desto besser):\n",
" * 35.45d 9.4 LK Starnberg\n",
" * 32.70d 9.4 LK Weilheim-Schongau\n",
" * 30.97d 9.4 SK Muenchen\n",
" \n",
"* Semi-log plots https://github.com/koepferl/COVID19Dahoam/tree/master/plots: \n",
"\n",
" Kreise mit sehr niedrigen DTs werden nicht/kaum flacher; mit sehr großen DTs ist der Verlauf fast horizontal. \n",
" \n",
" \n",
"* loglog plot https://github.com/koepferl/COVID19Dahoam/blob/master/loglog_Bavaria.pdf: \n",
"\n",
" Die Gesamtzahl der Fallzahlen an einem bestimmten Tag (y Achse) wurde gegen die Fallzahlen der letzten Woche für diesen Tag (x Achse) aufgetragen. Sobald es weniger Infektionen gibt fällt die Kurve ab. Ein besonders starker abfall wird erwartet, wenn das uncontrollierte exponentielle Wachstum beendet ist. Man sieht schon einen beginnenden Trend für Kreise mit sehr hohen DTs.\n",
" Siehe auch https://www.youtube.com/watch?v=54XLXg4fYsc and https://aatishb.com/covidtrends/\n",
"\n",
"Mehr Diskussion folgt morgen.\n",
"\n",
Expand Down
55 changes: 39 additions & 16 deletions cov19_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def load_RKI(filename, LandkreisID, state_name ='Bavaria'):
return
======
fall : np.array
Cumulative number of cases
dic : dictionary {'fall': array, 'tod':array, 'gesund': array}
Array of cumulative number of cases
uday : np.array
Individual days of notification to the RKI
Expand All @@ -47,16 +47,21 @@ def load_RKI(filename, LandkreisID, state_name ='Bavaria'):
daten_RKI = np.loadtxt(filename,
skiprows=1,
delimiter=',',
usecols=(9,2,8,5,6),
dtype={'names': ('lkID', 'lk_name', 'datum', 'fall', 'tod'), 'formats': ( 'S6', 'S40', 'S10', 'i4', 'i4')})
usecols=(9,2,8,5,6,-1),
dtype={'names': ('lkID', 'lk_name', 'datum', 'fall', 'tod', 'gesund'), 'formats': ( 'S6', 'S40', 'S10', 'i4', 'i4', 'i4')})


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

for dat in dat_state:
case_state.append(np.sum(daten_RKI['fall'][daten_RKI['datum'] == dat]))
case_state_dat = daten_RKI['fall'][daten_RKI['datum'] == dat]
#tod_state_dat = daten_RKI['tod'][daten_RKI['datum'] == dat]
#gesund_state_dat = daten_RKI['gesund'][daten_RKI['datum'] == dat]
case_state.append(np.sum(case_state_dat[case_state_dat > 0]))
num_state = np.cumsum(np.array(case_state))

# select unique region
Expand Down Expand Up @@ -100,8 +105,8 @@ def load_RKI(filename, LandkreisID, state_name ='Bavaria'):

# sum up unique dates
from astropy.table import Table
RKI_tab = Table([daten_RKI['datum'], year, month, day, daten_RKI['fall'], daten_RKI['tod']],
names=('datum', 'year', 'month', 'day', 'fall', 'tod'))
RKI_tab = Table([daten_RKI['datum'], year, month, day, daten_RKI['fall'], daten_RKI['tod'], daten_RKI['gesund']],
names=('datum', 'year', 'month', 'day', 'fall', 'tod', 'gesund'))

#print RKI_tab

Expand All @@ -110,25 +115,37 @@ def load_RKI(filename, LandkreisID, state_name ='Bavaria'):
umonth = np.zeros(shape=udate.shape)
uyear = np.zeros(shape=udate.shape)
ufall = np.zeros(shape=udate.shape)
utod = np.zeros(shape=udate.shape)
ugesund = np.zeros(shape=udate.shape)

#print RKI_tab['datum']

for i in range(len(udate)):
cond = (RKI_tab['datum'] == udate[i])
#print udate[i]
#print RKI_tab[cond]
ufall[i] = np.sum(RKI_tab['fall'][cond])

fall_day = RKI_tab['fall'][cond]
#print fall_day[fall_day < 0]
ufall[i] = np.sum(fall_day[fall_day > 0])

tod_day = RKI_tab['tod'][cond]
utod[i] = np.sum(tod_day[tod_day > 0])
#print tod_day[tod_day < 0]

gesund_day = RKI_tab['gesund'][cond]
ugesund[i] = np.sum(gesund_day[gesund_day > 0])
#print gesund_day[gesund_day < 0]

uday[i] = RKI_tab['day'][cond][0]
umonth[i] = RKI_tab['month'][cond][0]
uyear[i] = RKI_tab['year'][cond][0]

return np.cumsum(ufall), uday, umonth, region_name, dic_LK, [num_state, dat_state, state_name]#, uyear, udate
return {'fall': np.cumsum(ufall), 'tod': np.cumsum(utod), 'gesund':np.cumsum(ugesund)}, uday, umonth, region_name, dic_LK, [num_state, dat_state, state_name]#, uyear, udate

##################################################################################################
# Logarithmic Plot of Cumulative Cases (Logarithmische Darstellung der aufsummierten Fallzahlen) #
##################################################################################################

def plot_corona(num, day, month, name, geraet_min=None, geraet_max=None, anteil_beatmung=0.05):
def plot_corona(num_dic, day, month, name, geraet_min=None, geraet_max=None, anteil_beatmung=0.05):
'''
Plots cumulative case numbers against time for the specific county. Fits for any dataset
larger than eight a exponential function and estimates the doubling time. For the fit only
Expand All @@ -141,8 +158,8 @@ def plot_corona(num, day, month, name, geraet_min=None, geraet_max=None, anteil_
Input
=====
num : np.array
Cumulative number of cases.
num_dic : dictionary {'fall': array, 'tod':array, 'gesund': array}
Array of cumulative number of cases
day : np.array
String with 5 number entries to select the specific county.
Expand Down Expand Up @@ -183,9 +200,13 @@ def plot_corona(num, day, month, name, geraet_min=None, geraet_max=None, anteil_
print name
print '-' * 30

num = num_dic['fall']
num_tod = num_dic['tod']
num_gesund = num_dic['gesund']

fig, ax = plt.subplots(figsize=(10,8))
plt.title(name)
ax.axis([13, 50, 1, 1e5])
ax.axis([13, 50, 0.9, 1e5])

####
# move to March time frame
Expand Down Expand Up @@ -304,7 +325,9 @@ def func(x, a, b):#, c):
####
# gemeldete Fallzahlen
#########
plt.semilogy(day, num, 'k+', label="Daten")
plt.semilogy(day, num, 'k+', label="COVID19 erkrankt")
plt.semilogy(day, num_tod, 'k*', label="davon verstorben")
plt.semilogy(day, num_gesund, 'ko', alpha=0.3, label="davon genesen")


#############
Expand Down
Loading

0 comments on commit c59b503

Please sign in to comment.