Source code for emod_api.demographics.PreDefinedDistributions

from emod_api.demographics.PropertiesAndAttributes import IndividualAttributes
import copy


[docs]class ConstantDistribution: """ Wrapping this class around a Distributions disables __setattr__ and makes the wrapped objects constant. """ def __init__(self, distribution): self.distribution = distribution
[docs] def to_dict(self): """ Calls the to_dict() method of the wrapped distribution. """ return self.distribution.to_dict()
[docs] def copy(self): """ Creates a deepcopy of the wrapped Distribution object. """ return copy.deepcopy(self.distribution)
def __getattr__(self, item): return self.distribution.__dict__[item] def __setattr__(self, key, value): if key == "distribution": # only allow to set member 'distribution' vars(self)["distribution"] = value else: raise Exception("The object is constant and cannot be changed. Please use copy() to make a copy of the object.")
# Mortality Distributions Constant_Mortality = ConstantDistribution(IndividualAttributes.MortalityDistribution(num_population_axes=2, axis_names=["gender", "age"], axis_units=["male=0,female=1", "years"], axis_scale_factors=[1, 365], population_groups=[[0, 1], [0]], result_scale_factor=1, result_units="daily probability of dying", result_values=[[0.5], [0.5]])) SEAsia_Diag = ConstantDistribution(IndividualAttributes.MortalityDistribution(num_population_axes=2, num_population_groups=[2, 1], axis_names=["gender", "age"], axis_units=["male=0,female=1", "years"], axis_scale_factors=[1, 365], population_groups=[[0, 1], [0, 1, 5, 25, 40, 60, 80, 95]], result_scale_factor=0.00000274, result_units="annual deaths per 1000 individuals", result_values=[[35, 5, 1, 2, 5, 30, 350, 1000], [35, 5, 1, 2, 5, 30, 350, 1000]])) # Age Distributions AgeDistribution_Mosambique = ConstantDistribution(IndividualAttributes.AgeDistribution(distribution_values=[[0.1059, 0.2005, 0.3011, 0.4154, 0.5256, 0.6186, 0.7023, 0.7492, 0.8062, 0.8556, 0.8989, 0.9309, 0.9558, 0.9727, 0.9850, 0.9930, 1.0, 1.0]], result_scale_factor=1, result_values=[[0, 1825, 3650, 5475, 7300, 9125, 10950, 12775, 14600, 16425, 18250, 20075, 21900, 23725, 25550, 27375, 29200, 32850]])) AgeDistribution_Mozambique = AgeDistribution_Mosambique # Fix spelling AND stay backwards compatible AgeDistribution_SEAsia = ConstantDistribution(IndividualAttributes.AgeDistribution(distribution_values=[[0, 0.05131030266354994, 0.10043221053926492, 0.1474590550263547, 0.1924801872714009, 0.23553394531326288, 0.2767982572728267, 0.3163026374086899, 0.3541221439117167, 0.39032863400649825, 0.42499084497300144, 0.45817443053902823, 0.4899427290085593, 0.5203228231617444, 0.5494404809472532, 0.5773161674455726, 0.6040027732995582, 0.6295511892763999, 0.6540099573139143, 0.6774255492073296, 0.6998423831299495, 0.7212794983576319, 0.7418258161901273, 0.7614958268507029, 0.7803269034939072, 0.7983547388766181, 0.8156135975966274, 0.8321363617839843, 0.8479544246776415, 0.8630812779943506, 0.8775794381259877, 0.8914592027768785, 0.9047469918889075, 0.9174680522677974, 0.9296465540312573, 0.9413055618865094, 0.9524672736916279, 0.9631412421412441, 0.9733716589667161, 0.9831657440381932, 0.9925420312569604, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999, 0.9999999999999999]], result_scale_factor=1, result_values=[[0, 894, 1788, 2682, 3576, 4469, 5363, 6257, 7151, 8045, 8939, 9833, 10727, 11620, 12514, 13408, 14302, 15196, 16090, 16984, 17878, 18771, 19665, 20559, 21453, 22347, 23241, 24135, 25029, 25922, 26816, 27710, 28604, 29498, 30392, 31286, 32180, 33073, 33967, 34861, 35755, 36649, 37543, 38437, 39331, 40224, 41118, 42012, 42906, 43800]])) AgeDistribution_SSAfrica = ConstantDistribution(IndividualAttributes.AgeDistribution(distribution_values=[[0, 0.0874071047257126, 0.16737703029028825, 0.24054255502934432, 0.3074826208089575, 0.3686613109892203, 0.4246989953576121, 0.47596861687986874, 0.522875857439861, 0.5657918836833704, 0.6050561581209166, 0.6409789502300984, 0.673845189729804, 0.7038827889943505, 0.7313967340232171, 0.7565694182395838, 0.7795999267083209, 0.800670843446059, 0.8199488968312877, 0.8375866300551988, 0.8537235049479931, 0.8684713425858462, 0.8819801447631247, 0.8943395212968485, 0.9056472694733465, 0.915992766949792, 0.9254579031519203, 0.9341176809019833, 0.9420406227370048, 0.9492816775343581, 0.9559142701362873, 0.9619824759265774, 0.9675343569769829, 0.9726138439176826, 0.9772611297725079, 0.981512933676782, 0.9854029390818465, 0.9889581498026758, 0.9922146658619191, 0.9951940927775798, 0.9979199629370703, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013, 1.0000000000000013]], result_scale_factor=1, result_values=[[0, 894, 1788, 2682, 3576, 4469, 5363, 6257, 7151, 8045, 8939, 9833, 10727, 11620, 12514, 13408, 14302, 15196, 16090, 16984, 17878, 18771, 19665, 20559, 21453, 22347, 23241, 24135, 25029, 25922, 26816, 27710, 28604, 29498, 30392, 31286, 32180, 33073, 33967, 34861, 35755, 36649, 37543, 38437, 39331, 40224, 41118, 42012, 42906, 43800]])) AgeDistribution_Americas = ConstantDistribution(IndividualAttributes.AgeDistribution(distribution_values=[[0.0, 0.05561604975889523, 0.1085504268939315, 0.15893242961061219, 0.20688512221052024, 0.25247579365254375, 0.2959175591522817, 0.33726466606783617, 0.3766181094626717, 0.41407401508472774, 0.4497238096138797, 0.4836543370003379, 0.5159488150771436, 0.5466525950728578, 0.5759094477241161, 0.6037554939431383, 0.6302586709185651, 0.6554839272822989, 0.6794928786705416, 0.7023441700189808, 0.7240935400772673, 0.744771455413333, 0.7644749339811272, 0.7832283548978808, 0.8010775258283467, 0.8180659536755108, 0.8342351489080828, 0.8496247034407376, 0.864272208087148, 0.8781982393670924, 0.8914678963323107, 0.9040976746809025, 0.916118474493211, 0.9275596580218793, 0.9384491718638799, 0.9488135402059068, 0.9586781263987578, 0.9680568209592978, 0.9769935431718086, 0.9854993553707374, 0.9935949610029462, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997, 0.9999999999999997]], result_scale_factor=1, result_values=[[0, 894, 1788, 2682, 3576, 4469, 5363, 6257, 7151, 8045, 8939, 9833, 10727, 11620, 12514, 13408, 14302, 15196, 16090, 16984, 17878, 18771, 19665, 20559, 21453, 22347, 23241, 24135, 25029, 25922, 26816, 27710, 28604, 29498, 30392, 31286, 32180, 33073, 33967, 34861, 35755, 36649, 37543, 38437, 39331, 40224, 41118, 42012, 42906, 43800]]))