From 9f6e500618be39281a04dd9426ca0a2fa9962bd8 Mon Sep 17 00:00:00 2001 From: Andrejh Date: Fri, 19 Mar 2021 11:31:54 +0100 Subject: [PATCH] create present_qR_values --- cara/model_scenarios_publication.py | 28 ++++++++++++++++++++++++++++ cara/montecarlo.py | 13 ++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cara/model_scenarios_publication.py b/cara/model_scenarios_publication.py index 689da9f3..e78f2ac2 100644 --- a/cara/model_scenarios_publication.py +++ b/cara/model_scenarios_publication.py @@ -1,3 +1,31 @@ from cara import models from cara.montecarlo import * +######### Standard exposure models ########### +exposure_models = [MCExposureModel( + concentration_model=MCConcentrationModel( + room=models.Room(volume=45), + 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.2, + ), + infected=MCInfectedPopulation( + number=1, + presence=models.SpecificInterval(((0, 4), (5, 9))), + masked=False, + virus=MCVirus(halflife=1.1, qID=100), + expiratory_activity=a, + samples=2000000, + breathing_category=3, + expiratory_activity_weights=(0.7, 0.3, 0) + ) + ), + exposed=models.Population( + number=2, + presence=models.SpecificInterval(((0, 4), (5, 9))), + activity=models.Activity.types['Seated'], + mask=models.Mask.types['Type I'] + ) +) for a in (1, 2, 3)] \ No newline at end of file diff --git a/cara/montecarlo.py b/cara/montecarlo.py index 912f3d4c..fca16db8 100644 --- a/cara/montecarlo.py +++ b/cara/montecarlo.py @@ -426,11 +426,22 @@ def print_qr_info(log_qr: np.ndarray) -> None: print(f"MEAN of log_10(qR) = {np.mean(log_qr)}\n" f"SD of log_10(qR) = {np.std(log_qr)}\n" f"MEAN of qR = {np.mean(qr_values)}\n" - f"SD of qR = {np.std(qr_values)}\n") + f"SD of qR = {np.std(qr_values)}\n" + f"Median of qR = {np.quantile(qr_values, 0.5)}\n") for quantile in (0.01, 0.05, 0.25, 0.50, 0.75, 0.95, 0.99): print(f"qR_{quantile} = {np.quantile(qr_values, quantile)}") +def present_qR_values(model: MCConcentrationModel) -> None: + """ + Displays a handful of key parameters and results of qR from a given MCConcentrationModel + :param model: The MCConcentrationModel representing the scenario to be presented + :return: Nothing, parameters are printed + """ + + qRs = (np.log10(model.infected.emission_rate_when_present())) + + print_qr_info(np.asarray(qRs)) def present_model(model: MCConcentrationModel, bins: int = 200, title: str = 'Summary of $qR$ model parameters') -> None: