immunity
immunity
Defines classes and methods for calculating immunity
Classes
| Name | Description |
|---|---|
| variant | Add a new variant to the sim |
variant
immunity.variant(variant, days, label=None, n_imports=1, rescale=True)Add a new variant to the sim
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| variant | str / dict | name of variant, or dictionary of parameters specifying information about the variant | required |
| days | int / list | day(s) on which new variant is introduced | required |
| label | str | if variant is supplied as a dict, the name of the variant | None |
| n_imports | int | the number of imports of the variant to be added | 1 |
| rescale | bool | whether the number of imports should be rescaled with the population | True |
Example::
alpha = cv.variant('alpha', days=10) # Make the alpha variant B117 active from day 10
p1 = cv.variant('p1', days=15) # Make variant P1 active from day 15
my_var = cv.variant(variant={'rel_beta': 2.5}, label='My variant', days=20)
sim = cv.Sim(variants=[alpha, p1, my_var]).run() # Add them all to the sim
sim2 = cv.Sim(variants=cv.variant('alpha', days=0, n_imports=20), pop_infected=0).run() # Replace default variant with alpha
Methods
| Name | Description |
|---|---|
| apply | Introduce new infections with this variant |
| initialize | Update variant info in sim |
| parse | Unpack variant information, which may be given as either a string or a dict |
apply
immunity.variant.apply(sim)Introduce new infections with this variant
initialize
immunity.variant.initialize(sim)Update variant info in sim
parse
immunity.variant.parse(variant=None, label=None)Unpack variant information, which may be given as either a string or a dict