diff --git a/cara/short_range_plots/results.py b/cara/short_range_plots/results.py index 658ab820..efb1be4b 100644 --- a/cara/short_range_plots/results.py +++ b/cara/short_range_plots/results.py @@ -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', -# expiration={"Speaking": 1, "Breathing": 2}, +# 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', -# 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]) +# activity='Light activity', +# expiration={"Speaking": 1, "Breathing": 2}, +# 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 >>>>>>>>>>>') -# 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) +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_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) diff --git a/cara/short_range_plots/scripts.py b/cara/short_range_plots/scripts.py index 72a54441..3e537d3c 100644 --- a/cara/short_range_plots/scripts.py +++ b/cara/short_range_plots/scripts.py @@ -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()