Added uniform distribution for masks
This commit is contained in:
parent
3f38897099
commit
cbb3846eb7
3 changed files with 25 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ from cara import models
|
|||
from cara import data
|
||||
import cara.monte_carlo as mc
|
||||
from .. import calculator
|
||||
from cara.monte_carlo.data import activity_distributions, virus_distributions
|
||||
from cara.monte_carlo.data import activity_distributions, virus_distributions, mask_distributions
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
|
@ -301,7 +301,10 @@ class FormData:
|
|||
def mask(self) -> models.Mask:
|
||||
# Initializes the mask type if mask wearing is "continuous", otherwise instantiates the mask attribute as
|
||||
# the "No mask"-mask
|
||||
mask = models.Mask.types[self.mask_type if self.mask_wearing_option == "mask_on" else 'No mask']
|
||||
if self.mask_wearing_option == 'mask_on':
|
||||
mask = mask_distributions[self.mask_type]
|
||||
else:
|
||||
mask = models.Mask.types['No mask']
|
||||
return mask
|
||||
|
||||
def infected_population(self) -> mc.InfectedPopulation:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import numpy as np
|
||||
|
||||
import cara.monte_carlo as mc
|
||||
from cara.monte_carlo.sampleable import Normal,LogNormal,LogCustomKernel
|
||||
from cara.monte_carlo.sampleable import Normal,LogNormal,LogCustomKernel, Uniform
|
||||
|
||||
|
||||
# From CERN-OPEN-2021-04 and refererences therein
|
||||
|
|
@ -58,3 +58,10 @@ virus_distributions = {
|
|||
infectious_dose=60/1.6,
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
# From CERN-OPEN-2021-04 and refererences therein
|
||||
mask_distributions = {
|
||||
'Type I': mc.Mask(Uniform(0.25, 0.80)),
|
||||
'FFP2': mc.Mask(Uniform(0.83, 0.91)),
|
||||
}
|
||||
|
|
@ -28,6 +28,18 @@ class Normal(SampleableDistribution):
|
|||
return np.random.normal(self.mean, self.standard_deviation, size=size)
|
||||
|
||||
|
||||
class Uniform(SampleableDistribution):
|
||||
"""
|
||||
Defines a continuous uniform distribution
|
||||
"""
|
||||
def __init__(self, low: float, high: float):
|
||||
self.low = low
|
||||
self.high = high
|
||||
|
||||
def generate_samples(self, size: int) -> float_array_size_n:
|
||||
return np.random.uniform(self.low, self.high, size=size)
|
||||
|
||||
|
||||
class LogNormal(SampleableDistribution):
|
||||
"""
|
||||
Defines a lognormal distribution (i.e. Gaussian distribution vs. the
|
||||
|
|
|
|||
Loading…
Reference in a new issue