rsvsim.people module¶
Defines the People class and functions associated with making people and handling the transitions between states (e.g., from susceptible to infected).
-
class
rsvsim.people.
People
(pars, strict=True, **kwargs)[source]¶ Bases:
rsvsim.base.BasePeople
A class to perform all the operations on the people. This class is usually not invoked directly, but instead is created automatically by the sim. The only required input argument is the population size, but typically the full parameters dictionary will get passed instead since it will be needed before the People object is initialized.
Note that this class handles the mechanics of updating the actual people, while BasePeople takes care of housekeeping (saving, loading, exporting, etc.). Please see the BasePeople class for additional methods.
- Parameters
pars (dict) – the sim parameters, e.g. sim.pars – alternatively, if a number, interpreted as pop_size
strict (bool) – whether or not to only create keys that are already in self.meta.person; otherwise, let any key be set
kwargs (dict) – the actual data, e.g. from a popdict, being specified
::Examples:
ppl1 = cv.People(2000) sim = cv.Sim() ppl2 = cv.People(sim.pars)
-
set_prognoses
(new_year_inds=None)[source]¶ Set the prognoses for each person based on age during initialization. Gets called throughout sim for people on the day they age a year. Need to reset the seed because viral loads are drawn stochastically.
-
check_conception
()[source]¶ Method to determine who becomes pregnant on this time step based on age-specific fertility rate
-
check_delivery
()[source]¶ Method to check if it’s the day a woman has given birth and return inds of women who give birth today, otherwise step pregnancy forward in time
-
check_post_partum
()[source]¶ Method to check if it’s the day a woman becomes eligible to get pregnant again
-
check_inds
(current, date, filter_inds=None)[source]¶ Return indices for which the current state is false and which meet the date criterion
-
check_recovery
(inds=None, filter_inds='is_exp')[source]¶ Check for recovery.
More complex than other functions to allow for recovery to be manually imposed for a specified set of indices.
-
check_background_mortality
()[source]¶ Check whether or not people died from background mortality on this timestep
-
check_diagnosed
()[source]¶ Check for new diagnoses. Since most data are reported with diagnoses on the date of the test, this function reports counts not for the number of people who received a positive test result on a day, but rather, the number of people who were tested on that day who are schedule to be diagnosed in the future.
-
make_naive
(inds, reset_vx=False)[source]¶ Make a set of people naive. This is used during dynamic resampling.
- Parameters
inds (array) – list of people to make naive
reset_vx (bool) – whether to reset vaccine-derived immunity
-
make_nonnaive
(inds, date_recovered=- 365, genotype='groupA')[source]¶ Make a set of people non-naive.
This can be done either by setting only susceptible and naive states, or else by setting them as if they have been infected and recovered.
-
infect
(inds, hosp_max=None, icu_max=None, source=None, layer=None, genotype=0)[source]¶ Infect people and determine their eventual outcomes.
Every infected person can infect other people, regardless of whether they develop symptoms
Infected people that develop symptoms are disaggregated into mild vs. severe (=requires hospitalization) vs. critical (=requires ICU)
Every asymptomatic, mildly symptomatic, and severely symptomatic person recovers
Critical cases either recover or die
Method also deduplicates input arrays in case one agent is infected many times and stores who infected whom in infection_log list.
- Parameters
inds (array) – array of people to infect
hosp_max (bool) – whether or not there is an acute bed available for this person
icu_max (bool) – whether or not there is an ICU bed available for this person
source (array) – source indices of the people who transmitted this infection (None if an importation or seed infection)
layer (str) – contact layer this infection was transmitted on
genotype (int) – the genotype people are being infected by
- Returns
number of people infected
- Return type
count (int)
-
test
(inds, test_sensitivity=1.0, loss_prob=0.0, test_delay=0)[source]¶ Method to test people. Typically not to be called by the user directly; see the test_num() and test_prob() interventions.
- Parameters
inds – indices of who to test
test_sensitivity (float) – probability of a true positive
loss_prob (float) – probability of loss to follow-up
test_delay (int) – number of days before test results are ready
-
plot
(*args, **kwargs)[source]¶ Plot statistics of the population – age distribution, numbers of contacts, and overall weight of contacts (number of contacts multiplied by beta per layer).
- Parameters
bins (arr) – age bins to use (default, 0-100 in one-year bins)
width (float) – bar width
font_size (float) – size of font
alpha (float) – transparency of the plots
fig_args (dict) – passed to pl.figure()
axis_args (dict) – passed to pl.subplots_adjust()
plot_args (dict) – passed to pl.plot()
do_show (bool) – whether to show the plot
fig (fig) – handle of existing figure to plot into
-
story
(uid, *args)[source]¶ Print out a short history of events in the life of the specified individual.
- Parameters
uid (int/list) – the person or people whose story is being regaled
args (list) – these people will tell their stories too
Example:
sim = cv.Sim(pop_type='hybrid', verbose=0) sim.run() sim.people.story(12) sim.people.story(795)