コード例 #1
0
ファイル: main200311.py プロジェクト: lbusoni/epidemic_models
def plotGuido():
    delayH = 0
    strdates = 'Days (Hubei from Jan1, Italy from Feb6)'

    de = restore_data.restoreCSSEDeath()
    deH = de['Hubei/China'].values
    deHd = de['Hubei/China'].days - delayH

    pop = 6e7
    nSteps = 100
    cfr = 0.00006
    delayModel = -21
    beta0 = 0.481
    gamma0 = 0.16

    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta0,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    system3.plot()
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    plt.plot(system3.timeSeries.timeVector,
             deaths3,
             label='deaths no action cfr=%g' % cfr)

    plt.plot(deHd, deH, '.-', label='deaths Hubei')
    plt.ylim(1, )
    plt.xlim(10, 75)
    plt.xlabel(strdates)
    plt.legend()
コード例 #2
0
ファイル: main200312.py プロジェクト: lbusoni/epidemic_models
def plotFB():
    delayI = 36
    delayR = 34
    delayH = 0
    delayF = 45
    delayS = 45
    delayK = 35
    strdates = 'Days (Hub +Jan1, I +Feb6, F +Feb15, S +Feb15)'

    deH, coH, reH, daH = _restoreCountry('Hubei/China', delayH)
    deI, coI, reI, daI = _restoreCountry('Italy', delayI)
    deF, coF, reF, daF = _restoreCountry('France/France', delayF)
    # deR, coR, reR, daR = _restoreCountry('Iran', delayR)
    deS, coS, reS, daS = _restoreCountry('Spain', delayS)
    # deK, c*K, reK, daK = _restoreCountry('Korea, South', delayK)

    pop = 6e7
    nSteps = 100
    cfr = 0.03
    delayModel = -1
    beta0 = 0.481
    gamma0 = 0.16

    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta0,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    system3.plot(susceptibles=False, infectious=False, recovered=False)
    plt.plot(system3.timeSeries.timeVector,
             deaths3,
             color='C2',
             label='SIR model, R0=3')

    plt.plot(daH, deH, '.-', color='C3', label='deaths Hubei')
    plt.plot(daI,
             deI,
             '.-',
             linewidth=2,
             markersize=12,
             color='C4',
             label='deaths Italy')
    plt.plot(daF, deF, '.-', label='deaths France')
    plt.plot(daS, deS, '.-', label='deaths Spain')
    # plt.plot(coHd + delayModel, coH, '.-', label='confirmed Hubei')
    # plt.plot(coId + delayModel, coI, '.-', label='confirmed Italy')
    plt.ylim(10, 1e4)
    plt.xlim(20, 70)
    plt.xlabel(strdates)
    plt.legend()
コード例 #3
0
ファイル: main200306.py プロジェクト: lbusoni/epidemic_models
def main():
    syncI2H = 27
    deH, coH, reH, daH = restoreCovid('Hubei')
    deI, coI, reI, daI = restoreCovid('Italy', fromItem=syncI2H)

    plt.figure()
    plt.plot(np.arange(len(deI)), deI, '.-', label='Deaths Italy')
    plt.plot(np.arange(len(deH)), deH, '.-', label='Deaths Hubei')
    t = "Evolution of deaths in Hubei and Italy (both 60M people)"
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel('Time [days]. Arbitrary origin')
    plt.show()
    plt.semilogy()

    co2de = 0.04
    delay_co2de = 2
    ff = np.ones(int(delay_co2de)) / delay_co2de
    expDeH = co2de * convolve(coH, ff, mode='full')[:len(coH)]
    expDeI = co2de * convolve(coI, ff, mode='full')[:len(coI)]
    plt.figure()
    plt.plot(np.arange(len(deI)), deI, '.-', label='Deaths Italy')
    plt.plot(np.arange(len(deH)), deH, '.-', label='Deaths Hubei')
    plt.plot(np.arange(len(coI)), coI, '.-', label='Confirmed Italy')
    plt.plot(np.arange(len(coH)), coH, '.-', label='Confirmed Hubei')
    plt.plot(np.arange(len(expDeI)), expDeI, label='Expected Deaths Italy')
    plt.plot(np.arange(len(expDeH)), expDeH, label='Expected Deaths Hubei')
    t = "Confirmed 2 Dead\n co2de=%g, delay=%g d" % (co2de, delay_co2de)
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel('Time [days]. Arbitrary origin')
    plt.show()
    plt.semilogy()

    pop = 6e7
    system = simple_sir.SimpleSIR(pop, 1, 0, 0.4, 15, 100)
    system.evolveSystem()
    system.plot()

    cfr = 0.03
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(deaths, label='deaths (CFR=%g)' % (cfr))

    plt.plot(np.arange(len(deH)) + 27, deH, '.-', label='deaths Hubei')
    plt.plot(np.arange(len(deI)) + 27, deI, '.-', label='deaths Italy')
    plt.plot(np.arange(len(coH)) + 27, coH, '.-', label='confirmed Hubei')
    plt.plot(np.arange(len(coI)) + 27, coI, '.-', label='confirmed Italy')
    plt.ylim(1, )
    plt.legend()
コード例 #4
0
ファイル: main200311.py プロジェクト: lbusoni/epidemic_models
def plotTuttoAZero():
    delayI = 36
    delayH = 0
    strdates = 'Days (Hubei from Jan1, Italy from Feb6)'

    de = restore_data.restoreCSSEDeath()
    deH = de['Hubei/Mainland China'].values
    deHd = de['Hubei/Mainland China'].days - delayH
    deI = de['Italy'].values
    deId = de['Italy'].days - delayI

    pop = 6e7
    nSteps = 100
    cfr = 0.03
    delayModel = -1
    beta0 = 0.481
    gamma0 = 0.16

    beta = np.zeros(nSteps)
    tInt1 = 29 - delayModel
    beta[:tInt1] = beta0
    beta[tInt1:] = gamma0
    system = simple_sir.SimpleSIR(pop,
                                  1,
                                  0,
                                  beta,
                                  1 / gamma0,
                                  nSteps,
                                  t0=delayModel)
    system.evolveSystem()
    system.plot(susceptibles=False, infectious=False, recovered=False)
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(system.timeSeries.timeVector,
             deaths,
             label='deaths if R0=1 at day=%d' % (tInt1 + delayModel))

    beta2 = np.zeros(nSteps)
    tInt2 = 32 - delayModel
    beta2[:tInt2] = beta0
    beta2[tInt2:] = gamma0 * 0.
    system2 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta2,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system2.evolveSystem()
    deaths2 = cfr * system2.timeSeries.recovered_with_immunity
    plt.plot(system2.timeSeries.timeVector,
             deaths2,
             label='deaths if R0=1 at day=%d' % (tInt2 + delayModel))

    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta0,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    plt.plot(system3.timeSeries.timeVector, deaths3, label='deaths no action')

    plt.plot(deHd, deH, '.-', label='deaths Hubei')
    plt.plot(deId, deI, '.-', linewidth=2, markersize=12, label='deaths Italy')
    # plt.plot(coHd + delayModel, coH, '.-', label='confirmed Hubei')
    # plt.plot(coId + delayModel, coI, '.-', label='confirmed Italy')
    plt.ylim(10, )
    plt.xlim(20, 75)
    plt.xlabel(strdates)
    plt.legend()
コード例 #5
0
ファイル: main200311.py プロジェクト: lbusoni/epidemic_models
def delays():
    delayI = 36
    delayR = 34
    delayH = 0
    delayF = 45
    delayS = 45
    delayK = 35
    strdates = 'Days (Hubei from Jan1, Italy from Feb6)'

    deH, coH, reH, daH = _restoreCountry('Hubei/China', delayH)
    deI, coI, reI, daI = _restoreCountry('Italy', delayI)
    #    deF, coF, reF, daF = _restoreCountry('France', delayF)
    #    deR, coR, reR, daR = _restoreCountry('Iran (Islamic Republic of)', delayR)
    #    deS, coS, reS, daS = _restoreCountry('Spain', delayS)
    #    deK, c*K, reK, daK = _restoreCountry('Republic of Korea', delayK)

    pop = 6e7
    nSteps = 100
    beta0 = 0.48
    gamma0 = 0.16
    epsilon = 0.005
    cfr = 0.0005
    delayModel = -14

    system = simple_sir.SimpleSIR(pop,
                                  1,
                                  0,
                                  beta0,
                                  1 / gamma0,
                                  nSteps,
                                  t0=delayModel)
    system.evolveSystem()
    system.plot()
    dS = np.append(np.diff(system.timeSeries.susceptibles), 0)
    dC = -epsilon * dS
    C = np.cumsum(dC)
    system.timeSeries.confirmed = C
    plt.plot(system.timeSeries.timeVector,
             system.timeSeries.confirmed,
             label='confirmed eps=%g' % epsilon)

    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(system.timeSeries.timeVector, deaths, label='deaths cfr=%g' % cfr)

    plt.plot(daH, coH, '.-', label='confirmed Hubei')
    plt.plot(daH, deH, '.-', label='deaths Hubei')
    plt.plot(daI, coI, '.-', label='confirmed Italy')
    plt.plot(daI, deI, '.-', label='deaths Italy')
    #    plt.plot(daK, c*K, '.-', label='confirmed Korea')
    #    plt.plot(daK, deK, '.-', label='deaths Korea')
    plt.ylim(1, )
    plt.xlim(10, 75)
    plt.xlabel(strdates)
    plt.legend()

    alpha = cfr * system._gamma
    ncdpi = (system._beta - system._gamma)
    tauRI = -np.log(system.basicReproductionNumber - 1) / ncdpi
    tauMI = np.log(alpha / (system._beta - system._gamma)) / ncdpi
    tauMR = np.log(alpha / system._gamma) / ncdpi
    tauCI = np.log(system._beta * epsilon / ncdpi) / ncdpi
    tauCM = tauCI - tauMI
コード例 #6
0
def main():
    delayI2H = 36
    # deH, coH, reH, daH = restoreCovid('Hubei')
    # deI, coI, reI, daI = restoreCovid('Italy', fromItem=syncI2H)

    de = restore_data.restoreCSSEDeath()
    deH = de['Hubei/Mainland China'].values
    deHd = de['Hubei/Mainland China'].days
    deI = de['Italy'].values
    deId = de['Italy'].days
    co = restore_data.restoreCSSEConfirmed()
    coH = co['Hubei/Mainland China'].values
    coHd = co['Hubei/Mainland China'].days
    coI = co['Italy'].values
    coId = co['Italy'].days

    plt.figure()
    plt.plot(deId - delayI2H, deI, '.-', label='Deaths Italy')
    plt.plot(deHd, deH, '.-', label='Deaths Hubei')
    t = "Evolution of deaths in Hubei and Italy (both 60M people)"
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel('Days (H from Jan1, I from Feb27)')
    plt.show()
    plt.semilogy()

    co2de = 0.04
    delay_co2de = 2
    ff = np.ones(int(delay_co2de)) / delay_co2de
    expDeH = co2de * convolve(coH, ff, mode='full')[:len(coH)]
    expDeI = co2de * convolve(coI, ff, mode='full')[:len(coI)]
    plt.figure()
    plt.plot(deId - delayI2H, deI, '.-', label='Deaths Italy')
    plt.plot(deHd, deH, '.-', label='Deaths Hubei')
    plt.plot(coId - delayI2H, coI, '.-', label='Confirmed Italy')
    plt.plot(coHd, coH, '.-', label='Confirmed Hubei')
    plt.plot(coId - delayI2H, expDeI, label='Expected Deaths Italy')
    plt.plot(coHd, expDeH, label='Expected Deaths Hubei')
    t = "Confirmed 2 Dead\n co2de=%g, delay=%g d" % (co2de, delay_co2de)
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel('Days (Hubei from Jan 1, I from Feb 27)')
    plt.ylim(1, )
    plt.show()
    plt.semilogy()

    pop = 6e7
    nSteps = 100
    beta = np.zeros(nSteps)
    beta[:36] = 0.4
    beta[36:] = 0.1
    system = simple_sir.SimpleSIR(pop, 1, 0, beta, 15, nSteps)
    system.evolveSystem()
    system.plot()

    cfr = 0.03
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(deaths, label='deaths (CFR=%g)' % (cfr))

    plt.plot(deHd + 6, deH, '.-', label='deaths Hubei')
    plt.plot(deId - delayI2H + 6, deI, '.-', label='deaths Italy')
    plt.plot(coHd + 6, coH, '.-', label='confirmed Hubei')
    plt.plot(coId - delayI2H + 6, coI, '.-', label='confirmed Italy')
    plt.ylim(1, )
    plt.legend()
コード例 #7
0
def main():
    delayI = 36
    delayR = 34
    delayH = 0

    de = restore_data.restoreCSSEDeath()
    deH = de['Hubei/Mainland China'].values
    deHd = de['Hubei/Mainland China'].days - delayH
    deI = de['Italy'].values
    deId = de['Italy'].days - delayI
    deR = de['Iran'].values
    deRd = de['Iran'].days - delayR

    co = restore_data.restoreCSSEConfirmed()
    coH = co['Hubei/Mainland China'].values
    coHd = co['Hubei/Mainland China'].days - delayH
    coI = co['Italy'].values
    coId = co['Italy'].days - delayI
    coR = co['Iran'].values
    coRd = co['Iran'].days - delayR

    plt.figure()
    plt.plot(deId, deI, '.-', label='Deaths Italy')
    plt.plot(deRd, deR, '.-', label='Deaths Iran')
    plt.plot(deHd, deH, '.-', label='Deaths Hubei')
    t = "Evolution of deaths in Hubei, Italy, Iran"
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    strdates = 'Days (H from Jan1, I from Feb6, Ir from Feb4)'
    plt.xlabel(strdates)
    plt.show()
    plt.semilogy()

    co2de = 0.04
    delay_co2de = 2
    ff = np.ones(int(delay_co2de)) / delay_co2de
    expDeH = co2de * convolve(coH, ff, mode='full')[:len(coH)]
    expDeI = co2de * convolve(coI, ff, mode='full')[:len(coI)]
    expDeR = co2de * convolve(coR, ff, mode='full')[:len(coR)]
    plt.figure()
    plt.plot(deId, deI, '.-', label='Deaths Italy')
    plt.plot(deRd, deR, '.-', label='Deaths Iran')
    plt.plot(deHd, deH, '.-', label='Deaths Hubei')
    plt.plot(coId, coI, '.-', label='Confirmed Italy')
    plt.plot(coRd, coR, '.-', label='Confirmed Iran')
    plt.plot(coHd, coH, '.-', label='Confirmed Hubei')
    plt.plot(coId, expDeI, label='Expected Deaths Italy')
    plt.plot(coRd, expDeR, label='Expected Deaths Iran')
    plt.plot(coHd, expDeH, label='Expected Deaths Hubei')
    t = "Confirmed 2 Dead\n co2de=%g, delay=%g d" % (co2de, delay_co2de)
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel(strdates)
    plt.ylim(1, )
    plt.show()
    plt.semilogy()

    pop = 6e7
    nSteps = 100
    beta = np.zeros(nSteps)
    beta[:36] = 0.4
    beta[36:] = 0.1
    system = simple_sir.SimpleSIR(pop, 1, 0, beta, 15, nSteps)
    system.evolveSystem()
    system.plot()

    cfr = 0.03
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(deaths, label='deaths (CFR=%g)' % (cfr))

    plt.plot(deHd + 6, deH, '.-', label='deaths Hubei')
    plt.plot(deId + 6, deI, '.-', label='deaths Italy')
    plt.plot(deRd + 6, deR, '.-', label='deaths Iran')
    plt.plot(coHd + 6, coH, '.-', label='confirmed Hubei')
    plt.plot(coId + 6, coI, '.-', label='confirmed Italy')
    plt.plot(coRd + 6, coR, '.-', label='confirmed Iran')
    plt.ylim(1, )
    plt.legend()
コード例 #8
0
ファイル: main200309.py プロジェクト: lbusoni/epidemic_models
def main():
    delayI = 36
    delayR = 34
    delayH = 0
    strdates = 'Days (Hubei from Jan1, Italy from Feb6)'

    de = restore_data.restoreCSSEDeath()
    deH = de['Hubei/Mainland China'].values
    deHd = de['Hubei/Mainland China'].days - delayH
    deI = de['Italy'].values
    deId = de['Italy'].days - delayI
    deR = de['Iran'].values
    deRd = de['Iran'].days - delayR

    co = restore_data.restoreCSSEConfirmed()
    coH = co['Hubei/Mainland China'].values
    coHd = co['Hubei/Mainland China'].days - delayH
    coI = co['Italy'].values
    coId = co['Italy'].days - delayI
    coR = co['Iran'].values
    coRd = co['Iran'].days - delayR

    plt.figure()
    plt.plot(deId, deI, '.-', label='Deaths Italy')
    plt.plot(deRd, deR, '.-', label='Deaths Iran')
    plt.plot(deHd, deH, '.-', label='Deaths Hubei')
    t = "Evolution of deaths in Hubei, Italy, Iran"
    plt.title(t)
    plt.legend()
    plt.grid(True)
    plt.ylabel('Total deaths')
    plt.xlabel(strdates)
    plt.show()
    plt.semilogy()

    pop = 6e7
    nSteps = 100
    cfr = 0.03
    delayModel = -3
    beta = np.zeros(nSteps)
    tInt1 = 33
    beta[:tInt1] = 0.481
    beta[tInt1:] = 0.192
    gamma = 0.192
    system = simple_sir.SimpleSIR(pop,
                                  1,
                                  0,
                                  beta,
                                  1 / gamma,
                                  nSteps,
                                  t0=delayModel)
    system.evolveSystem()
    system.plot(susceptibles=False, infectious=False, recovered=False)
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(system.timeSeries.timeVector,
             deaths,
             label='deaths if R0=1 at day=%d' % (tInt1 + delayModel))

    beta2 = np.zeros(nSteps)
    tInt2 = 40
    beta2[:tInt2] = 0.481
    beta2[tInt2:] = 0.192
    gamma2 = 0.192
    system2 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta2,
                                   1 / gamma2,
                                   nSteps,
                                   t0=delayModel)
    system2.evolveSystem()
    deaths2 = cfr * system2.timeSeries.recovered_with_immunity
    plt.plot(system2.timeSeries.timeVector,
             deaths2,
             label='deaths if R0=1 at day=%d' % (tInt2 + delayModel))

    beta3 = 0.481
    gamma3 = 0.192
    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta3,
                                   1 / gamma3,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    plt.plot(system3.timeSeries.timeVector, deaths3, label='deaths no action')

    plt.plot(deHd, deH, '.-', label='deaths Hubei')
    plt.plot(deId, deI, '.-', linewidth=2, markersize=12, label='deaths Italy')
    # plt.plot(coHd + delayModel, coH, '.-', label='confirmed Hubei')
    # plt.plot(coId + delayModel, coI, '.-', label='confirmed Italy')
    plt.ylim(10, )
    plt.xlim(20, 75)
    plt.xlabel(strdates)
    plt.legend()
コード例 #9
0
ファイル: main200312.py プロジェクト: lbusoni/epidemic_models
def plotGio():
    delayI = 36
    delayR = 34
    delayH = 0
    delayF = 45
    delayS = 45
    delayK = 35
    strdates = 'Days (Hub +Jan1, I +Feb6, F +Feb15, S +Feb15)'

    deH, coH, reH, daH = _restoreCountry('Hubei/China', delayH)
    deI, coI, reI, daI = _restoreCountry('Italy', delayI)
    deF, coF, reF, daF = _restoreCountry('France/France', delayF)
    # deR, coR, reR, daR = _restoreCountry('Iran', delayR)
    deS, coS, reS, daS = _restoreCountry('Spain', delayS)
    # deK, c*K, reK, daK = _restoreCountry('Korea, South', delayK)

    pop = 6e7
    nSteps = 100
    cfr = 0.03
    delayModel = -1
    beta0 = 0.481
    gamma0 = 0.16

    beta = np.zeros(nSteps)
    tInt1 = 29 - delayModel
    beta[:tInt1] = beta0
    beta[tInt1:] = gamma0
    system = simple_sir.SimpleSIR(pop,
                                  1,
                                  0,
                                  beta,
                                  1 / gamma0,
                                  nSteps,
                                  t0=delayModel)
    system.evolveSystem()
    system.plot(susceptibles=False, infectious=False, recovered=False)
    deaths = cfr * system.timeSeries.recovered_with_immunity
    plt.plot(system.timeSeries.timeVector,
             deaths,
             label='deaths if R0=1 at day=%d' % (tInt1 + delayModel))

    beta2 = np.zeros(nSteps)
    tInt2 = 32 - delayModel
    beta2[:tInt2] = beta0
    beta2[tInt2:] = gamma0
    system2 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta2,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system2.evolveSystem()
    deaths2 = cfr * system2.timeSeries.recovered_with_immunity
    plt.plot(system2.timeSeries.timeVector,
             deaths2,
             label='deaths if R0=1 at day=%d' % (tInt2 + delayModel))

    beta4 = np.zeros(nSteps)
    beta4[:tInt2] = beta0
    beta4[tInt2:] = 0 * gamma0
    system4 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta4,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system4.evolveSystem()
    deaths4 = cfr * system4.timeSeries.recovered_with_immunity
    plt.plot(system4.timeSeries.timeVector,
             deaths4,
             label='deaths if R0=0 at day=%d' % (tInt2 + delayModel))

    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta0,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    plt.plot(system3.timeSeries.timeVector, deaths3, label='deaths no action')

    plt.plot(daH, deH, '.-', label='deaths Hubei')
    plt.plot(daI, deI, '.-', linewidth=2, markersize=12, label='deaths Italy')
    plt.plot(daF, deF, '.-', label='deaths France')
    # plt.plot(daS, deS, '.-', label='deaths Spain')
    # plt.plot(coHd + delayModel, coH, '.-', label='confirmed Hubei')
    # plt.plot(coId + delayModel, coI, '.-', label='confirmed Italy')
    plt.ylim(10, 1e5)
    plt.xlim(20, 70)
    plt.xlabel(strdates)
    plt.legend()
コード例 #10
0
ファイル: main200312.py プロジェクト: lbusoni/epidemic_models
def plotLapo():
    delayI = 36
    delayR = 34
    delayH = 0
    delayF = 45
    delayS = 45
    delayK = 35
    strdates = 'Days (Hub +Jan1, I +Feb6, F +Feb15, S +Feb15)'

    deH, coH, reH, daH = _restoreCountry('Hubei/China', delayH)
    deI, coI, reI, daI = _restoreCountry('Italy', delayI)
    #    deF, coF, reF, daF = _restoreCountry('France/France', delayF)
    # deR, coR, reR, daR = _restoreCountry('Iran', delayR)
    #    deS, coS, reS, daS = _restoreCountry('Spain', delayS)
    # deK, c*K, reK, daK = _restoreCountry('Korea, South', delayK)

    pop = 6e7
    nSteps = 200
    cfr = 0.03
    delayModel = -1
    beta0 = 0.481
    gamma0 = 0.16
    lockDownTime = 60

    beta2 = np.zeros(nSteps)
    tInt2 = 32 - delayModel
    beta2[:tInt2] = beta0
    beta2[tInt2:tInt2 + lockDownTime] = 1.0 * gamma0
    beta2[tInt2 + lockDownTime:] = beta0
    system2 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta2,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system2.evolveSystem()
    # system2.plot(susceptibles=False, infectious=False, recovered=False)
    system2.plot()
    deaths2 = cfr * system2.timeSeries.recovered_with_immunity
    plt.plot(system2.timeSeries.timeVector,
             deaths2,
             label='deaths if R0=1.0 from day %d to %d ' %
             (tInt2 + delayModel, tInt2 + lockDownTime + delayModel))

    #     beta4 = np.zeros(nSteps)
    #     beta4[:tInt2] = beta0
    #     beta4[tInt2:tInt2 + lockDownTime] = 0
    #     beta4[tInt2 + lockDownTime:] = beta0
    #     system4 = simple_sir.SimpleSIR(pop, 1, 0, beta4, 1 / gamma0,
    #                                    nSteps, t0=delayModel)
    #     system4.evolveSystem()
    #     system4.plot(susceptibles=False, infectious=True, recovered=False, newFigure=False)
    #     deaths4 = cfr * system4.timeSeries.recovered_with_immunity
    #     plt.plot(system4.timeSeries.timeVector,
    #              deaths4,
    #              label='deaths if R0=0 from day %d to %d ' % (
    #                  tInt2 + delayModel, tInt2 + lockDownTime + delayModel))

    system3 = simple_sir.SimpleSIR(pop,
                                   1,
                                   0,
                                   beta0,
                                   1 / gamma0,
                                   nSteps,
                                   t0=delayModel)
    system3.evolveSystem()
    system3.plot(susceptibles=False,
                 infectious=True,
                 recovered=False,
                 newFigure=False)
    deaths3 = cfr * system3.timeSeries.recovered_with_immunity
    plt.plot(system3.timeSeries.timeVector, deaths3, label='deaths no action')

    #    plt.plot(daH, deH, '.-', label='deaths Hubei')
    #    plt.plot(daI, deI, '.-',
    #             linewidth=2,
    #             markersize=12,
    #             label='deaths Italy')
    plt.ylim(10, )
    plt.xlim(20, )
    plt.xlabel(strdates)
    plt.legend()