demographics_utils
apply_to_defaults_or_nodes(demog, fn, *args)
Apply the fn
function either to the Defaults
dictionary or to each of the nodes depending
if the IndividualAttributes
parameter is present in the Defaults
or not.
.. todo::
This function should be refactored to look at both the Defaults
and each individual nodes.
It will make sure that if a node override the default IndividualAttributes
the change will still
be effective.
:param demog: The demographic file represented as a dictionary
:param fn: The function to apply the Defaults
or individual nodes
:param args: Argument list needed by fn
:return: Nothing
Source code in emod_api/demographics/demographics_utils.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
set_demog_distributions(filename, distributions)
Apply distributions to a given demographics file. The distributions needs to be formatted as a list of (name, distribution, par1, par2) with:
- name: Immunity, Risk, Age, Prevalence or MigrationHeterogeneity
- distribution: One distribution contained in
distribution_types
- par1, par2: the values for the distribution parameters
.. code-block:: python
1 2 3 4 5 6 7 |
|
:param filename: the demographics file as json :param distributions: the different distributions to set contained in a list :return: Nothing
Source code in emod_api/demographics/demographics_utils.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
set_growing_demographics(cb, use_existing=False)
This function creates a growing population. It works the same way as the :any:set_static_demographics
but with
a birth rate more important than the death rate which leads to a growing population.
.. todo:: Make sure that the population is 1000 individuals. For now rely on the fact that the base demographics file will be 1000 Initial Population.
:param cb: The :py:class:DTKConfigBuilder <dtk.utils.core.DTKConfigBuilder>
object
:param use_existing: If True
will only take the demographics file name and add the .growing to it. If False
will create a growing demographics file based on the specified demographics file.
:return: Nothing
Source code in emod_api/demographics/demographics_utils.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
set_immune_mod(filename, distribution, par1, par2)
Set the ImmunityDistributionFlag
, ImmunityDistribution1
and ImmunityDistribution2
in a demographics file.
:param filename: The demographics file location
:param distribution: The selected distribution (need to come from distribution_types
)
:param par1: Parameter 1 of the distribution
:param par2: Parameter 2 of the distribution (may be unused depending on the selected distribution)
:return: Nothing
Source code in emod_api/demographics/demographics_utils.py
65 66 67 68 69 70 71 72 73 74 75 |
|
set_risk_mod(filename, distribution, par1, par2)
Set the RiskDistributionFlag
, RiskDistribution1
and RiskDistribution2
in a demographics file.
:param filename: The demographics file location
:param distribution: The selected distribution (need to come from distribution_types
)
:param par1: Parameter 1 of the distribution
:param par2: Parameter 2 of the distribution (may be unused depending on the selected distribution)
:return: Nothing
Source code in emod_api/demographics/demographics_utils.py
52 53 54 55 56 57 58 59 60 61 62 |
|
set_static_demographics(cb, use_existing=False)
Create a static demographics based on the demographics file specified in the config file
of the :py:class:DTKConfigBuilder
object passed to the function.
This function takes the current demographics file and adjust the birth rate/death rate to get a static population (the deaths are always compensated by new births).
.. todo:: Make sure that the population is 1000 individuals. For now rely on the fact that the base demographics file will be 1000 Initial Population.
:param cb: The config builder object
:param use_existing: If True
will only take the demographics file name and add the .static to it. If False
will create a static demographics file based on the specified demographics file.
:return: Nothing
Source code in emod_api/demographics/demographics_utils.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
|