Compare commits
1 commit
master
...
feature/BL
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26220029d5 |
8 changed files with 31 additions and 25 deletions
|
|
@ -11,6 +11,7 @@ import matplotlib.figure
|
|||
from cara import models
|
||||
from cara import state
|
||||
from cara import data
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
def collapsible(widgets_to_collapse: typing.List, title: str, start_collapsed=False):
|
||||
|
|
@ -405,13 +406,13 @@ class ModelWidgets(View):
|
|||
|
||||
def _build_expiration(self, node):
|
||||
expiration = node.dcs_instance()
|
||||
for name, expiration_ in models.Expiration.types.items():
|
||||
for name, expiration_ in expiration_types.items():
|
||||
if expiration == expiration_:
|
||||
break
|
||||
expiration_choice = widgets.Select(options=list(models.Expiration.types.keys()), value=name)
|
||||
expiration_choice = widgets.Select(options=list(expiration_types.keys()), value=name)
|
||||
|
||||
def on_expiration_change(change):
|
||||
expiration = models.Expiration.types[change['new']]
|
||||
expiration = expiration_types[change['new']]
|
||||
node.dcs_update_from(expiration)
|
||||
expiration_choice.observe(on_expiration_change, names=['value'])
|
||||
|
||||
|
|
@ -498,7 +499,7 @@ baseline_model = models.ExposureModel(
|
|||
presence=models.SpecificInterval(((8., 12.), (13., 17.))),
|
||||
mask=models.Mask.types['No mask'],
|
||||
activity=models.Activity.types['Seated'],
|
||||
expiration=models.Expiration.types['Speaking'],
|
||||
expiration=expiration_types['Speaking'],
|
||||
host_immunity=0.,
|
||||
),
|
||||
evaporation_factor=0.3,
|
||||
|
|
|
|||
|
|
@ -695,19 +695,6 @@ class MultipleExpiration(_ExpirationBase):
|
|||
]).sum(axis=0)
|
||||
|
||||
|
||||
# Typical expirations. The aerosol diameter given is an equivalent
|
||||
# diameter, chosen in such a way that the aerosol volume is
|
||||
# the same as the total aerosol volume given by the full BLO model
|
||||
# (integrated between 0.1 and 30 microns)
|
||||
# The correspondence with the BLO coefficients is given.
|
||||
_ExpirationBase.types = {
|
||||
'Breathing': Expiration(1.3844), # corresponds to B/L/O coefficients of (1, 0, 0)
|
||||
'Speaking': Expiration(5.8925), # corresponds to B/L/O coefficients of (1, 1, 1)
|
||||
'Shouting': Expiration(10.0411), # corresponds to B/L/O coefficients of (1, 5, 5)
|
||||
'Singing': Expiration(10.0411), # corresponds to B/L/O coefficients of (1, 5, 5)
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Activity:
|
||||
#: Inhalation rate in m^3/h
|
||||
|
|
|
|||
|
|
@ -5,6 +5,19 @@ import cara.dataclass_utils
|
|||
import pytest
|
||||
|
||||
|
||||
# Typical expirations. The aerosol diameter given is an equivalent
|
||||
# diameter, chosen in such a way that the aerosol volume is
|
||||
# the same as the total aerosol volume given by the full BLO model
|
||||
# (integrated between 0.1 and 30 microns)
|
||||
# The correspondence with the BLO coefficients is given.
|
||||
expiration_types = {
|
||||
'Breathing': models.Expiration(1.3844), # corresponds to B/L/O coefficients of (1, 0, 0)
|
||||
'Speaking': models.Expiration(5.8925), # corresponds to B/L/O coefficients of (1, 1, 1)
|
||||
'Shouting': models.Expiration(10.0411), # corresponds to B/L/O coefficients of (1, 5, 5)
|
||||
'Singing': models.Expiration(10.0411), # corresponds to B/L/O coefficients of (1, 5, 5)
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def baseline_model():
|
||||
model = models.ConcentrationModel(
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import numpy.testing as npt
|
|||
import pytest
|
||||
|
||||
from cara import models
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -45,7 +46,7 @@ def test_concentration_model_vectorisation(override_params):
|
|||
viable_to_RNA_ratio = 0.5,
|
||||
transmissibility_factor=1.0,
|
||||
),
|
||||
expiration=models._ExpirationBase.types['Breathing'],
|
||||
expiration=expiration_types['Breathing'],
|
||||
host_immunity=0.,
|
||||
),
|
||||
evaporation_factor=0.3,
|
||||
|
|
@ -67,7 +68,7 @@ def simple_conc_model():
|
|||
mask=models.Mask.types['Type I'],
|
||||
activity=models.Activity.types['Seated'],
|
||||
virus=models.Virus.types['SARS_CoV_2'],
|
||||
expiration=models.Expiration.types['Breathing'],
|
||||
expiration=expiration_types['Breathing'],
|
||||
host_immunity=0.,
|
||||
),
|
||||
evaporation_factor=0.3,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from dataclasses import dataclass
|
|||
from cara import models
|
||||
from cara.models import ExposureModel
|
||||
from cara.dataclass_utils import replace
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
|
@ -64,7 +65,7 @@ def known_concentrations(func):
|
|||
mask=models.Mask.types['Type I'],
|
||||
activity=models.Activity.types['Standing'],
|
||||
virus=models.Virus.types['SARS_CoV_2_ALPHA'],
|
||||
expiration=models.Expiration.types['Speaking'],
|
||||
expiration=expiration_types['Speaking'],
|
||||
host_immunity=0.,
|
||||
)
|
||||
normed_func = lambda x: func(x) / dummy_infected_population.emission_rate_when_present()
|
||||
|
|
@ -205,7 +206,7 @@ def test_infectious_dose_vectorisation():
|
|||
viable_to_RNA_ratio = 0.5,
|
||||
transmissibility_factor=1.0,
|
||||
),
|
||||
expiration=models.Expiration.types['Speaking'],
|
||||
expiration=expiration_types['Speaking'],
|
||||
host_immunity=0.,
|
||||
)
|
||||
cm = known_concentrations(lambda t: 1.2)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
|
||||
from cara import models
|
||||
from cara.monte_carlo.data import expiration_distribution
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
def test_multiple_wrong_weight_size():
|
||||
|
|
@ -34,8 +35,8 @@ def test_multiple_wrong_diameters():
|
|||
def test_multiple():
|
||||
weights = (1., 1.)
|
||||
mask = models.Mask.types['Type I']
|
||||
e1 = models.Expiration.types['Breathing']
|
||||
e2 = models.Expiration.types['Singing']
|
||||
e1 = expiration_types['Breathing']
|
||||
e2 = expiration_types['Singing']
|
||||
aerosol_expected = (e1.aerosols(mask) + e2.aerosols(mask))/2.
|
||||
e = models.MultipleExpiration([e1, e2], weights)
|
||||
npt.assert_almost_equal(aerosol_expected, e.aerosols(mask))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import numpy as np
|
|||
import pytest
|
||||
|
||||
import cara.models
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -35,7 +36,7 @@ def test_infected_population_vectorisation(override_params):
|
|||
viable_to_RNA_ratio = 0.5,
|
||||
transmissibility_factor=1.0,
|
||||
),
|
||||
expiration=cara.models._ExpirationBase.types['Breathing'],
|
||||
expiration=expiration_types['Breathing'],
|
||||
host_immunity=0.,
|
||||
)
|
||||
emission_rate = infected.emission_rate(10)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import pytest
|
|||
import cara.models
|
||||
import cara.monte_carlo.models as mc_models
|
||||
import cara.monte_carlo.sampleable
|
||||
from cara.tests.conftest import expiration_types
|
||||
|
||||
|
||||
MODEL_CLASSES = [
|
||||
|
|
@ -53,7 +54,7 @@ def baseline_mc_model() -> cara.monte_carlo.ConcentrationModel:
|
|||
presence=cara.models.SpecificInterval(((0., 4.), (5., 8.))),
|
||||
mask=cara.models.Mask.types['No mask'],
|
||||
activity=cara.models.Activity.types['Light activity'],
|
||||
expiration=cara.models.Expiration.types['Breathing'],
|
||||
expiration=expiration_types['Breathing'],
|
||||
host_immunity=0.,
|
||||
),
|
||||
evaporation_factor=0.3,
|
||||
|
|
|
|||
Loading…
Reference in a new issue