Welcome to emodpy-hiv

emodpy-hiv is a collection of Python scripts and utilities created to streamline user interactions with EMOD and idmtools for modeling generic diseases. Much of the functionality is inherited from the emod_api and emodpy packages.

Additional information about how to use idmtools can be found at in Welcome to idmtools. Additional information about EMOD HIV parameters can be found in EMOD parameter reference.

If you have questions, see Frequently asked questions for general questions about all emodpy functionality or Frequently asked questions for functionality specific to emodpy-hiv.

Installation

You can install emodpy-hiv using the instructions in the GitHub repository README.

Frequently asked questions

As you get started with emodpy-hiv, you may have questions. The most common questions are answered below. The most common questions are answered below. For questions related to functionality in related packages, see Frequently asked questions for idmtools, Frequently asked questions for emod-api, and Frequently asked questions for emodpy.

How do I set configuration parameters?

Define your own parameter-setting function such as set_param_fn and pass that function to the emodpy task creator as the param_custom_cb parameter. In that function, you can set the parameters directly. For example:

    config.parameters.Enable_Demographics_Reporting = 0  # just because I don't like our default for this

    # config hacks until schema fixes arrive
    config.parameters.pop( "Serialized_Population_Filenames" )
    config.parameters.pop( "Serialization_Time_Steps" )
    config.parameters.Report_HIV_Event_Channels_List = []
    config.parameters.Male_To_Female_Relative_Infectivity_Ages = [] # 15,25,35 ]
    config.parameters.Male_To_Female_Relative_Infectivity_Multipliers = [] # 5, 1, 0.5 ]
    # This one is crazy! :(
    config.parameters.Maternal_Infection_Transmission_Probability = 0

    return config


def build_camp():
    """
    Build a campaign input file for the DTK using emod_api.
    Right now this function creates the file and returns the filename. If calling code just needs an asset that's fine.

See examples/start_here/example.py. for additional information.

If you prefer something more modular, you can call a function in a standalone script/file that sets the configuration parameters.

Are there parameter defaults?

Great question. If you don’t set any configuration parameters, they will have defaults based on the schema. There are not yet configuration parameter defaults specific to HIV.

The HIV team has some demographic parameter defaults set using emodpy_hiv.demographics.DemographicsTemplates.AddDefaultSociety(). They can be seen below.

def set_society_configs( config ):
    print( "TBD: Should be adding some implicit config here." )
    return config

def AddDefaultSociety( demog ):
    """
    Adds a PFA config based on IDM defaults.
    """
    setting = {
        "Society" : {
            "Concurrency_Configuration" : 
            {
                "Probability_Person_Is_Behavioral_Super_Spreader" : 0,
                "Individual_Property_Name": "NONE", 
                "NONE": 
                {
                    "Extra_Relational_Flag_Type": "Independent"
                }
            },
            "TRANSITORY" :
            {
                "Concurrency_Parameters" :
                {
                    "NONE": 
                    {
                        "Max_Simultaneous_Relationships_Female": 1,
                        "Max_Simultaneous_Relationships_Male"  : 1,
                        "Prob_Extra_Relationship_Female"       : 0,
                        "Prob_Extra_Relationship_Male"         : 0
                    }
                },
                "Relationship_Parameters" :
                {
                    "Coital_Act_Rate" : 0.33,
                    "Condom_Usage_Probability" :
                    {
                        "Min": 0.10,
                        "Max": 0.90,
                        "Mid": 2000,
                        "Rate": 1
                    },
                    "Duration_Weibull_Heterogeneity": 0.833333333,
                    "Duration_Weibull_Scale": 0.956774771214,
                    "Migration_Actions" : [ "TERMINATE" ],
                    "Migration_Actions_Distribution" : [ 1.0 ]
                },
                "Pair_Formation_Parameters" :
                {
                    "Formation_Rate_Type" : "CONSTANT",
                    "Formation_Rate_Constant": 0.0014424307254,
                    "Update_Period" : 0.0,
                    "Extra_Relational_Rate_Ratio_Male": 1,
                    "Extra_Relational_Rate_Ratio_Female": 1,
                    "Number_Age_Bins_Male"   : 20,
                    "Number_Age_Bins_Female" : 20,
                    "Age_of_First_Bin_Edge_Male"   : 17.5,
                    "Age_of_First_Bin_Edge_Female" : 17.5,
                    "Years_Between_Bin_Edges_Male"   : 2.5,
                    "Years_Between_Bin_Edges_Female" : 2.5,
                    "Joint_Probabilities" :
                    [
                        [ 0.045567, 0.035956, 0.019793, 0.007568, 0.002328, 0.000551, 0.000059, 0.000018, 0.000004, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.044738, 0.036352, 0.021958, 0.010123, 0.003782, 0.001001, 0.000184, 0.000073, 0.000022, 0.000004, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.041749, 0.037081, 0.028094, 0.017609, 0.008170, 0.002469, 0.000642, 0.000267, 0.000090, 0.000021, 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.034883, 0.034782, 0.032721, 0.025031, 0.013417, 0.004969, 0.001732, 0.000707, 0.000251, 0.000079, 0.000018, 0.000004, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.022317, 0.025265, 0.028532, 0.025516, 0.016489, 0.008321, 0.003780, 0.001533, 0.000572, 0.000213, 0.000062, 0.000012, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.009200, 0.013361, 0.019412, 0.020918, 0.016811, 0.011010, 0.005957, 0.002611, 0.001029, 0.000369, 0.000102, 0.000020, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.002873, 0.006137, 0.011340, 0.014349, 0.013829, 0.010947, 0.007060, 0.003720, 0.001602, 0.000506, 0.000122, 0.000031, 0.000004, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.001060, 0.002528, 0.005183, 0.007796, 0.009413, 0.009220, 0.007328, 0.004767, 0.002392, 0.000882, 0.000305, 0.000121, 0.000038, 0.000008, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000282, 0.000827, 0.002074, 0.004090, 0.006305, 0.007459, 0.007090, 0.005534, 0.003443, 0.001782, 0.000873, 0.000393, 0.000140, 0.000032, 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000148, 0.000373, 0.001016, 0.002362, 0.004162, 0.005612, 0.006176, 0.005583, 0.004120, 0.002630, 0.001522, 0.000769, 0.000319, 0.000097, 0.000021, 0.000004, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000077, 0.000166, 0.000484, 0.001276, 0.002467, 0.003661, 0.004442, 0.004384, 0.003574, 0.002614, 0.001800, 0.001118, 0.000585, 0.000245, 0.000083, 0.000020, 0.000002, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000096, 0.000144, 0.000302, 0.000669, 0.001252, 0.001963, 0.002577, 0.002736, 0.002445, 0.002074, 0.001750, 0.001355, 0.000895, 0.000496, 0.000222, 0.000071, 0.000017, 0.000003, 0.000000, 0.000000 ],
                        [ 0.000219, 0.000202, 0.000201, 0.000291, 0.000540, 0.001013, 0.001555, 0.001784, 0.001668, 0.001522, 0.001453, 0.001358, 0.001170, 0.000855, 0.000475, 0.000195, 0.000063, 0.000013, 0.000000, 0.000000 ],
                        [ 0.000320, 0.000250, 0.000144, 0.000097, 0.000205, 0.000567, 0.001037, 0.001230, 0.001110, 0.000997, 0.001033, 0.001178, 0.001296, 0.001150, 0.000755, 0.000381, 0.000150, 0.000037, 0.000004, 0.000001 ],
                        [ 0.000227, 0.000170, 0.000077, 0.000015, 0.000051, 0.000253, 0.000535, 0.000648, 0.000582, 0.000560, 0.000678, 0.000905, 0.001125, 0.001143, 0.000924, 0.000598, 0.000283, 0.000086, 0.000021, 0.000010 ],
                        [ 0.000062, 0.000046, 0.000021, 0.000004, 0.000014, 0.000069, 0.000146, 0.000177, 0.000176, 0.000240, 0.000395, 0.000600, 0.000804, 0.000943, 0.000951, 0.000756, 0.000428, 0.000183, 0.000088, 0.000063 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000015, 0.000076, 0.000194, 0.000361, 0.000551, 0.000720, 0.000808, 0.000735, 0.000536, 0.000355, 0.000253, 0.000212 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000004, 0.000021, 0.000070, 0.000186, 0.000351, 0.000496, 0.000586, 0.000621, 0.000607, 0.000555, 0.000489, 0.000451 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000015, 0.000077, 0.000184, 0.000305, 0.000424, 0.000543, 0.000649, 0.000717, 0.000746, 0.000754 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000005, 0.000024, 0.000074, 0.000178, 0.000331, 0.000500, 0.000666, 0.000820, 0.000946, 0.001010 ]
                    ],
                    "Assortivity" :
                    {
                        "Group" : "NO_GROUP"
                    }
                }
            },
            "INFORMAL" :
            {
                "Concurrency_Parameters" :
                {
                    "NONE": 
                    {
                        "Max_Simultaneous_Relationships_Female": 1,
                        "Max_Simultaneous_Relationships_Male"  : 1,
                        "Prob_Extra_Relationship_Female"       : 0,
                        "Prob_Extra_Relationship_Male"         : 0
                    }
                },
                "Relationship_Parameters" :
                {
                    "Coital_Act_Rate" : 0.33,
                    "Condom_Usage_Probability" :
                    {
                        "Min": 0.10,
                        "Max": 0.90,
                        "Mid": 2000,
                        "Rate": 1
                    },
                    "Duration_Weibull_Heterogeneity": 0.5,
                    "Duration_Weibull_Scale": 2.03104913138,
                    "Migration_Actions" : [ "TERMINATE" ],
                    "Migration_Actions_Distribution" : [ 1.0 ]
                },
                "Pair_Formation_Parameters" :
                {
                    "Formation_Rate_Type" : "CONSTANT",
                    "Formation_Rate_Constant": 0.00146753349399999,
                    "Update_Period" : 0.0,
                    "Extra_Relational_Rate_Ratio_Male": 1,
                    "Extra_Relational_Rate_Ratio_Female": 1,
                    "Number_Age_Bins_Male"   : 20,
                    "Number_Age_Bins_Female" : 20,
                    "Age_of_First_Bin_Edge_Male"   : 17.5,
                    "Age_of_First_Bin_Edge_Female" : 17.5,
                    "Years_Between_Bin_Edges_Male"   : 2.5,
                    "Years_Between_Bin_Edges_Female" : 2.5,
                    "Joint_Probabilities" :
                    [
                        [ 0.021820, 0.016798, 0.008474, 0.002572, 0.000566, 0.000133, 0.000012, 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.022878, 0.018808, 0.011747, 0.005706, 0.002183, 0.000534, 0.000061, 0.000012, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.025094, 0.023590, 0.019998, 0.013835, 0.006582, 0.001817, 0.000321, 0.000075, 0.000008, 0.000003, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.024383, 0.026075, 0.027147, 0.022210, 0.012255, 0.004504, 0.001348, 0.000349, 0.000061, 0.000025, 0.000008, 0.000002, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.017162, 0.021429, 0.026924, 0.025626, 0.017250, 0.008852, 0.003661, 0.001076, 0.000252, 0.000092, 0.000027, 0.000006, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.008432, 0.013738, 0.021613, 0.024180, 0.019887, 0.013033, 0.006651, 0.002503, 0.000812, 0.000255, 0.000063, 0.000019, 0.000004, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.003736, 0.007791, 0.014370, 0.018571, 0.018491, 0.014865, 0.009391, 0.004734, 0.001979, 0.000629, 0.000170, 0.000062, 0.000019, 0.000006, 0.000002, 0.000001, 0.000001, 0.000000, 0.000000, 0.000000 ],
                        [ 0.001699, 0.003707, 0.007467, 0.011553, 0.014397, 0.014112, 0.010869, 0.006905, 0.003605, 0.001505, 0.000575, 0.000218, 0.000079, 0.000034, 0.000017, 0.000010, 0.000004, 0.000001, 0.000000, 0.000000 ],
                        [ 0.000649, 0.001503, 0.003405, 0.006352, 0.009457, 0.010871, 0.010096, 0.007985, 0.005372, 0.003070, 0.001478, 0.000581, 0.000222, 0.000103, 0.000053, 0.000030, 0.000012, 0.000002, 0.000000, 0.000000 ],
                        [ 0.000253, 0.000604, 0.001471, 0.003029, 0.005049, 0.006871, 0.007949, 0.007848, 0.006588, 0.004633, 0.002576, 0.001130, 0.000463, 0.000197, 0.000093, 0.000050, 0.000020, 0.000004, 0.000000, 0.000000 ],
                        [ 0.000096, 0.000274, 0.000712, 0.001492, 0.002634, 0.004087, 0.005552, 0.006489, 0.006506, 0.005362, 0.003450, 0.001796, 0.000819, 0.000328, 0.000137, 0.000067, 0.000025, 0.000006, 0.000001, 0.000000 ],
                        [ 0.000066, 0.000224, 0.000546, 0.000969, 0.001526, 0.002331, 0.003383, 0.004556, 0.005399, 0.005125, 0.003806, 0.002370, 0.001298, 0.000621, 0.000278, 0.000118, 0.000045, 0.000015, 0.000004, 0.000001 ],
                        [ 0.000034, 0.000126, 0.000314, 0.000562, 0.000882, 0.001325, 0.001955, 0.002844, 0.003711, 0.003916, 0.003386, 0.002613, 0.001862, 0.001172, 0.000606, 0.000252, 0.000098, 0.000039, 0.000012, 0.000003 ],
                        [ 0.000009, 0.000033, 0.000107, 0.000275, 0.000523, 0.000781, 0.001072, 0.001508, 0.002033, 0.002423, 0.002583, 0.002548, 0.002296, 0.001748, 0.001030, 0.000478, 0.000199, 0.000073, 0.000021, 0.000006 ],
                        [ 0.000000, 0.000000, 0.000021, 0.000106, 0.000244, 0.000370, 0.000495, 0.000703, 0.001023, 0.001429, 0.001860, 0.002219, 0.002354, 0.002059, 0.001414, 0.000786, 0.000357, 0.000120, 0.000030, 0.000008 ],
                        [ 0.000000, 0.000000, 0.000006, 0.000028, 0.000066, 0.000112, 0.000179, 0.000309, 0.000527, 0.000843, 0.001243, 0.001692, 0.002040, 0.002018, 0.001612, 0.001064, 0.000557, 0.000218, 0.000067, 0.000018 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000003, 0.000013, 0.000053, 0.000161, 0.000337, 0.000537, 0.000769, 0.001088, 0.001424, 0.001582, 0.001485, 0.001178, 0.000762, 0.000404, 0.000178, 0.000078 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000001, 0.000003, 0.000034, 0.000143, 0.000303, 0.000410, 0.000468, 0.000594, 0.000806, 0.001025, 0.001160, 0.001107, 0.000884, 0.000635, 0.000444, 0.000350 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000024, 0.000119, 0.000259, 0.000338, 0.000354, 0.000400, 0.000512, 0.000665, 0.000808, 0.000863, 0.000843, 0.000852, 0.000910, 0.000951 ],
                        [ 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000020, 0.000101, 0.000223, 0.000309, 0.000345, 0.000378, 0.000427, 0.000485, 0.000549, 0.000625, 0.000753, 0.001001, 0.001315, 0.001501 ]
                    ],
                    "Assortivity" :
                    {
                        "Group" : "NO_GROUP"
                    }
                }
            },
            "MARITAL" :
            {
                "Concurrency_Parameters" :
                {
                    "NONE": 
                    {
                        "Max_Simultaneous_Relationships_Female": 1,
                        "Max_Simultaneous_Relationships_Male"  : 1,
                        "Prob_Extra_Relationship_Female"       : 0,
                        "Prob_Extra_Relationship_Male"         : 0
                    }
                },
                "Relationship_Parameters" :
                {
                    "Coital_Act_Rate" : 0.33,
                    "Condom_Usage_Probability" :
                    {
                        "Min": 0.10,
                        "Max": 0.90,
                        "Mid": 2001,
                        "Rate": 1
                    },
                    "Duration_Weibull_Heterogeneity": 0.666666667,
                    "Duration_Weibull_Scale": 22.154455184937,
                    "Migration_Actions" : [ "TERMINATE" ],
                    "Migration_Actions_Distribution" : [ 1.0 ]
                },
                "Pair_Formation_Parameters" :
                {
                    "Formation_Rate_Type" : "CONSTANT",
                    "Formation_Rate_Constant": 0.0000914427211999999,
                    "Update_Period" : 0.0,
                    "Extra_Relational_Rate_Ratio_Male": 1,
                    "Extra_Relational_Rate_Ratio_Female": 1,
                    "Number_Age_Bins_Male"   : 20,
                    "Number_Age_Bins_Female" : 20,
                    "Age_of_First_Bin_Edge_Male"   : 17.5,
                    "Age_of_First_Bin_Edge_Female" : 17.5,
                    "Years_Between_Bin_Edges_Male"   : 2.5,
                    "Years_Between_Bin_Edges_Female" : 2.5,
                    "Joint_Probabilities" :
                    [
                        [ 0.001014, 0.000773, 0.000377, 0.000102, 0.000016, 0.000003, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.001467, 0.001149, 0.000618, 0.000222, 0.000062, 0.000012, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.002110, 0.001740, 0.001116, 0.000633, 0.000393, 0.000235, 0.000098, 0.000020, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.002212, 0.002054, 0.001796, 0.001620, 0.001472, 0.001076, 0.000489, 0.000098, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.001684, 0.001953, 0.002461, 0.003028, 0.003301, 0.002735, 0.001514, 0.000551, 0.000155, 0.000031, 0.000001, 0.000005, 0.000009, 0.000009, 0.000005, 0.000001, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.001040, 0.001617, 0.002774, 0.004255, 0.005423, 0.005206, 0.003661, 0.001972, 0.000775, 0.000155, 0.000005, 0.000024, 0.000047, 0.000047, 0.000024, 0.000005, 0.000000, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000569, 0.001200, 0.002613, 0.004826, 0.007094, 0.007849, 0.006726, 0.004557, 0.002234, 0.000711, 0.000183, 0.000092, 0.000101, 0.000097, 0.000050, 0.000013, 0.000002, 0.000000, 0.000000, 0.000000 ],
                        [ 0.000339, 0.000830, 0.002079, 0.004396, 0.007285, 0.009393, 0.009818, 0.008106, 0.004974, 0.002315, 0.000877, 0.000269, 0.000126, 0.000108, 0.000063, 0.000025, 0.000008, 0.000002, 0.000000, 0.000000 ],
                        [ 0.000293, 0.000570, 0.001407, 0.003244, 0.006069, 0.009393, 0.011954, 0.011712, 0.008762, 0.005333, 0.002674, 0.001056, 0.000371, 0.000138, 0.000062, 0.000038, 0.000016, 0.000003, 0.000000, 0.000000 ],
                        [ 0.000253, 0.000419, 0.000970, 0.002268, 0.004615, 0.008232, 0.012061, 0.013764, 0.012690, 0.009880, 0.006410, 0.003391, 0.001375, 0.000352, 0.000070, 0.000039, 0.000016, 0.000003, 0.000000, 0.000000 ],
                        [ 0.000159, 0.000333, 0.000802, 0.001727, 0.003427, 0.006363, 0.010138, 0.013505, 0.015301, 0.014457, 0.011223, 0.007178, 0.003560, 0.001263, 0.000358, 0.000087, 0.000009, 0.000002, 0.000000, 0.000000 ],
                        [ 0.000075, 0.000230, 0.000598, 0.001230, 0.002345, 0.004316, 0.007261, 0.011034, 0.014582, 0.015942, 0.014559, 0.011288, 0.007231, 0.003733, 0.001443, 0.000304, 0.000009, 0.000002, 0.000000, 0.000000 ],
                        [ 0.000027, 0.000102, 0.000300, 0.000684, 0.001367, 0.002505, 0.004362, 0.007309, 0.010903, 0.013882, 0.015276, 0.014404, 0.011428, 0.007354, 0.003388, 0.000935, 0.000171, 0.000046, 0.000007, 0.000002 ],
                        [ 0.000005, 0.000020, 0.000090, 0.000286, 0.000658, 0.001226, 0.002235, 0.004148, 0.007018, 0.010488, 0.013644, 0.015020, 0.013925, 0.010445, 0.005801, 0.002345, 0.000792, 0.000218, 0.000037, 0.000010 ],
                        [ 0.000000, 0.000000, 0.000020, 0.000102, 0.000273, 0.000549, 0.001102, 0.002260, 0.004239, 0.007138, 0.010432, 0.012966, 0.013724, 0.011826, 0.007974, 0.004455, 0.002233, 0.000958, 0.000324, 0.000092 ],
                        [ 0.000000, 0.000000, 0.000013, 0.000063, 0.000163, 0.000314, 0.000611, 0.001249, 0.002433, 0.004383, 0.006909, 0.009408, 0.011056, 0.010813, 0.008887, 0.006737, 0.004916, 0.003067, 0.001322, 0.000382 ],
                        [ 0.000000, 0.000000, 0.000018, 0.000088, 0.000203, 0.000312, 0.000455, 0.000764, 0.001380, 0.002449, 0.003925, 0.005568, 0.007040, 0.007909, 0.008149, 0.008144, 0.007639, 0.005738, 0.002924, 0.001208 ],
                        [ 0.000000, 0.000000, 0.000018, 0.000088, 0.000198, 0.000288, 0.000365, 0.000502, 0.000770, 0.001238, 0.001911, 0.002730, 0.003684, 0.004800, 0.006002, 0.007105, 0.007580, 0.006558, 0.004455, 0.003100 ],
                        [ 0.000000, 0.000000, 0.000009, 0.000044, 0.000105, 0.000175, 0.000244, 0.000316, 0.000417, 0.000601, 0.000889, 0.001276, 0.001787, 0.002479, 0.003318, 0.004175, 0.004909, 0.005365, 0.005540, 0.005586 ],
                        [ 0.000000, 0.000000, 0.000002, 0.000012, 0.000038, 0.000096, 0.000173, 0.000228, 0.000270, 0.000355, 0.000509, 0.000729, 0.001011, 0.001347, 0.001743, 0.002217, 0.002961, 0.004339, 0.006055, 0.007062 ]
                    ],
                    "Assortivity" :
                    {
                        "Group" : "NO_GROUP"
                    }
                }
            },
            "COMMERCIAL" :
            {
                "Concurrency_Parameters" :
                {
                    "NONE": 
                    {
                        "Max_Simultaneous_Relationships_Female": 0,
                        "Max_Simultaneous_Relationships_Male"  : 0,
                        "Prob_Extra_Relationship_Female"       : 0,
                        "Prob_Extra_Relationship_Male"         : 0
                    }
                },
                "Relationship_Parameters" :
                {
                    "Coital_Act_Rate" : 0.33,
                    "Condom_Usage_Probability" :
                    {
                        "Min": 0.10,
                        "Max": 0.90,
                        "Mid": 2000,
                        "Rate": 1
                    },
                    "Duration_Weibull_Heterogeneity": 0.833333333,
                    "Duration_Weibull_Scale": 0.956774771214,
                    "Migration_Actions" : [ "TERMINATE" ],
                    "Migration_Actions_Distribution" : [ 1.0 ]
                },
                "Pair_Formation_Parameters" :
                {
                    "Formation_Rate_Type" : "CONSTANT",
                    "Formation_Rate_Constant": 0.0,
                    "Update_Period" : 7.0,
                    "Extra_Relational_Rate_Ratio_Male": 1,
                    "Extra_Relational_Rate_Ratio_Female": 1,
                    "Number_Age_Bins_Male"   : 2,
                    "Number_Age_Bins_Female" : 2,
                    "Age_of_First_Bin_Edge_Male"   : 50,
                    "Age_of_First_Bin_Edge_Female" : 50,
                    "Years_Between_Bin_Edges_Male"   : 35,
                    "Years_Between_Bin_Edges_Female" : 35,
                    "Joint_Probabilities" :
                    [
                        [ 0, 1 ],
                        [ 1, 0 ]
                    ],
                    "Assortivity" :
                    {
                        "Group" : "NO_GROUP"
                    }
                }
            }
        }
    }
    demog.raw['Defaults'].update( setting )
    #demog.SetNodeDefaultFromTemplate( setting, set_society_configs )
I see lots of HIV_SIM examples. Are there any STI_SIM examples?

Not at this time.

I pip installed emodpy-hiv, but I want to make changes. How should I do that?

Install at a command prompt using the following:

python package_setup.py develop

This method is the most popular and proven, though there are some other options. Installing this way means that the emodpy-hiv module in site-packages actually points to the same code as you have checked out in git. For more detail, see this Stack Overflow post.

However, we aim to get the desired changes quickly tested and included in the versioned module we release via pip install.

emodpy_hiv

emodpy_hiv package

Subpackages

emodpy_hiv.demographics package
Submodules
emodpy_hiv.demographics.DemographicsTemplates module
emodpy_hiv.demographics.DemographicsTemplates.set_society_configs(config)
emodpy_hiv.demographics.DemographicsTemplates.AddDefaultSociety(demog)

Adds a PFA config based on IDM defaults.

emodpy_hiv.demographics.HIVDemographics module

This module contains the classes and functions for creating demographics files for HIV simulations. For more information on EMOD demographics files, see Demographics file.

class emodpy_hiv.demographics.HIVDemographics.HIVDemographics(nodes, idref='Gridded world grump2.5arcmin', base_file=None)

Bases: emod_api.demographics.Demographics.Demographics

This class is derived from emod_api.demographics.Demographics.Demographics and sets certain defaults for HIV in construction.

Parameters
  • nodes – The number of nodes to create.

  • idref – Method describing how the latitude and longitude values are created for each of the nodes in a simulation. “Gridded world” values use a grid overlaid across the globe at some arcsec resolution. You may also generate the grid using another tool or coordinate system. For more information, see Metadata.

  • base_file – A basic demographics file used as a starting point for creating more complicated demographics files. For example, using a single node file to create a multi-node file for spatial simulations.

  • init_prev – The initial HIV prevalence of the population.

Returns

None

fertility(path_to_csv)

Set fertility based on data. Simulation shall concist of individual pregnancies with rates by woman’s age and year-of-simulation using data from provided csv.

mortality(file_male, file_female, interval_fit=[1970, 1980], which_point='mid', predict_horizon=2050, csv_out=False, n=0, results_scale_factor=0.0027397260273972603)

Calculate and set the expected natural mortality by age, sex, and year from data, predicting what it would have been without HIV.

apply_assortivity(category, rowmale_colfemale_matrix)

Add an assortivity matrix to Pair-Forming Algo. Right now only applies to RISK IP.

Parameters
  • category – “COMMERCIAL”, “INFORMAL”, “MARITAL”, or “TRANSITORY”

  • rowmale_colfemale_matrix – 3x3 matrix of assortivity values, row represents male, column represents female.

Returns

N/A.

emodpy_hiv.demographics.HIVDemographics.from_template_node(lat=0, lon=0, pop=1000000.0, name=1, forced_id=1)

Create a single-node HIVDemographics instance from the parameters you supply.

Parameters
  • lat – Latitude of the centroid of the node to create.

  • lon – Longitude of the centroid of the node to create.

  • pop – Human population of the node.

  • name – The name of the node. This may be a characteristic of the node, such as “rural” or “urban”, or an identifying integer.

  • forced_id – The node ID for the single node.

Returns

A HIVDemographics instance.

emodpy_hiv.demographics.HIVDemographics.from_pop_csv(pop_filename_in, pop_filename_out='spatial_gridded_pop_dir', site='No_Site')

Create a multi-node HIVDemographics instance from a CSV file describing a population.

Parameters
  • pop_filename_in – The path to the demographics file to ingest.

  • pop_filename_out – The path to the file to output.

  • site – A string to identify the country, village, or trial site.

Returns

A HIVDemographics instance.

emodpy_hiv.demographics.HIVDemographics.from_params(tot_pop=1000000.0, num_nodes=100, frac_rural=0.3, id_ref='from_params')

Create a multi-node HIVDemographics instance as a synthetic population based on a few parameters.

Parameters
  • tot_pop – The total human population in the node.

  • num_nodes – The number of nodes to create.

  • frac_rural – The fraction of the population that is rural.

  • id_ref – Method describing how the latitude and longitude values are created for each of the nodes in a simulation. “Gridded world” values use a grid overlaid across the globe at some arcsec resolution. You may also generate the grid using another tool or coordinate system. For more information, see Metadata.

Returns

A HIVDemographics instance.

emodpy_hiv.interventions package
Submodules
emodpy_hiv.interventions.art module
emodpy_hiv.interventions.art.new_intervention(camp)

AntiRetroviralTherapy intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.art.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

ART intervention as complete (scheduled) event.

emodpy_hiv.interventions.art.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.artdropout module
emodpy_hiv.interventions.artdropout.new_intervention(camp)

ARTDropout intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.artdropout.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

ARTDropout intervention as complete (scheduled) event.

emodpy_hiv.interventions.artdropout.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.artstagingbycd4agnosticdiag module
emodpy_hiv.interventions.artstagingbycd4agnosticdiag.new_diagnostic(camp, Positive_Event, Negative_Event, abp_tvmap, abt_tvmap, abw_tvmap, cua_tvmap, cbt_tvmap, cbw_tvmap)

Wrapper function to create and return a HIVARTStagingCD4AgnosticDiagnostic intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.artstagingbycd4agnosticdiag.new_intervention_event(camp, pos_event, neg_event, abp_tvmap, abt_tvmap, abw_tvmap, cua_tvmap, cbt_tvmap, cbw_tvmap, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.artstagingbycd4agnosticdiag.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.artstagingbycd4diag module
emodpy_hiv.interventions.artstagingbycd4diag.new_diagnostic(camp, Positive_Event, Negative_Event, Threshold_TVMap, IP_TVMap, IAT_TVMap)

Wrapper function to create and return a HIVARTStagingByCD4Diagnostic intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.artstagingbycd4diag.new_intervention_event(camp, pos_event, neg_event, thresh_tvmap, pregnant_tvmap, tb_tvmap, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.artstagingbycd4diag.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.cascade_helpers module
emodpy_hiv.interventions.cascade_helpers.reset(camp)

Utility function to clear out the campaign object, mostly useful to test. This function is not auto-imported with the module like the rest of the functions in this submodule. Caller has to explicitly import emodpy_hiv.interventions.cascade_helpers. :param camp: emod_api.campaign object.

Returns

None.

emodpy_hiv.interventions.cascade_helpers.seed_infection(camp, timestep, coverage)

Seed an infection by time and %age of population infected.

emodpy_hiv.interventions.cascade_helpers.triggered_event_common(camp, in_trigger, out_iv, event_name='')

Parameterized utility function used by rest of functions in this submodule that listen for a trigger and distribute an intervention (or list thereof) as a result.

emodpy_hiv.interventions.cascade_helpers.add_choice(camp, sympto_signal='HIVSymptomatic', get_tested_signal='GetTested')

Listen for HIVSymptomatic trigger. Then toss a coin (Random Choice), heads get tested, tails maybe it’s just a cold.

emodpy_hiv.interventions.cascade_helpers.add_test(camp, get_tested_signal='GetTested')

Listen for GetTested signal. Then get HIV RapidDiagnostic test after a delay of 30 days.

emodpy_hiv.interventions.cascade_helpers.trigger_art_from_pos_test(camp, input_signal='HIVPositiveTest', output_signal='StartTreatment', lag_time=30)

Listen for HIVPositiveTest trigger. Then Trigger ART. Note that Trigger ART isn’t same as starting it.

emodpy_hiv.interventions.cascade_helpers.add_art_from_trigger(camp, signal='StartTreatment')

Actually distribute ART if a StartTreatment signal/trigger is observed. Broadcast a StartedART signal synchronously.

emodpy_hiv.interventions.cascade_helpers.trigger_art(camp, timestep, coverage, trigger='StartTreatment')

Schedule a broadcast of StartTreatment (or equivalent), not based on any observed signals.

emodpy_hiv.interventions.delay module
emodpy_hiv.interventions.delay.new_delay(camp, Bcast_Event, Expire_Event='', Coverage=1, Delay=1, Shelf_Life=36500, Name='')

Wrapper function to create and return a HIVDelayedIntervention intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.delay.new_intervention_event(camp, bcast_event, expire_event='', coverage=1, delay=1, shelf_life=0)

Delay as scheduled event.

emodpy_hiv.interventions.delay.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.drawblood module
emodpy_hiv.interventions.drawblood.new_diagnostic(camp, Positive_Event, Base_Sensitivity=1, Base_Specificity=1, Days_To_Diagnosis=0, Treatment_Fraction=1)

Wrapper function to create and return a HIVDrawBlood intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.drawblood.new_intervention_event(camp, pos_event, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.drawblood.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.malecirc module
emodpy_hiv.interventions.malecirc.new_intervention(camp)

MaleCircumcision intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.malecirc.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

VMMC intervention as complete (scheduled) event.

emodpy_hiv.interventions.malecirc.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.modcoinf module
emodpy_hiv.interventions.modcoinf.new_intervention(camp)

ModifySTICoInfection intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.modcoinf.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

ModifySTICoInfection intervention as complete (scheduled) event.

emodpy_hiv.interventions.modcoinf.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.outbreak module
emodpy_hiv.interventions.outbreak.new_intervention(timestep, camp, coverage=0.01)

Seed HIV infection at a certain timestep, with a certain prevalence.

Parameters
  • timestep (float) – When? Timestep at which outbreak should occur.

  • camp – emod_api.campaign object that has schema_path.

  • coverage – How Much? The intended level of initial prevalance.

Returns

event as dict

Return type

event

emodpy_hiv.interventions.outbreak.seed_infections(camp, start_day=365, coverage=0.075, target_properties='Risk:HIGH', target_min_age=0, target_max_age=125, target_gender='All')

Create outbreak event with more targeting than ‘new_intervention’.

emodpy_hiv.interventions.pmtct module
emodpy_hiv.interventions.pmtct.new_intervention(camp, efficacy=1.0)

PMTCT intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.pmtct.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

PMTCT intervention as complete (scheduled) event.

emodpy_hiv.interventions.pmtct.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.prep module
emodpy_hiv.interventions.prep.new_intervention(camp)

PrEP intervention wrapper. Just the intervention. No configuration yet.

emodpy_hiv.interventions.prep.new_intervention_event(camp, start_day=1, coverage=1.0, node_ids=None)

PrEP intervention as complete (scheduled) event.

emodpy_hiv.interventions.prep.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.random module
emodpy_hiv.interventions.random.new_diagnostic(camp, choices)

Wrapper function to create and return a HIVRandomChoice intervention.

Parameters
  • camp – emod_api.campaign object with schema_path set.

  • choices – dict of events:probability, with probs summing up to 1.0

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.random.new_intervention_event(camp, choices, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.random.new_intervention_as_file(camp, start_day, choices, filename=None)
emodpy_hiv.interventions.rapiddiag module
emodpy_hiv.interventions.rapiddiag.new_diagnostic(camp, Positive_Event, Negative_Event)

Wrapper function to create and return a HIVRapidHIVDiagnostic intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.rapiddiag.new_intervention_event(camp, pos_event, neg_event, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.rapiddiag.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.reftracker module
emodpy_hiv.interventions.reftracker.DistributeIVByRefTrack(camp, Start_Day, Intervention, TVMap, node_ids=None, Event_Name='Scheduled_Campaign_Event', Property_Restrictions=None, Target_Demographic='Everyone', Target_Age_Min=0, Target_Age_Max=45625, Target_Gender='All')

Wrapper function to create and return a ScheduledCampaignEvent intervention. The alternative to a ScheduledCampaignEvent is a TriggeredCampaignEvent.

Parameters
  • camp – emod_api.campaign object with schema_path set.

  • Start_Day – When to start.

  • Intervention – Valid intervention to be distributed together as necessary to track coverage targets.

  • Event_Name – Name for overall campaign event, of not functional meaning.

  • node_ids – Nodes to target with this intervention, return from utils.do_nodes().

  • Property_Restrictions – Individual Properties a person must have to receive the intervention(s).

  • Number_Repetitions – N/A

  • Timesteps_Between_Repetitions – N/A

  • Target_Demographic – Everyone, ExplicitAgeRanges, etc.

  • Target_Age_Min – Minimum age (in years).

  • Target_Age_Max – Maximum age (in years).

  • Target_Gender – All, Male, or Female.

Returns

Schema-based smart dictionary representing a new ScheduledCampaignEvent intervention ready to be added to a campaign.

Return type

ReadOnlyDict

emodpy_hiv.interventions.reftracker.new_intervention_as_file(camp, actual_intervention, start_day=1, filename=None)
emodpy_hiv.interventions.sigmoiddiag module
emodpy_hiv.interventions.sigmoiddiag.new_diagnostic(camp, Positive_Event, Negative_Event, ramp_min, ramp_max, ramp_midyear, ramp_rate)

Wrapper function to create and return a HIVSigmoidByYearAndSexDiagnostic intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.sigmoiddiag.new_intervention_event(camp, pos_event, neg_event, ramp_min=0, ramp_max=1, ramp_midyear=2000, ramp_rate=1, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.sigmoiddiag.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.stipostdebut module
emodpy_hiv.interventions.stipostdebut.new_diagnostic(camp, Positive_Event, Negative_Event, Base_Sensitivity=1, Base_Specificity=1, Days_To_Diagnosis=0, Treatment_Fraction=1)

Wrapper function to create and return a STIIsPostDebut intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.stipostdebut.new_intervention_event(camp, pos_event, neg_event, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.stipostdebut.new_intervention_as_file(camp, start_day, filename=None)
emodpy_hiv.interventions.utils module
emodpy_hiv.interventions.utils.set_tvmap_lists_from_map(tvmap, param)
emodpy_hiv.interventions.utils.declutter(event)

These are mostly temporary hacks that clean up the output json; should go away with subsequent cherry-picks of schema enhancements from other branches.

emodpy_hiv.interventions.yearandsexdiag module
emodpy_hiv.interventions.yearandsexdiag.new_diagnostic(camp, Positive_Event, Negative_Event, TVMap)

Wrapper function to create and return a HIVPiecewiseByYearAndSexDiagnostic intervention.

Parameters

camp – emod_api.campaign object with schema_path set.

Returns

Schema-based smart dictionary representing a new

Return type

ReadOnlyDict

emodpy_hiv.interventions.yearandsexdiag.new_intervention_event(camp, pos_event, neg_event, tvmap, start_day=1, coverage=1.0, node_ids=None)

Diagnostic as scheduled event.

emodpy_hiv.interventions.yearandsexdiag.new_intervention_as_file(camp, start_day, tvmap, filename=None)