MetaWards.utils API Detail

Functions

add_lookup(network, nthreads) Add in metadata about the network that can be used to look up wards by name of location or region etc.
add_wards_network_distance(network, nthreads) Reads the location data in network.parameters.input_files.position and adds those locations to all of the nodes in the passed network.
allocate_vaccination(network, output_dir) Allocate memory and open files needed to track vaccination
assert_sane_network(network, profiler) This function runs through and checks that the passed network is sane.
build_play_matrix(network, max_nodes, …) Build the play matrix for the passed network
build_wards_network(params, profiler, …) Creates a network of wards using the information provided in the file specified in parameters.input_files.work.
clear_all_infections(infections, nthreads) Clears all infections associated with a model run
create_int_array(size, default) Create a new array.array of the specified size.
create_double_array(size, default) Create a new array.array of the specified size.
create_string_array(size, unicode default) Create an array of python strings of size ‘size’, optionally initialised with ‘default’
create_thread_generators(rng, nthreads) Return a set of random number generators, one for each thread - these are seeded using the next ‘nthreads’ random numbers drawn from the passed generator
delete_ran_binomial(rng) Delete the passed random number generator.
extract(network, population, workspace, …) Extract data from the network and write this to the specified output directory.
fill_in_gaps(network, max_nodes) Fills in gaps in the network
get_available_num_threads() Return the maximum number of threads that are recommended for this computer (the OMP_NUM_THREADS value)
get_min_max_distances(network, nthreads, …) Return the minimum and maximum distances recorded in the network
get_number_of_processes(parallel_scheme, nprocs) This function works out how many processes have been set by the paralellisation system called ‘parallel_scheme’
how_many_vaccinated(vac)
initialise_infections(network) Initialise the data structure used to store the infections
initialise_play_infections(network) Initialise the space used to store the play infections
iterate(network, population, infections, …) Advance the infection by one day for the passed Network, acting on the passed Population.
move_population_from_work_to_play(network, …) This function is not used or implemented, but is implied by the naming scheme…
move_population_from_play_to_work(network, …) And Vice Versa From Work to Play The relevant parameters are network.params.play_to_work and network.params.work_to_play
prepare_worker(params, options) Prepare a worker to receive work to run a model using the passed parameters.
ran_binomial(rng, double p, n) Return a random number drawn from the binomial distribution [p,n] (see gsl_ran_binomial for documentation)
ran_int(rng[, lower, upper]) Draw a random integer from [0,upper] inclusive
ran_uniform(rng) Return a random double drawn from a uniform distribution between zero and one
read_done_file(filename) This function reads the ‘done_file’ from ‘filename’ returning the list of seeded nodes
recalculate_work_denominator_day(network, …) Recalculate the denominator_d for the wards (nodes) in the network for the normal links
recalculate_play_denominator_day(network, …) Recalculate the denominator_d for the wards (nodes) in the network for the play links
redirect_output(outdir) Nice way to redirect stdout and stderr - thanks to Emil Stenström in https://stackoverflow.com/questions/6735917/redirecting-stdout-to-nothing-in-python
rescale_play_matrix(network, nthreads, profiler) Static Play At Home rescaling.
resize_array(a, size, default) Resize the passed array to size ‘size’, adding ‘default’ if this will grow the array
reset_everything(network, profiler, nthreads) Reset everything in the passed network so that it can be used for a new model run
reset_play_matrix(network, nthreads) Resets the play entries in the passed Network.
reset_play_susceptibles(network, nthreads) Resets the ward entries in the passed Network.
reset_work_matrix(network[, nthreads]) Resets the work entries in the passed Network.
run_model(network, infections, rngs, s, …) Actually run the model…
run_models(network, variables, population, …) Run all of the models on the passed Network that are described by the passed VariableSets
run_worker(arguments) Ask the worker to run a model using the passed variables and options.
seed_ran_binomial(seed) Seed and return the random binomial generator.
string_to_ints(string, strings) Convert the passed string (or strings) containing integers (or ranges of integers) into a single sorted list of integers where no value is repeated
vaccinate_same_id(network, risk_ra, sort_ra, …)

Classes

Profiler(name[, parent]) This is a simple profiling class that supports manual instrumenting of the code.
NullProfiler(name[, parent]) This is a null profiler that does nothing