covasim.people module

Defines the Person class and functions associated with making people.

class covasim.people.People(pars, strict=True, **kwargs)

Bases: covasim.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. Most initialization happens in BasePeople.

Parameters
  • pars (dict) – the sim parameters, e.g. sim.pars – must have pop_size and n_days keys

  • 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

initialize()

Perform initializations

set_prognoses()

Set the prognoses for each person based on age during initialization. Need to reset the seed because viral loads are drawn stochastically.

update_states_pre(t)

Perform all state updates at the current timestep

update_states_post()

Perform post-timestep updates

update_contacts()

Refresh dynamic contacts, e.g. community

check_inds(current, date, filter_inds=None)

Return indices for which the current state is false and which meet the date criterion

check_infectious()

Check if they become infectious

check_symptomatic()

Check for new progressions to symptomatic

check_severe()

Check for new progressions to severe

check_critical()

Check for new progressions to critical

check_recovery()

Check for recovery

check_death()

Check whether or not this person died on this timestep

check_diagnosed()

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.

check_quar()

Update quarantine state

make_susceptible(inds)

Make person susceptible. This is used during dynamic resampling

infect(inds, hosp_max=None, icu_max=None, source=None, layer=None)
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

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

Returns

number of people infected

Return type

count (int)

test(inds, test_sensitivity=1.0, loss_prob=0.0, test_delay=0)

Method to test people

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

Returns

Whether or not this person tested positive

quarantine(inds, start_date=None, period=None)

Schedule a quarantine

This function will create a request to quarantine a person on the start_date for a period of time. Whether they are on an existing quarantine that gets extended, or whether they are no longer eligible for quarantine, will be checked when the start_date is reached.

Parameters
  • inds (int) – indices of who to quarantine, specified by check_quar()

  • start_date (int) – day to begin quarantine (defaults to the current day, sim.t)

  • period (int) – quarantine duration (defaults to pars[‘quar_period’])

trace(inds, trace_probs, trace_time)

Trace the contacts of the people provided :param inds: indices of whose contacts to trace :type inds: array :param trace_probs: probability of being able to trace people at each contact layer - should have the same keys as contacts :type trace_probs: dict :param trace_time: days it’ll take to trace people at each contact layer - should have the same keys as contacts :type trace_time: dict

plot(*args, **kwargs)

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()