Пример #1
0
def add_scenario_reports(cb,
                         include_summary=True,
                         include_inset=True,
                         include_bednet_events_in_counter=False):
    if include_summary:
        add_summary_report(cb, age_bins=summary_age_bins, start=365)

    events_to_count = [
        "Received_Treatment", "Received_Test", "Received_Campaign_Drugs",
        "Received_RCD_Drugs", "Received_SMC", "Received_Ivermectin",
        "Received_Primaquine"
    ]
    if include_bednet_events_in_counter:
        events_to_count += [
            "Bednet_Discarded", "Bednet_Got_New_One", "Bednet_Using"
        ]

    add_event_counter_report(cb, event_trigger_list=events_to_count)

    # drug_events = ["Received_Treatment", "Diagnostic_Survey_0", "Received_Test", "Received_RCD_Drugs",
    #                "Received_Campaign_Drugs"]
    # cb.set_param("Listed_Events", drug_events)
    # cb.set_param("Custom_Individual_Events", drug_events)

    if include_inset:
        cb.set_param("Enable_Default_Reporting", 1)
    else:
        cb.set_param("Enable_Default_Reporting", 0)
def iver_sweep(cb, intervention_df_dict, vc_pack, drug_pack, vc_coverage, mda_coverage, ivm_duration, restricted_ivm=False):
    add_hs(cb, intervention_df_dict["hs"])
    event_trigger_list = ["Received_Treatment"]

    if vc_pack == "none":
        pass
    elif vc_pack == "ITN only":
        itn_events = intervention_df_dict["itn"]
        itn_events["cov_all"] = vc_coverage
        add_itn(cb, itn_events)
    elif vc_pack == "IRS only":
        irs_events = intervention_df_dict["irs"]
        irs_events["cov_all"] = vc_coverage
        add_irs(cb, irs_events)
    elif vc_pack == "ITN and IRS":
        itn_events = intervention_df_dict["itn"]
        itn_events["cov_all"] = vc_coverage
        irs_events = intervention_df_dict["irs"]
        irs_events["cov_all"] = vc_coverage
        add_itn(cb, itn_events)
        add_irs(cb, irs_events)

    # Is there a DP component to the MDA?
    if mda_coverage > 0:
        mda_events = intervention_df_dict["mda"]
        mda_events["cov_all"] = mda_coverage

        if drug_pack != "Pure IVM MDA": # MDA includes DP
            event_trigger_list.append('Received_Campaign_Drugs')
            add_mda(cb, mda_events)
        elif drug_pack == "Pure IVM MDA": # MDA with only IVM and no DP
            event_trigger_list.append('Received_Ivermectin')
            add_pure_ivm_mda(cb, mda_events, ivm_duration, restricted_ivm=restricted_ivm)

    if drug_pack == "MDA with IVM":
        event_trigger_list.append('Received_Ivermectin')
        if not restricted_ivm:
            add_ivermectin(cb, box_duration=ivm_duration, coverage=1.0, start_days=[1],
                           trigger_condition_list=['Received_Campaign_Drugs'], target_residents_only=False)
        else:
            target_groups = [{'agemin': 5, 'agemax': 200, 'gender': 'Male'},
                             {'agemin': 51, 'agemax': 200, 'gender': 'Female'},
                             {'agemin': 5, 'agemax': 12, 'gender': 'Female'}]

            for tg in target_groups:
                add_ivermectin(cb, box_duration=ivm_duration, coverage=1.0, start_days=[1],
                               trigger_condition_list=['Received_Campaign_Drugs'], target_residents_only=False,
                               target_group=tg)

    add_event_counter_report(cb, event_trigger_list=event_trigger_list)
    return {"vc_pack": vc_pack,
            "drug_pack": drug_pack,
            "vc_coverage": vc_coverage,
            "mda_coverage": mda_coverage,
            "ivm_duration": ivm_duration}
Пример #3
0
def add_all_reports(cb):
    add_event_counter_report(cb, event_trigger_list=["Received_Treatment"])
    add_filtered_spatial_report(cb, channels=["Population", "True_Prevalence"])

    # Filtered report just for work node, and just for catchment:
    regional_EIR_node_label = 100000
    # Quick and dirty way to get sorted, unique list of grid cells in catchment:
    df = pd.read_csv("./inputs/grid_all_healthseek_events.csv")
    catch_node_ids = list(set(list(df["grid_cell"])))

    add_filtered_report(cb,
                        nodes=[regional_EIR_node_label],
                        description='Work')
    add_filtered_report(cb, nodes=catch_node_ids, description='Catchment')
Пример #4
0
def add_burnin_reports(cb, include_inset=False):
    add_summary_report(cb, start=45 * 365)

    if include_inset:
        cb.set_param("Enable_Default_Reporting", 1)
    else:
        cb.set_param("Enable_Default_Reporting", 0)

    events_to_count = [
        "Bednet_Discarded", "Bednet_Got_New_One", "Bednet_Using",
        "Received_Treatment", "Received_SMC"
    ]

    add_event_counter_report(cb,
                             event_trigger_list=events_to_count,
                             duration=365 * 50)
Пример #5
0
 def __call__(self, cb):
     from malaria.reports.MalariaReport import add_event_counter_report
     return add_event_counter_report(cb,
                                     self.channels,
                                     start=self.start,
                                     duration=self.duration,
                                     nodes=self.nodes,
                                     description=self.description)
Пример #6
0
def add_standard_reports(cb):
    add_event_counter_report(cb,
                             event_trigger_list=[
                                 "Received_Treatment", "Received_Test",
                                 "Received_Campaign_Drugs",
                                 "Received_RCD_Drugs"
                             ],
                             start=start,
                             duration=duration)

    cb.update_params({
        "Listed_Events": [
            "Received_Treatment", "Diagnostic_Survey_0", "Received_Test",
            "Received_RCD_Drugs", "Received_Campaign_Drugs"
        ]
    })

    # Replace InsetChart with a filtered report
    cb.update_params({"Enable_Default_Reporting": 0})
    add_filtered_report(cb, start=365 * 3, description="Final_Year")
    def add_reports_for_likelihood_analyzers(self,
                                             cb,
                                             catch,
                                             filter_duration_days=3650):
        filter_end = self.sim_duration_days
        filter_start = self.sim_duration_days - filter_duration_days

        add_filtered_spatial_report(cb,
                                    start=filter_start,
                                    end=filter_end,
                                    channels=[
                                        'Population', 'True_Prevalence',
                                        "Blood_Smear_Parasite_Prevalence"
                                    ])  # 'New_Clinical_Cases','New_Infections'

        # Now add report for is for HF-level incidence likelihood analyzer.
        add_event_counter_report(
            cb,
            # event_trigger_list=['Received_Treatment', 'Received_IRS', 'Received_Campaign_Drugs', 'Received_RCD_Drugs', 'Bednet_Got_New_One', 'Received_Test'],
            event_trigger_list=[
                'Received_Treatment'
            ],  #, 'Received_Test', 'TestedPositive', 'Received_Campaign_Drugs'],
            start=filter_start,
            duration=filter_duration_days)

        # Get list of cells that correspond to this catchment:
        catch_nodes = catchment_grid_cells(catch, as_list=True)

        add_filtered_report(cb,
                            start=filter_start,
                            end=filter_end,
                            nodes=catch_nodes)

        # Add a similar report for the migration node
        add_filtered_report(cb,
                            start=filter_start,
                            end=filter_end,
                            nodes=[100000],
                            description='Work')
from simtools.ExperimentManager.ExperimentManagerFactory import ExperimentManagerFactory
from simtools.SetupParser import SetupParser
from dtk.interventions.incidence_counter import add_incidence_counter
from dtk.interventions.irs import add_node_IRS
from malaria.reports.MalariaReport import add_event_counter_report  # you need to isntall the malaria package

# This block will be used unless overridden on the command-line
# this means that simtools.ini local block will be used
SetupParser.default_block = 'LOCAL'

cb = DTKConfigBuilder.from_defaults('VECTOR_SIM')
configure_site(cb, 'Namawala')

# event counter can help you keep track of events that are happening
add_event_counter_report(
    cb,
    ["HappyBirthday", "Party", "PartyHarder", "IRS_Blackout_Event_Trigger"])
# adding an incidence counter, which starts on day 20, and counts "Happy Birthday" events for 30 days. the default
# thresholds are 10 and 100 event counts and default events being sent out when the threshold is reached are Action1 and Action2
add_incidence_counter(
    cb,
    start_day=20,
    count_duration=30,
    count_triggers=['HappyBirthday'],
    threshold_type=
    'COUNT',  #this is the default, we can also look at % per eligible population
    thresholds=[13, 254],
    triggered_events=['Party', 'PartyHarder'])

add_incidence_counter(cb,
                      start_day=50,
Пример #9
0
def add_interventions_and_reports(cb, sim_time_dict):
    sim_start_year = sim_time_dict["sim_start_year"]
    sim_length_years = sim_time_dict["sim_length_years"]
    sim_filter_start_time = sim_time_dict["sim_filter_start_time"]
    sim_filter_duration = sim_time_dict["sim_filter_duration"]

    mozamb_exp.start_year = sim_start_year
    mozamb_exp.sim_length_years = sim_length_years
    mozamb_exp.implement_baseline_healthseeking(
        cb
    )  #fixme In future, pass start_year and sim_length_years to avoid race conditions
    mozamb_exp.implement_interventions(cb, True, True, False, True, True)

    all_nodes = list(mozamb_exp.desired_cells)
    if importation_version == 0:
        cb.update_params({
            'x_Regional_Migration': 0.03,
        })
        add_migration_event(
            cb,
            nodeto=100000,
            coverage=0.5,
            repetitions=500,
            tsteps_btwn=30,
            duration_of_stay=3,
            duration_before_leaving_distr_type='UNIFORM_DURATION',
            duration_before_leaving=0,
            duration_before_leaving_2=30,
            nodesfrom={
                'class': 'NodeSetNodeList',
                'Node_List': all_nodes
            },
            ind_property_restrictions=[{
                'TravelerStatus': 'IsTraveler'
            }])

    elif importation_version == 1:
        cb.update_params({
            'x_Regional_Migration': 0.0405,
        })

    # Add specific reports that we want (have to do it here because we need to know what times to filter for):

    # Add filter report that has same length for both burn-in and non-burn-in runs (2010-2020).
    # This version is for grid-level prevalence comparison
    add_filtered_spatial_report(
        cb,
        start=sim_filter_start_time,
        end=(sim_filter_start_time + sim_filter_duration),
        # channels=['Population', 'New_Diagnostic_Prevalence'])
        channels=['Population',
                  'True_Prevalence'])  # 'New_Clinical_Cases','New_Infections'

    # Add filter that has same length for both burn-in and non-burn-in runs (2010-2020)
    # This version is for HF-level incidence comparison.  Add a similar report for the migration node

    add_filtered_report(cb,
                        start=sim_filter_start_time,
                        end=(sim_filter_start_time + sim_filter_duration),
                        nodes=all_nodes)
    add_filtered_report(cb,
                        start=sim_filter_start_time,
                        end=(sim_filter_start_time + sim_filter_duration),
                        nodes=[EIR_node_label],
                        description='Work')

    # # Add filter report for prevalence in each bairro
    foo = bairro_df.groupby('bairro')

    for (bairro_num, df) in foo:
        add_filtered_report(cb,
                            start=sim_filter_start_time,
                            end=(sim_filter_start_time + sim_filter_duration),
                            nodes=[int(x) for x in df['grid_cell'].values],
                            description=str(int(bairro_num)))

    # Add counter report for clinical incidence
    add_event_counter_report(cb,
                             event_trigger_list=[
                                 'Received_Treatment', 'Received_IRS',
                                 'Received_Campaign_Drugs',
                                 'Received_RCD_Drugs', 'Bednet_Got_New_One',
                                 'Received_Test'
                             ],
                             start=sim_filter_start_time,
                             duration=sim_filter_duration)
Пример #10
0
# you will need to install malaria package for use with dtk-tools:
# use > dtk get_package malaria -v HEAD

# This block will be used unless overridden on the command-line
# this means that simtools.ini local block will be used
# change this to 'LOCAL' to run it on just your machine.
#SetupParser('HPC')

cb = DTKConfigBuilder.from_defaults('MALARIA_SIM')
cb.update_params({"Genome_Markers": []})
cb.update_params({"Base_Population_Scale_Factor": 0.001}),
configure_site(cb, "Matsari")

# event counter can help you keep track of events that are happening that you're interested in.
add_event_counter_report(cb, ["Took_Dose", "NewClinicalCase"])

# run_sim_args is what the `dtk run` command will look for
run_sim_args =  {
    'exp_name': 'Matsari_Malaria_Adherence_Drug_Example',
    'config_builder': cb
}


# There are defaults for all the variables except the config_builder that gets passed in
# you could, if you wanted to, create this interventions with
# add_adherent_drug(cb)
# You'll want to define the configuration for the usage/waning of the drug separately and pass the whole thing
# to adherence_config variable - there is a default, which is the following, in which the any user takes all the drugs
# {  # the default is for person to take everything not matter what age
#     "class": "WaningEffectMapLinearAge",
####################
# Reports and logs #
####################
add_summary_report(cb, age_bins=summary_age_bins, start=365)

events_to_count = [
    "Received_Treatment", "Received_Test", "Received_Campaign_Drugs_Term_1",
    "Received_Campaign_Drugs_Term_2", "Received_Campaign_Drugs_Term_3",
    "Received_RCD_Drugs", "Received_SMC", "Received_Ivermectin",
    "Received_Primaquine"
]

events_to_count += ["Bednet_Discarded", "Bednet_Got_New_One", "Bednet_Using"]

add_event_counter_report(cb, event_trigger_list=events_to_count)

cb.set_param("Enable_Default_Reporting", 1)

###############################
# Submission/COMPs parameters #
###############################

comps_experiment_name = "southern_sac_ipt_iver_withheld_from_term"
comps_priority = "AboveNormal"
# comps_priority = "Highest"
comps_coreset = "emod_abcd"
# comps_coreset = "emod_32cores"

##################
# Job submission #
Пример #12
0
add_summary_report(cb,
                   age_bins=summary_age_bins,
                   start=365,
                   duration_days=sim_duration)
cb.set_param("Enable_Demographics_Reporting", 1)

events_to_count = [
    "Received_Treatment", "Received_Test", "Received_Campaign_Drugs",
    "Received_RCD_Drugs", "Received_SMC", "Received_Ivermectin",
    "Received_Primaquine"
]

events_to_count += ["Bednet_Discarded", "Bednet_Got_New_One", "Bednet_Using"]

add_event_counter_report(cb,
                         event_trigger_list=events_to_count,
                         duration=sim_duration)

cb.set_param("Enable_Default_Reporting", 1)

###############################
# Submission/COMPs parameters #
###############################

comps_experiment_name = "sahel_smc_with_transmission_blocking"
comps_priority = "Normal"
# comps_priority = "Highest"
comps_coreset = "emod_abcd"
# comps_coreset = "emod_32cores"

##################
        }])

    add_filtered_report(cb, nodes=all_nodes, description='Catchment')

    add_filtered_report(cb, nodes=[100000], description='Work')

    # Add counter report for clinical incidence
    # add_event_counter_report(cb,
    #                          event_trigger_list=['Received_Treatment', 'Received_IRS', 'Received_Campaign_Drugs', 'Received_RCD_Drugs', 'Bednet_Got_New_One', 'Received_Test'])

    # Add counter for new infections in work node vs all other nodes:
    add_event_counter_report(
        cb,
        event_trigger_list=['NewInfectionEvent'],
        description='WorkInfections',
        # start=sim_filter_start_time,
        # duration=sim_filter_duration,
        nodes={
            'Node_List': all_nodes,
            "class": "NodeSetNodeList"
        })

    add_event_counter_report(
        cb,
        event_trigger_list=['NewInfectionEvent'],
        description='NonworkInfections',
        # start=sim_filter_start_time,
        # duration=sim_filter_duration,
        nodes={
            'Node_List': [100000],
            "class": "NodeSetNodeList"
        })
def add_intervention(cb, intervention, coverage, target, ivm_duration) :

    IPR = [{'HomeVillage' : 'Village1'}] if target == 'vill1' else None

    if intervention == 'ivermectin_to_forest' :
        add_ivermectin(cb, box_duration=ivm_duration, coverage=coverage, start_days=[365],
                       trigger_condition_list=['Immigrating'],
                       nodeIDs=forest_nodes,
                       target_group={'agemin': 5, 'agemax': 200, 'gender': 'Male'},
                       target_residents_only=False,
                       ind_property_restrictions=IPR
                       )
    elif intervention == 'drug_to_forest' :
        add_drug_campaign(cb, 'MDA', 'DP', coverage=coverage, start_days=[365],
                          repetitions=1,
                          trigger_condition_list=['Immigrating'],
                          nodeIDs=forest_nodes,
                          target_residents_only=False,
                          ind_property_restrictions=IPR
                          )
    elif intervention == 'drug_MDA' :
        add_drug_campaign(cb, 'MDA', 'DP', coverage=coverage, start_days=[365 + 152],
                          repetitions=3, tsteps_btwn_repetitions=30,
                          nodeIDs=village_nodes,
                          target_residents_only=False,
                          ind_property_restrictions=IPR
                          )
    elif intervention == 'drug_ivermectin_MDA' :
        add_drug_campaign(cb, 'MDA', 'DP', coverage=coverage, start_days=[365 + 152],
                          repetitions=3, tsteps_btwn_repetitions=30,
                          nodeIDs=village_nodes,
                          target_residents_only=False,
                          ind_property_restrictions=IPR
                          )
        add_ivermectin(cb, box_duration=ivm_duration, coverage=1, start_days=[365],
                       trigger_condition_list=['Received_Campaign_Drugs'],
                       target_group={'agemin': 5, 'agemax': 200, 'gender': 'Male'},
                       nodeIDs=village_nodes,
                       target_residents_only=False
                       )
        add_ivermectin(cb, box_duration=ivm_duration, coverage=1, start_days=[365],
                       trigger_condition_list=['Received_Campaign_Drugs'],
                       target_group={'agemin': 51, 'agemax': 200, 'gender': 'Female'},
                       nodeIDs=village_nodes,
                       target_residents_only=False
                       )
        add_ivermectin(cb, box_duration=ivm_duration, coverage=1, start_days=[365],
                       trigger_condition_list=['Received_Campaign_Drugs'],
                       target_group={'agemin': 5, 'agemax': 12, 'gender': 'Female'},
                       nodeIDs=village_nodes,
                       target_residents_only=False
                       )
    elif intervention == 'ivermectin_MDA' :
        add_ivermectin(cb, box_duration=ivm_duration, coverage=coverage,
                       start_days=[365 + 152 + 30 * x for x in range(3)],
                       nodeIDs=village_nodes,
                       target_group={'agemin': 5, 'agemax': 200, 'gender': 'Male'},
                       target_residents_only=False,
                       ind_property_restrictions=IPR
                       )
        add_ivermectin(cb, box_duration=ivm_duration, coverage=coverage,
                       start_days=[365 + 152 + 30 * x for x in range(3)],
                       nodeIDs=village_nodes,
                       target_group={'agemin': 51, 'agemax': 200, 'gender': 'Female'},
                       target_residents_only=False,
                       ind_property_restrictions=IPR
                       )
        add_ivermectin(cb, box_duration=ivm_duration, coverage=coverage,
                       start_days=[365 + 152 + 30 * x for x in range(3)],
                       nodeIDs=village_nodes,
                       target_group={'agemin': 5, 'agemax': 12, 'gender': 'Female'},
                       target_residents_only=False,
                       ind_property_restrictions=IPR
                       )

    forest_HS_coverage = coverage if intervention == 'forest_HS' else 0.4
    add_health_seeking(cb, start_day=0,
                       drug=['Artemether', 'Lumefantrine'],
                       nodes=village_nodes,
                       targets=[
                           {'trigger': 'NewClinicalCase', 'coverage': forest_HS_coverage, 'seek': 1, 'rate': 0.2}],
                       ind_property_restrictions=[{'ForestGoing': 'LovesForest'}]
                       )

    event_trigger_list=['Received_Treatment']
    if 'ivermectin' in intervention :
        event_trigger_list.append('Received_Ivermectin')
    if 'drug' in intervention :
        event_trigger_list.append('Received_Campaign_Drugs')
    add_event_counter_report(cb, event_trigger_list=event_trigger_list)

    return { 'intervention' : intervention,
             'coverage' : coverage,
             'target' : target,
             'IVM duration' : ivm_duration}