IFR = infectionFatalityRateA if U[i] <= intensiveUnits else infectionFatalityRateB
    D[i] = DPrev + IFR * (R[i] - RPrev)
    RPrev = R[i]
    DPrev = D[i]

D = shared.delay(D, - timeInfected + timePresymptomatic +symptomToHospitalLag + timeInHospital + communicationLag)  # deaths  from R

# Plot
fig = plt.figure(dpi=75, figsize=(20,16))
ax = fig.add_subplot(111)
ax.fmt_xdata = matplotlib.dates.DateFormatter('%Y-%m-%d')  # higher date precision for cursor display
if logPlot:
    ax.set_yscale("log", nonposy='clip')

# actual country data
XCDR_data = np.array(world_data.get_country_xcdr(COUNTRY, PROVINCE,
                                                 excludeCountries=EXCLUDECOUNTRIES, returnDates=True))
dataOffset = shared.get_offset_X(XCDR_data, D, dataOffset)  # match model day to real data day for deaths curve  todo: percentage wise?

ax.plot(XCDR_data[:,0], XCDR_data[:,1], 'o', color='orange', alpha=0.5, lw=1, label='cases actually detected in tests')
ax.plot(XCDR_data[:,0], XCDR_data[:,2], 'x', color='black', alpha=0.5, lw=1, label='actually deceased')

# set model time to real world time
X = shared.model_to_world_time(X - dataOffset, XCDR_data)

# model data
#ax.plot(X, S, 'b', alpha=0.5, lw=2, label='Susceptible')
ax.plot(X, E, 'y', alpha=0.5, lw=2, label='Exposed (realtime)')
ax.plot(X, I, 'r--', alpha=0.5, lw=1, label='Infected (realtime)')
ax.plot(X, FC, color='orange', alpha=0.5, lw=1, label='Found cumulated: "cases" (lagtime)')
ax.plot(X, U, 'r', alpha=0.5, lw=2, label='ICU (realtime)')
#ax.plot(X, R, 'g', alpha=0.5, lw=1, label='Recovered with immunity')
Esempio n. 2
0
ax.plot(X, I, 'r--', alpha=0.5, lw=1, label='Infected')
ax.plot(X, F, color='orange', alpha=0.5, lw=1, label='Found')
ax.plot(X, H, 'r', alpha=0.5, lw=2, label='ICU')
#ax.plot(X, R, 'g', alpha=0.5, lw=1, label='Recovered with immunity')
#ax.plot(X, P, 'c', alpha=0.5, lw=1, label='Probability of infection')
ax.plot(X, D, 'k', alpha=0.5, lw=1, label='Deaths')

ax.plot([min(X), max(X)], [intensiveUnits, intensiveUnits],
        'b-.',
        alpha=0.5,
        lw=1,
        label='Number of ICU available')

# actual country data
XCDR_data = np.array(
    world_data.get_country_xcdr(COUNTRY, PROVINCE, dateOffset=dataOffset))

ax.plot(XCDR_data[:, 0],
        XCDR_data[:, 1],
        'o',
        color='orange',
        alpha=0.5,
        lw=1,
        label='cases actually detected in tests')
ax.plot(XCDR_data[:, 0],
        XCDR_data[:, 2],
        'x',
        color='black',
        alpha=0.5,
        lw=1,
        label='actually deceased')
Esempio n. 3
0
# todo: single loop, cleanup

countryDeaths = []
for country in countries:
    try:
        if countryPopulation[country] < 1000000:
            continue
        province = 'all'
        country2 = country
        if country == 'Hubei':
            country2 = 'China'
            province = 'Hubei'
        XCDR_data = np.array(
            world_data.get_country_xcdr(country2,
                                        province=province,
                                        returnDates=True))
        cases = int(XCDR_data[-1, 1])  # last row, third column
        deaths = int(XCDR_data[-1, 2])  # last row, third column
        if deaths < 10:
            continue
        recovered = int(XCDR_data[-1, 3])  # last row, third column
        date = XCDR_data[-1, 0]
        countryDeaths.append((country, cases, deaths, recovered, date))

    except Exception as e:
        print("fail: ", country, sys.exc_info()[0], e)

countryDeathsPC = []
for ccdrd in countryDeaths:
    country, cases, deaths, recovered, date = ccdrd
Esempio n. 4
0
import numpy as np
import matplotlib.pyplot as plt

import population
import world_data

countries, provinces = world_data.get_countries_provinces()
countryPopulation = population.get_all_population_data()

countryDeaths = []
for country in countries:
    try:
        if countryPopulation[country] < 1000000:
            continue
        XCDR_data = np.array(world_data.get_country_xcdr(country))
        cases = int(XCDR_data[-1, 1])  # last row, third column
        deaths = int(XCDR_data[-1, 2])  # last row, third column
        if deaths < 10:
            continue
        recovered = int(XCDR_data[-1, 3])  # last row, third column
        countryDeaths.append((country, cases, deaths, recovered))

    except:
        print("fail: ", country)

countryDeathsPC = []
for ccdr in countryDeaths:
    country, cases, deaths, recovered = ccdr
    try:
        pop = population.get_population(country)
        countryDeathsPC.append((country, deaths * 1.0e6 / pop, deaths, pop))