change to plot_vD_vs_exposure_time

This commit is contained in:
Andrejh 2022-02-21 10:57:20 +01:00
parent a594b67528
commit 96800e04ff
2 changed files with 46 additions and 49 deletions

View file

@ -20,41 +20,42 @@ from cara.monte_carlo.data import symptomatic_vl_frequencies
# print('\n<<<<<<<<<<< Peak viral concentration with short range interactions for baseline scenarios >>>>>>>>>>>')
# concentration_curve(models=[exposure_module_with_short_range(
# activity='Seated',
# activity='Light activity',
# expiration={"Speaking": 1, "Breathing": 2},
# mask='No mask',
# sr_presence=[(10.5, 11.0), (15.5, 16.0)],
# sr_activities=['Breathing', 'Shouting']),
# sr_presence=[(10.5, 11.0), (15.0, 16.0)],
# sr_activities=['Breathing', 'Speaking']),
# exposure_module_without_short_range(
# activity='Seated',
# activity='Light activity',
# expiration={"Speaking": 1, "Breathing": 2},
# mask='No mask',
# )],
# labels = ['Mean concentration with short range interactions', 'Mean concentration without short range interactions'],
# colors = ['royalblue', 'darkviolet'],
# linestyles = ['-', '-'],
# thickness = [2, 2.5])
# mask='No mask',)
# ],
# labels = ['Concentration with short range interactions', 'Background (long-range) concentration'],
# labelsDose = ['Dose (full)', 'Dose (long-range)'],
# colors = ['salmon', 'royalblue'],
# linestyles = ['-', '--'],
# thickness = [2, 2])
# print('\n<<<<<<<<<<< Probability of infections vs exposure time >>>>>>>>>>>')
print('\n<<<<<<<<<<< Dose vs SR exposure time >>>>>>>>>>>')
#Always assume 1h for the short range interactions.
#Always assume that in each model there is only ONE short range interaction.
# plot_pi_vs_exposure_time(exp_models = [
# baseline_model(
# activity='Seated',
# expiration={"Speaking": 2, "Breathing": 1},
# mask='No mask',
# sr_presence=[(10.0, 11.0)],
# sr_activities=['Breathing']),
# baseline_model(
# activity='Seated',
# expiration={"Shouting": 2, "Breathing": 1},
# mask='No mask',
# sr_presence=[(10.0, 11.0)],
# sr_activities=['Shouting'])],
# labels = ['Baseline model breathing', 'Baseline model shouting'],
# colors=['royalblue', 'darkviolet'],
# linestyles=['solid', 'solid'],
# points=20,
# time_in_minutes=True,
# normalize_y_axis=True)
plot_vD_vs_exposure_time(exp_models = [
baseline_model(
activity='Light activity',
expiration={"Speaking": 2, "Breathing": 1},
mask='No mask',
sr_presence=[(8.5, 9.5)],
sr_activities=['Breathing']),
baseline_model(
activity='Light activity',
expiration={"Speaking": 2, "Breathing": 1},
mask='No mask',
sr_presence=[(8.5, 9.5)],
sr_activities=['Speaking'])],
labels = ['Baseline model breathing', 'Baseline model speaking'],
colors=['royalblue', 'darkviolet'],
linestyles=['solid', 'solid'],
points=20,
time_in_minutes=True,
normalize_y_axis=True)

View file

@ -149,18 +149,14 @@ def concentration_curve(models, labels, labelsDose, colors, linestyles, thicknes
plt.legend(handles=labels_legend, loc='upper left')
plt.show()
def plot_pi_vs_exposure_time(exp_models: typing.List[mc.ExposureModel],
labels,
colors,
linestyles,
points: int = 20, time_in_minutes: bool = False, normalize_y_axis: bool = False) -> None:
def plot_vD_vs_exposure_time(exp_models: typing.List[mc.ExposureModel], labels, colors, linestyles, points: int = 20, time_in_minutes: bool = False, normalize_y_axis: bool = False) -> None:
TIMESTEP = 0.001
TIMESTEP = 0.01
concentration_models = [model.concentration_model for model in exp_models]
exposed_models = [model.exposed for model in exp_models]
pis: typing.List[typing.List[float]] = [[] for _ in exp_models]
vDs: typing.List[typing.List[float]] = [[] for _ in exp_models]
presence_intervals = [model.short_range.presence[0].boundaries() for model in exp_models]
start, final = presence_intervals[0]
@ -177,20 +173,20 @@ def plot_pi_vs_exposure_time(exp_models: typing.List[mc.ExposureModel],
) for cm, exposed, em in zip(concentration_models, exposed_models, exp_models)]
for i, m in enumerate(current_models):
pis[i].append(np.mean(m.build_model(SAMPLE_SIZE).infection_probability() / 100))
vDs[i].append(np.mean(m.build_model(SAMPLE_SIZE).deposited_exposure()))
times = np.linspace(0, 60, points)
for i, pi in enumerate(pis):
plt.plot(times, pi, color=colors[i], label=labels[i])
for i, vD in enumerate(vDs):
plt.plot(times, vD, color=colors[i], label=labels[i])
# plt.xlim((0, 60))
if normalize_y_axis:
plt.ylim((0, 1))
#if normalize_y_axis:
# plt.ylim((0, 1))
for m in exp_models:
print(np.mean(m.build_model(SAMPLE_SIZE).infection_probability() / 100))
print(np.mean(m.build_model(SAMPLE_SIZE).deposited_exposure()))
plt.xlabel(f'Exposure time (m)', fontsize=12)
plt.ylabel('Probability of infection\n$P(\,\mathtt{I}\,)$', fontsize=12)
plt.xlabel(f'Duration of close-proximity encounter\n(min)', fontsize=12)
plt.ylabel('Mean cumulative dose\n(infectious virus)', fontsize=12)
plt.legend()
plt.show()