コード例 #1
0
ファイル: main.py プロジェクト: tinayem01/seir-model
                         infectious_func=infectious_func,
                         imported_func=imported_func)

init_vectors = {
    's_0': [27000000, 8000000],
    'e_0': [0, 0],
    'i_0': [[0, 0, 0, 0], [0, 0, 0, 0]]
}
t = np.linspace(0, 300, 3001)
solution = model.solve(init_vectors, t, to_csv=True, fp='data/solution.csv')

print(model.r_0_eff)
print(model.r_0)

# plot all figures
fig, axes = plot_solution(solution, t)

for row in axes:
    for ax in row:
        ax.set_xlim((0, 50))
        ax.set_ylim((0, 2000))

# plt.show()

# plot young
# fig, axes = plot_solution(solution, t, 0)
# plt.show()
#
# # plot old
# fig, axes = plot_solution(solution, t, 1)
# plt.show()
コード例 #2
0
init_vectors = {
    's_0': s_0,
    'i_0': {'30-39_male_high': [0, 0, 0, 0, 0, 0]}
}

periods_per_day = 5
t = np.linspace(0, 300, 300 * periods_per_day + 1)
solution = model.solve(init_vectors, t, to_csv=True, fp='data/solution.csv')

print(model.r_0)

s_t, e_t, i_t, r_t, d_t = solution

# plot all figures
fig, axes = plot_solution(solution, t, show_detected=True)

# all time plot
axes[1, 0].set_xticks((0, 50, 100, 150, 200, 250, 300))
axes[1, 0].set_xticklabels(('05-Mar', '24-Apr', '13-Jun', '02-Aug', '21-Sep', '10-Nov', '30-Dec'))

# 90 day plot
# for row in axes:
#     for ax in row:
#         ax.set_xlim((0, 90))
#         ax.set_ylim((0, 2000))
#         ax.axvline(x=22, color='k', ls='--', lw=0.8)
#         ax.axvline(x=64, color='k', ls='--', lw=0.8)
#
# axes[0, 1].set_ylim((0, 100))
# axes[1, 1].set_ylim((0, 50))
コード例 #3
0
    for t in df_total['Time']
]
df_total.drop(columns='Time', inplace=True)
cols = list(df_total.columns)
cols = [cols[-1]] + cols[:-1]
df_total = df_total[cols]
df_total['Cumulative Infections'] = df_total['Asymptomatic'] + df_total[
    'Mild'] + df_total['Severe Total'] + df_total['R'] + df_total['Dead']
df_total['IFR'] = df_total['Dead'] / df_total['Cumulative Infections']
df_total['CFR'] = df_total['Dead'] / df_total['Cumulative Detected']
df_total['Total hospitalised'] = [
    a + b for a, b in zip(df_total['Hospitalised'], df_total['ICU'])
]
df_total['Active infections'] = df_total['Asymptomatic'] + df_total[
    'Mild'] + df_total['Severe Total']
df_total.to_csv('data/daily_output_' + descr + '.csv', index=False)

# plot output
fig, axes = plot_solution(df_total, full_descr, actual_infections,
                          actual_hospitalisations, actual_deaths, 45, 90)
fig.savefig('data/output_' + descr + '.png')

plt.stackplot(np.asarray(df_total['Day']),
              np.asarray(df_total['Active infections']),
              np.asarray(df_total['S']),
              np.asarray(df_total['E']),
              np.asarray(df_total['R']),
              np.asarray(df_total['Dead']),
              labels=['I', 'S', 'E', 'R', 'D'],
              colors=['red', 'lightgray', 'blue', 'green', 'black'])