Exemplo n.º 1
0
def fit_lockdown(region, name, plot = True):
    fit_deaths = lockdown.Fitter(deaths[region].sum(axis=1), '2020-03-19', 21)
    fit_adm = lockdown.Fitter(admissions[region].sum(axis=1), '2020-03-19', 13)
    fit_rea = lockdown.Fitter(reanimations[region].sum(axis=1), '2020-03-19', 15)
    
    if plot:
        plt.figure(dpi = 200, figsize = (10,4))
        axes = plt.axes()
        axes.set_yscale('log')
    
    for (i, fit) in enumerate([fit_adm, fit_rea, fit_deaths]):
        fit.fit_lockdown('2020-05-13')
#        fit.plot_fit()
#        fit.axes.set_title(data_names[i])
        if plot:
            p = axes.plot(fit.data['daily'], label = 'new ' + data_names[i] + ' ($r_E$ = %.3f)' % fit.rE)
            axes.plot(fit.index_lockdown, fit.best_fit_lock_daily(), linestyle = 'dashdot', color = p[0].get_color())
        print(name + ', ' + data_names[i] + ', rE = %.3f' % fit.rE)
    
    if plot:
        axes.set_xticks(fit.data.index[0::7])
        axes.set_xticklabels(fit.data.index[0::7])
        axes.legend(loc='best')
        axes.set_title('Decrease in hospital deaths, hospital admissions and\nICU admissions in ' + name + ' under lockdown')
Exemplo n.º 2
0
         "Provence Alpes Cote d'Azur", 'Occitanie', 'Loire Atlantique',  
         'Centre Val de Loire', 'Nouvelle Aquitaine', 'Bourgogne Franche Comté', 'Bretagne', 'Normandie', 'Corse']
colors = [cm.tab20(x) for x in np.tile(np.linspace(0,1,10,endpoint=False), 2)]
colors_fits = [cm.tab20(x + .05) for x in np.tile(np.linspace(0,1,10,endpoint=False),2)]

deaths_France = deaths.sum(axis=1)
deaths_France = pd.DataFrame(deaths_France, columns = ['deces'])
#deaths_France = pd.concat((deaths_early['2020-02-15':'2020-03-17'], deaths_France), axis = 0)


data_names = ['hospital admissions', 'ICU admissions', 'hospital deaths']

ad_France = admissions.sum(axis = 1)
rea_France = reanimations.sum(axis = 1)

fit_d_France = lockdown.Fitter(deaths_France, '2020-03-19', 21)

fit_ad_france = lockdown.Fitter(ad_France, '2020-03-19', 13)

fit_rea_france = lockdown.Fitter(rea_France, '2020-03-19', 15)

plt.figure(dpi=200, figsize = (10,4))
axes = plt.axes()
axes.set_yscale('log')

for (i, fit) in enumerate([fit_ad_france, fit_rea_france, fit_d_France]):
    fit.fit_lockdown('2020-05-13')
    p = axes.plot(fit.data['daily'], label = 'new ' + data_names[i] + ' ($r_E$ = %.3f)' % fit.rE)
    axes.plot(fit.index_lockdown, fit.best_fit_lock_daily(), linestyle = 'dashdot', color = p[0].get_color())

axes.set_xticks(fit_d_France.data.index[0::7])
Exemplo n.º 3
0
    'Green areas excluding Corsica'
]
colors = [
    cm.tab20(x) for x in np.tile(np.linspace(0, 1, 10, endpoint=False), 2)
]
colors_fits = [
    cm.tab20(x + .05)
    for x in np.tile(np.linspace(0, 1, 10, endpoint=False), 2)
]

deaths_France = deaths.sum(axis=1)
deaths_France = pd.DataFrame(deaths_France, columns=['deces'])
deaths_France = pd.concat(
    (deaths_early['2020-02-15':'2020-03-17'], deaths_France), axis=0)

fit_France = lockdown.Fitter(deaths_France, '2020-03-17', 25)
fit_France.fit_init('2020-03-01', '2020-03-24')

plt.figure(dpi=200)
axes = plt.axes()
axes.set_ylabel('Cumulative number of deaths')
axes.set_title('Growth rate during the early phase of the epidemic')

axes.plot(fit_France.data['cumul'],
          label='Mainland France (r = %.2f)' % fit_France.r,
          color=colors[0])
axes.set_xticks(fit_France.data.index[0::9])
axes.set_xticklabels(fit_France.data.index[0::9])
axes.set_yscale('log')
n = np.size(fit_France.index_init)
y = np.exp(fit_France.regression_init.intercept + fit_France.r * np.arange(n))
fit.fit_init('2020-03-01', '2020-03-24')

fit.fit_lockdown('2020-05-10')

fit.plot_fit()
fit.axes.set_title('Cumulative and daily hospital deaths in mainland France')

#fit.compute_SIR(3.5, N_france, 60)
#fit.plot_SIR()
'''

IdF = deaths[GrandEst].sum(axis=1)
IdF = pd.DataFrame(IdF, columns=['deces'])
#IdF['daily'] = np.concatenate(([0], np.diff(IdF['deces'])))

fit_idf = lockdown.Fitter(IdF, '2020-03-16', 21)

fit_idf.fit_init('2020-03-19', '2020-03-26')
fit_idf.fit_lockdown('2020-05-13')

#fit_idf.plot_fit()
#fit_idf.axes.set_title('Cumulative and daily hospital deaths in Ile de France')

lockdown_length = 55
R0_after = 1.2
f = .005
#delays = np.array([[21, 1]])
#delays = np.array([[12, .17], [14.5, .18], [15, .19], [17.5, .19], [20, .17], [22.5, .1]])
delays = np.array([[10, .1], [17, .2], [18, .2], [23, .25], [25, .25]])
#n = 50
#scale = 20
data = pd.read_csv(
    'donnees-hospitalieres-nouveaux-covid19-2020-05-03-19h00.csv',
    delimiter=';')

#deaths_early = pd.read_csv('deces_france_0101-1404.csv', index_col = 'jour')

# remove unused columns
admissions = data.pivot(index='jour', columns='dep', values='incid_hosp')
reanimations = data.pivot(index='jour', columns='dep', values='incid_rea')

plt.plot(admissions.sum(axis=1), label='hospitalisations')
plt.plot(reanimations.sum(axis=1), label='reanimations')
plt.yscale('log')
plt.legend(loc='best')

# remove overseas
admissions = admissions.drop(['971', '972', '973', '974', '976'], axis=1)

# Ile de France
adm_Idf = admissions[['92', '75', '77', '78', '91', '93', '94',
                      '95']].sum(axis=1)
# switch to cumulative data
adm_Idf = np.cumsum(adm_Idf)

fit_idf_adm = lockdown.Fitter(adm_Idf, '2020-03-19', 12)

fit_idf_adm.fit_lockdown('2020-05-03')

fit_idf_adm.plot_fit()
fit_idf_adm.axes.set_title('Hospitalisations en Ile de France')