metawards.Parameters¶
-
class
metawards.
Parameters
(input_files: Optional[metawards._inputfiles.InputFiles] = None, disease_params: Optional[metawards._disease.Disease] = None, additional_seeds: Optional[List[str]] = None, length_day: float = 0.7, 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, daily_imports: float = 0.0, ward_seed_index: Optional[int] = None, initial_inf: int = 5, stage_0: str = 'R', UV: float = 0.0, UV_max: Optional[datetime.date] = None, scale_uv: float = 1.0, bg_foi: float = 0.0, user_params: Dict[str, float] = <factory>, adjustments: Optional[List[metawards._variableset.VariableSet]] = None, _name: Optional[str] = None, _version: Optional[str] = None, _authors: Optional[str] = None, _contacts: Optional[str] = None, _references: Optional[str] = None, _filename: Optional[str] = None, _repository: Optional[str] = None, _repository_version: Optional[str] = None, _repository_branch: Optional[str] = None, _repository_dir: Optional[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: Optional[metawards._inputfiles.InputFiles] = None, disease_params: Optional[metawards._disease.Disease] = None, additional_seeds: Optional[List[str]] = None, length_day: float = 0.7, 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, daily_imports: float = 0.0, ward_seed_index: Optional[int] = None, initial_inf: int = 5, stage_0: str = 'R', UV: float = 0.0, UV_max: Optional[datetime.date] = None, scale_uv: float = 1.0, bg_foi: float = 0.0, user_params: Dict[str, float] = <factory>, adjustments: Optional[List[metawards._variableset.VariableSet]] = None, _name: Optional[str] = None, _version: Optional[str] = None, _authors: Optional[str] = None, _contacts: Optional[str] = None, _references: Optional[str] = None, _filename: Optional[str] = None, _repository: Optional[str] = None, _repository_version: Optional[str] = None, _repository_branch: Optional[str] = None, _repository_dir: Optional[str] = None) → None¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__delattr__
(name, /)Implement delattr(self, name).
__dir__
()Default dir() implementation.
__eq__
(other)Return self==value.
__format__
(format_spec, /)Default object formatter.
__ge__
(value, /)Return self>=value.
__getattribute__
(name, /)Return getattr(self, name).
__getitem__
(demographic)Return the parameters that should be used for the demographic subnetwork called ‘demographic’.
__gt__
(value, /)Return self>value.
__init__
([input_files, disease_params, …])Initialize self.
__init_subclass__
This method is called when a class is subclassed.
__le__
(value, /)Return self<=value.
__lt__
(value, /)Return self<value.
__ne__
(value, /)Return self!=value.
__new__
(**kwargs)Create and return a new object.
__reduce__
()Helper for pickle.
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
__sizeof__
()Size of object in memory, in bytes.
__str__
()Return str(self).
__subclasshook__
Abstract classes can override this to customize issubclass().
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.
Return the names of demographics that have specialised parameters that are different to those of the overall network
Attributes
Seasonality parameter
Date when transmission should be at a maximum
__annotations__
__dataclass_fields__
__dataclass_params__
__dict__
__doc__
__hash__
__module__
__weakref__
list of weak references to the object (if defined)
_authors
_contacts
_filename
_name
_references
_repository
_repository_branch
_repository_dir
_repository_version
_subparams
The parameters for demographic sub-networks.
_version
The set of files that contain additional seeds that seed the outbreak during the model run
All of the VariableSet adjustments that have been applied to these parameters
The global background force of infection (FOI).
proportion of daily imports if there are additional infections
The set of parameters that define the disease
The cutoff distance in km beyond which workers or players cannot move
dyn_play_at_home
The number of initial infections if there are daily imports
The set of input files that define the model Network
The fraction of day considered “day” for work, e.g.
play_to_work
The global scale_uv.
how to treat the * state (stage 0).
static_play_at_home
The index of the seeding ward if there are daily imports
work_to_play
-
UV
: float = 0.0¶ Seasonality parameter
-
UV_max
: datetime.date = None¶ Date when transmission should be at a maximum
-
__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
: List[str] = None¶ The set of files that contain additional seeds that seed the outbreak during the model run
-
adjustments
: List[metawards._variableset.VariableSet] = None¶ All of the VariableSet adjustments that have been applied to these parameters
-
bg_foi
: float = 0.0¶ The global background force of infection (FOI). This is combined with the per-ward level bg_foi to give a single value
-
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
: float = 0.0¶ proportion of daily imports if there are additional infections
-
disease_params
: metawards._disease.Disease = None¶ The set of parameters that define the disease
-
dyn_dist_cutoff
: float = 10000000.0¶ The cutoff distance in km beyond which workers or players cannot move
-
static
get_repository
(repository: Optional[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
: int = 5¶ The number of initial infections if there are daily imports
-
input_files
: metawards._inputfiles.InputFiles = None¶ The set of input files that define the model Network
-
length_day
: float = 0.7¶ The fraction of day considered “day” for work, e.g. 0.7 * 24 hours
-
static
load
(parameters: str = 'march29', repository: Optional[str] = None, folder: str = 'parameters', filename: Optional[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
-
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
-
scale_uv
: float = 1.0¶ The global scale_uv. This is combined with the population and per-ward level scale_uvs to give a single value
-
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
-
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
: str = 'R'¶ how to treat the * state (stage 0). This should be a string describing the method. Currently “R”, “E” and “disable” are supported. Not needed if the mapping is specified explicitly in the disease
-
user_params
: Dict[str, float]¶ User parameters
-
ward_seed_index
: int = None¶ The index of the seeding ward if there are daily imports
-