synthpops.pop module

This module provides the layer for communicating with the agent-based model Covasim.

class synthpops.pop.Pop(n=None, max_contacts=None, ltcf_pars=None, school_pars=None, with_industry_code=False, with_facilities=False, use_default=False, use_two_group_reduction=True, average_LTCF_degree=20, ltcf_staff_age_min=20, ltcf_staff_age_max=60, with_school_types=False, school_mixing_type='random', average_class_size=20, inter_grade_mixing=0.1, average_student_teacher_ratio=20, average_teacher_teacher_degree=3, teacher_age_min=25, teacher_age_max=75, with_non_teaching_staff=False, average_student_all_staff_ratio=15, average_additional_staff_degree=20, staff_age_min=20, staff_age_max=75, rand_seed=None, country_location=None, state_location=None, location=None, sheet_name=None, household_method='infer_ages', smooth_ages=False, window_length=7, do_make=True)

Bases: sciris.sc_utils.prettyobj

generate(verbose=False)

Actually generate the network.

Parameters

verbose (bool) – If True, print statements about the population and networks as they’re being generated.

Returns

A dictionary of the full population with ages, connections, and other attributes.

Return type

network (dict)

to_dict()

Export to a dictionary – official way to get the popdict

Example:

popdict = pop.to_dict()
to_json(filename, indent=2, **kwargs)

Export to a JSON file

Example:

pop.to_json('my-pop.json')
save(filename, **kwargs)

Save population to an binary, gzipped object file

Example:

pop.save('my-pop.pop')
static load(filename, *args, **kwargs)

Load from disk from a gzipped pickle.

Parameters
  • filename (str) – the name or path of the file to load from

  • kwargs – passed to sc.loadobj()

Example:

pop = sp.Pop.load('my-pop.pop')
plot_people(*args, **kwargs)

Placeholder example of plotting the people in a population

plot_contacts(*args, **kwargs)

Plot matrices of the contacts for a given layer or layers

synthpops.pop.make_population(*args, **kwargs)

Interface to sp.Pop().to_dict(). Included for backwards compatibility.

synthpops.pop.generate_synthetic_population(*args, **kwargs)

For backwards compatibility only.