metawards.Parameters¶
- 
class 
metawards.Parameters(input_files: metawards._inputfiles.InputFiles = None, uv_filename: str = None, disease_params: metawards._disease.Disease = None, additional_seeds: List[str] = None, length_day: float = 0.7, plength_day: float = 0.5, initial_inf: int = 5, static_play_at_home: float = 0.0, dyn_play_at_home: float = 0.0, dyn_dist_cutoff: float = 10000000.0, play_to_work: float = 0.0, work_to_play: float = 0.0, local_vaccination_thresh: int = 4, global_detection_thresh: int = 4, daily_ward_vaccination_capacity: int = 5, neighbour_weight_threshold: float = 0.0, daily_imports: float = 0.0, stage_0: str = 'R', UV: float = 0.0, user_params: Dict[str, float] = None, adjustments: List[metawards._variableset.VariableSet] = None, _name: str = None, _version: str = None, _authors: str = None, _contacts: str = None, _references: str = None, _filename: str = None, _repository: str = None, _repository_version: str = None, _repository_branch: str = None, _repository_dir: str = None)[source]¶ The full set of Parameters that are used to control the model outbreak over a Network. The combination of a Network and a Parameters defines the model outbreak.
Load the Parameters using the Parameters.load function, and then add extra data using the various “set” and “add” functions, e.g.
Examples
>>> params = Parameters.load("march29") >>> params.set_disease("ncov") >>> params.set_input_files("2011Data") >>> params.add_seeds("ExtraSeedsBrighton.dat")
- 
__init__(input_files: metawards._inputfiles.InputFiles = None, uv_filename: str = None, disease_params: metawards._disease.Disease = None, additional_seeds: List[str] = None, length_day: float = 0.7, plength_day: float = 0.5, initial_inf: int = 5, static_play_at_home: float = 0.0, dyn_play_at_home: float = 0.0, dyn_dist_cutoff: float = 10000000.0, play_to_work: float = 0.0, work_to_play: float = 0.0, local_vaccination_thresh: int = 4, global_detection_thresh: int = 4, daily_ward_vaccination_capacity: int = 5, neighbour_weight_threshold: float = 0.0, daily_imports: float = 0.0, stage_0: str = 'R', UV: float = 0.0, user_params: Dict[str, float] = None, adjustments: List[metawards._variableset.VariableSet] = None, _name: str = None, _version: str = None, _authors: str = None, _contacts: str = None, _references: str = None, _filename: str = None, _repository: str = None, _repository_version: str = None, _repository_branch: str = None, _repository_dir: str = None) → None¶ 
Methods
__init__(input_files, uv_filename, …)add_seeds(filename)Add an ‘additional seeds’ file that can be used to seed wards with new infections at different times and locations. copy(include_subparams)Return a safe copy of these parameters, which does not include any subnetwork parameters if ‘include_subparams’ is False default()Return the default set of parameters get_repository(repository)Return the repository location and version information for the passed repository load(parameters, repository, folder, filename)This will return a Parameters object containing all of the parameters loaded from the parameters found in file f”{repository}/{folder}/{parameters}.json” read_variables(filename, line_numbers)Read in extra variable parameters from the specified line number(s) of the specified file, returning the list of the dictionaries of variables that have been read. set_disease(disease, silent)“Set the disease that will be modelled set_input_files(input_files)Set the input files that are used to initialise the simulation set_variables(variables)This function sets the adjustable variable values to those specified in ‘variables’ in A COPY OF THIS PARAMETERS OBJECT. specialised_demographics()Return the names of demographics that have specialised parameters that are different to those of the overall network Attributes
UVSeasonality parameter additional_seedsThe set of files that contain additional seeds that seed the outbreak during the model run adjustmentsAll of the VariableSet adjustments that have been applied to these parameters daily_importsproportion of daily imports daily_ward_vaccination_capacitydisease_paramsThe set of parameters that define the disease dyn_dist_cutoffdyn_play_at_homeglobal_detection_threshinitial_infThe number of initial infections input_filesThe set of input files that define the model Network length_dayThe fraction of day considered “day” for work, e.g. local_vaccination_threshneighbour_weight_thresholdplay_to_workplength_dayThe fraction of day considered “day” for play stage_0how to treat the * state (stage 0). static_play_at_homeuser_paramsUser parameters uv_filenameThe name of the UV file work_to_play- 
UV= 0.0¶ Seasonality parameter
- 
__getitem__(demographic: str)[source]¶ Return the parameters that should be used for the demographic subnetwork called ‘demographic’. If these have not been set specifically then the parameters for the overall network are used
- 
add_seeds(filename: str)[source]¶ Add an ‘additional seeds’ file that can be used to seed wards with new infections at different times and locations. Several additional_seed files can be added
Parameters: filename (str) – Name of the file containing the additional seeds 
- 
additional_seeds= None¶ The set of files that contain additional seeds that seed the outbreak during the model run
- 
adjustments= None¶ All of the VariableSet adjustments that have been applied to these parameters
- 
copy(include_subparams: bool = False)[source]¶ Return a safe copy of these parameters, which does not include any subnetwork parameters if ‘include_subparams’ is False
- 
daily_imports= 0.0¶ proportion of daily imports
- 
disease_params= None¶ The set of parameters that define the disease
- 
static 
get_repository(repository: str = None)[source]¶ Return the repository location and version information for the passed repository
Parameters: repository (str) – Location on the filesystem of the repository. If this is None then it will be searched for using first the environment variable METAWARDSDATA, then $HOME/GitHub/MetaWardsData, then ./METAWARDSDATA Returns: (repository, version) – A tuple of the location on disk of the repository, plus the version information (git ID etc) Return type: tuple 
- 
initial_inf= 5¶ The number of initial infections
- 
input_files= None¶ The set of input files that define the model Network
- 
length_day= 0.7¶ The fraction of day considered “day” for work, e.g. 0.7 * 24 hours
- 
static 
load(parameters: str = 'march29', repository: str = None, folder: str = 'parameters', filename: str = None)[source]¶ This will return a Parameters object containing all of the parameters loaded from the parameters found in file f”{repository}/{folder}/{parameters}.json”
By default this will load the march29 parameters from $HOME/GitHub/model_data/2011Data/parameters/march29.json
Alternatively, you can provide the exact path to the filename via the ‘filename’ argument
Parameters: - parameters (str) – The name of the parameters to load. This is the name that will be searched for in the METAWARDSDATA parameters directory
 - repository (str) – The location of the cloned METAWARDSDATA repository
 - folder (str) – The name of the folder within the METAWARDSDATA repository that contains the parameters
 - filename (str) – The name of the file to load the parameters from - this directly loads this file without searching through the METAWARDSDATA repository
 
Returns: params – The constructed and validated parameters
Return type: 
- 
plength_day= 0.5¶ The fraction of day considered “day” for play
- 
static 
read_variables(filename: str, line_numbers: List[int])[source]¶ Read in extra variable parameters from the specified line number(s) of the specified file, returning the list of the dictionaries of variables that have been read. You can then apply those variable parameters using the ‘set_variables’ function
Parameters: - filename (str) – The file from which to read the adjustable variables
 - line_numbers (List[int]) – All of the line numbers from which to read. If this is None then all lines will be read.
 
Returns: variables – The VariableSets containing all of the adjustable variables
Return type: 
- 
set_disease(disease: metawards._disease.Disease, silent: bool = True)[source]¶ “Set the disease that will be modelled
Parameters: - disease – The disease to be modelled. If a string is passed
 - the disease will be loaded using that string (then) –
 - silent – Whether or not to suppress printing out the disease
 
- 
set_input_files(input_files: metawards._inputfiles.InputFiles)[source]¶ Set the input files that are used to initialise the simulation
Parameters: input_files (InputFiles) – The set of input files that will be used to load the Network. If a string is passed then the InputFiles will be loaded based on that string. 
- 
set_variables(variables: metawards._variableset.VariableSet)[source]¶ This function sets the adjustable variable values to those specified in ‘variables’ in A COPY OF THIS PARAMETERS OBJECT. This returns the copy. It does not change this object
Parameters: variables (VariableSet) – The variables that will be adjusted before the model run. This adjusts the parameters and returns them in a deep copy Returns: params – A copy of this set of parameters with the variables adjusted Return type: Parameters 
- 
specialised_demographics() → List[str][source]¶ Return the names of demographics that have specialised parameters that are different to those of the overall network
- 
stage_0= 'R'¶ how to treat the * state (stage 0). This should be a string describing the method. Currently “R”, “E” and “disable” are supported
- 
user_params= None¶ User parameters
- 
uv_filename= None¶ The name of the UV file
-