Merge remote-tracking branch 'origin/feature/mc' into feature/mc
# Conflicts: # cara/mc-output.py
This commit is contained in:
commit
7cf31b50df
3 changed files with 124 additions and 38 deletions
|
|
@ -1,7 +1,7 @@
|
|||
from cara.montecarlo import *
|
||||
from cara.model_scenarios import *
|
||||
|
||||
#classroom_model.infection_probability()
|
||||
classroom_model.infection_probability()
|
||||
#compare_concentration_curves([classroom_model, classroom_model_with_hepa], ['Just window', 'Window and HEPA'])
|
||||
|
||||
#print(np.mean(chorale_model.infection_probability()))
|
||||
|
|
@ -12,13 +12,18 @@ from cara.model_scenarios import *
|
|||
|
||||
|
||||
|
||||
# #print(np.mean(classroom_model_with_hepa.infection_probability()))
|
||||
composite_plot_pi_vs_viral_load([shared_office_worst_model[1], shared_office_model[1],shared_office_better_model[1]],
|
||||
labels=['No mask &\nwindows closed', 'Baseline', 'Baseline +\nHEPA filter'],
|
||||
colors=['tomato', '#1f77b4', 'limegreen'],
|
||||
title='$P(I|qID)$ vs $vl$ - Shared office scenario',
|
||||
vl_points=200)
|
||||
#plot_pi_vs_viral_load([shared_office_model[1]], labels=['Baseline, qID=60', 'HEPA, qID=60', 'No mask + windows closed, qID=60'],title='$P(I|qID)$ - Shared office scenario')
|
||||
print(np.mean(shared_office_model[1].infection_probability()))
|
||||
composite_plot_pi_vs_viral_load([shared_office_worst_model[1], shared_office_model[1], shared_office_better_model[1]],
|
||||
labels=['No mask &\nwindows closed', 'Baseline', 'Baseline +\nHEPA filter'],
|
||||
colors=['tomato', '#1f77b4', 'limegreen'],
|
||||
title='$P(I|qID)$ vs $vl$ - Shared office scenario',
|
||||
vl_points=200)
|
||||
composite_plot_pi_vs_viral_load([classroom_model[1], classroom_model_with_hepa[1]],
|
||||
labels=['No mask &\nwindows closed', 'Baseline', 'Baseline +\nHEPA filter'],
|
||||
colors=['tomato', '#1f77b4', 'limegreen'],
|
||||
title='$P(I|qID)$ vs $vl$ - Shared office scenario',
|
||||
vl_points=200)
|
||||
#plot_pi_vs_viral_load([shared_office_model[1]], labels=['Baseline'],title='')
|
||||
|
||||
|
||||
#generate_cdf_curves_vs_qr(masked=False,qid=1000)
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ exposure_models_2 = [MCExposureModel(
|
|||
)
|
||||
) for qid in (100, 60)]
|
||||
|
||||
classroom_model = MCExposureModel(
|
||||
classroom_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=160),
|
||||
ventilation=models.SlidingWindow(
|
||||
|
|
@ -128,7 +128,7 @@ classroom_model = MCExposureModel(
|
|||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=60),
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
|
|
@ -140,9 +140,90 @@ classroom_model = MCExposureModel(
|
|||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
classroom_model_with_hepa = MCExposureModel(
|
||||
classroom_model_full_open = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=160),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (283,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
infected=MCInfectedPopulation(
|
||||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
)
|
||||
),
|
||||
exposed=models.Population(
|
||||
number=19,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
classroom_model_summer = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=160),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=10),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (291,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
infected=MCInfectedPopulation(
|
||||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
)
|
||||
),
|
||||
exposed=models.Population(
|
||||
number=19,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
classroom_model_full_open_summer = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=160),
|
||||
ventilation=models.SlidingWindow(
|
||||
active=models.PeriodicInterval(period=120, duration=120),
|
||||
inside_temp=models.PiecewiseConstant((0, 24), (293,)),
|
||||
outside_temp=models.PiecewiseConstant((0, 24), (291,)),
|
||||
window_height=1.6, opening_length=0.6,
|
||||
),
|
||||
infected=MCInfectedPopulation(
|
||||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
)
|
||||
),
|
||||
exposed=models.Population(
|
||||
number=19,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
classroom_model_with_hepa = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=160),
|
||||
ventilation=models.MultipleVentilation(
|
||||
|
|
@ -161,7 +242,7 @@ classroom_model_with_hepa = MCExposureModel(
|
|||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2), (2.5, 4), (5, 7), (7.5, 9))),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=60),
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
|
|
@ -173,7 +254,7 @@ classroom_model_with_hepa = MCExposureModel(
|
|||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
shared_office_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
|
|
@ -263,7 +344,7 @@ shared_office_better_model = [MCExposureModel(
|
|||
)
|
||||
) for qid in (100, 60)]
|
||||
|
||||
ski_cabin_model = MCExposureModel(
|
||||
ski_cabin_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=10),
|
||||
ventilation=models.HVACMechanical(
|
||||
|
|
@ -274,7 +355,7 @@ ski_cabin_model = MCExposureModel(
|
|||
number=1,
|
||||
presence=models.SpecificInterval(((0, 0.33),)),
|
||||
masked=True,
|
||||
virus=MCVirus(halflife=1.1, qID=60),
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=2,
|
||||
samples=200000,
|
||||
breathing_category=4,
|
||||
|
|
@ -287,9 +368,9 @@ ski_cabin_model = MCExposureModel(
|
|||
activity=models.Activity.types['Moderate activity'],
|
||||
mask=models.Mask.types['Type I']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
gym_model = MCExposureModel(
|
||||
gym_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=300),
|
||||
ventilation=models.AirChange(
|
||||
|
|
@ -300,7 +381,7 @@ gym_model = MCExposureModel(
|
|||
number=2,
|
||||
presence=models.SpecificInterval(((0, 1),)),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=60),
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=1,
|
||||
samples=200000,
|
||||
breathing_category=5,
|
||||
|
|
@ -313,9 +394,9 @@ gym_model = MCExposureModel(
|
|||
activity=models.Activity.types['Heavy exercise'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
waiting_room_model = MCExposureModel(
|
||||
waiting_room_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=100),
|
||||
ventilation=models.AirChange(
|
||||
|
|
@ -326,7 +407,7 @@ waiting_room_model = MCExposureModel(
|
|||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2),)),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=3.8, qID=60),
|
||||
virus=MCVirus(halflife=3.8, qID=qid),
|
||||
expiratory_activity=4,
|
||||
samples=200000,
|
||||
breathing_category=1,
|
||||
|
|
@ -339,9 +420,9 @@ waiting_room_model = MCExposureModel(
|
|||
activity=models.Activity.types['Seated'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
||||
chorale_model = MCExposureModel(
|
||||
chorale_model = [MCExposureModel(
|
||||
concentration_model=MCConcentrationModel(
|
||||
room=models.Room(volume=810),
|
||||
ventilation=models.AirChange(
|
||||
|
|
@ -352,7 +433,7 @@ chorale_model = MCExposureModel(
|
|||
number=1,
|
||||
presence=models.SpecificInterval(((0, 2.5),)),
|
||||
masked=False,
|
||||
virus=MCVirus(halflife=1.1, qID=100),
|
||||
virus=MCVirus(halflife=1.1, qID=qid),
|
||||
expiratory_activity=3,
|
||||
samples=200000,
|
||||
breathing_category=3,
|
||||
|
|
@ -365,4 +446,4 @@ chorale_model = MCExposureModel(
|
|||
activity=models.Activity.types['Moderate activity'],
|
||||
mask=models.Mask.types['No mask']
|
||||
)
|
||||
)
|
||||
)for qid in (100, 60)]
|
||||
|
|
|
|||
|
|
@ -579,8 +579,8 @@ def plot_pi_vs_viral_load(baselines: typing.Union[MCExposureModel, typing.List[M
|
|||
|
||||
plt.vlines(x=(left, right), ymin=0, ymax=1,
|
||||
colors=('grey', 'grey'), linestyles='dotted')
|
||||
plt.text(left - 1.1, 0.80, '$vl_{crit1}$', fontsize=12,color='black')
|
||||
plt.text(right + 0.1, 0.80, '$vl_{crit2}$', fontsize=12,color='black')
|
||||
plt.text(left - 1.1, 0.80, '$vl_{0.05}$', fontsize=12,color='black')
|
||||
plt.text(right + 0.1, 0.80, '$vl_{0.95}$', fontsize=12,color='black')
|
||||
# add 3 shaded areas
|
||||
plt.axvspan(3, left, alpha=0.1, color='limegreen')
|
||||
plt.axvspan(left, right, alpha=0.1, color='orange')
|
||||
|
|
@ -589,16 +589,16 @@ def plot_pi_vs_viral_load(baselines: typing.Union[MCExposureModel, typing.List[M
|
|||
if labels is not None:
|
||||
plt.legend(labels)
|
||||
# this is an inset plot inside the main plot
|
||||
a = plt.axes([.2, .25, .3, .2], facecolor='lightgrey')
|
||||
|
||||
plt.title('Histogram', fontsize=10)
|
||||
# choose between hist or violin plot
|
||||
|
||||
if len(baselines) == 1:
|
||||
plt.hist(baselines[0].infection_probability()/100, bins=50)
|
||||
plt.xticks([0, 0.5, 1])
|
||||
plt.yticks([])
|
||||
|
||||
#a = plt.axes([.2, .25, .3, .2], facecolor='lightgrey')
|
||||
#
|
||||
#plt.title('Histogram', fontsize=10)
|
||||
## choose between hist or violin plot
|
||||
#
|
||||
#if len(baselines) == 1:
|
||||
# plt.hist(baselines[0].infection_probability()/100, bins=50)
|
||||
# plt.xticks([0, 0.5, 1])
|
||||
# plt.yticks([])
|
||||
#
|
||||
# parts = plt.violinplot((shared_office_worst_model[1].infection_probability()/100, shared_office_model[1].infection_probability()/100, shared_office_better_model[1].infection_probability()/100), positions = (1, 2, 3), showmeans=True, showmedians=True)
|
||||
# for pc in parts['bodies']:
|
||||
# pc.set_facecolor('#D43F3A')
|
||||
|
|
|
|||
Loading…
Reference in a new issue