Beispiel #1
0
def add_forest_migration(cb, start, years, forest, non_forest,
                         mig_type='one_season') :

    if mig_type == 'one_season' :
        months_of_mig = 5
    elif mig_type == 'planting' :
        months_of_mig = 1
        second_season_offset = 6
    else :
        print('Warning: Unrecognized migration type %s' % mig_type)
        return

    # add seasonal migration to forest nodes
    for node_id in forest:

        nodes_from = non_forest


        for year in range(years):

            add_migration_event(cb, nodeto=node_id,
                                duration_at_node_distr_type='GAUSSIAN_DURATION',
                                start_day=year*365 + start,
                                coverage=0.5,
                                duration_of_stay=30,
                                duration_of_stay_2=10,
                                duration_before_leaving_distr_type='GAUSSIAN_DURATION',
                                duration_before_leaving=3,
                                duration_before_leaving_2=0.75,
                                repetitions=4*months_of_mig,  # NORMALLY 5 months of migration (4*5)
                                tsteps_btwn=7,  # send a pulse every week
                                # target=target_ages,
                                nodesfrom={'class': 'NodeSetNodeList',
                                           'Node_List': nodes_from},
                                ind_property_restrictions=[{"ForestGoing": "LovesForest"}])
            if mig_type == 'planting' :
                add_migration_event(cb, nodeto=node_id,
                                    duration_at_node_distr_type='GAUSSIAN_DURATION',
                                    start_day=year * 365 + start + second_season_offset*30,  # start in august of each year + 6m for end of planting
                                    coverage=0.5,
                                    duration_of_stay=30,
                                    duration_of_stay_2=10,
                                    duration_before_leaving_distr_type='GAUSSIAN_DURATION',
                                    duration_before_leaving=3,
                                    duration_before_leaving_2=0.75,
                                    repetitions=4 * months_of_mig,  # 1 month of migration
                                    tsteps_btwn=7,  # send a pulse every week
                                    # target=target_ages,
                                    nodesfrom={'class': 'NodeSetNodeList',
                                               'Node_List': nodes_from},
                                    ind_property_restrictions=[{"ForestGoing": "LovesForest"}])
    return { 'Forest_Migration_Start_Day' : start}
 def __call__(self, cb):
     return add_migration_event(cb, self.nodeto, start_day=self.start_day, coverage=self.coverage,
                                        repetitions=self.repetitions,
                                        tsteps_btwn=self.tsteps_btwn,
                                        duration_at_node_distr_type=self.duration_at_node_distr_type,
                                        duration_of_stay=self.duration_of_stay,
                                        duration_of_stay_2=self.duration_of_stay_2,
                                        duration_before_leaving_distr_type=self.duration_before_leaving_distr_type,
                                        duration_before_leaving=self.duration_before_leaving,
                                        duration_before_leaving_2=self.duration_before_leaving_2,
                                        target=self.target, nodesfrom=self.nodesfrom)
Beispiel #3
0
def add_travellers(cb, catch):
    all_nodes = list(find_cells_for_this_catchment(catch))

    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'
                        }])
Beispiel #4
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)
    all_nodes = list(mozamb_exp.desired_cells)

    cb.params['logLevel_JsonConfigurable'] = "WARNING"

    #travelers:
    cb.params['Disable_IP_Whitelist'] = 1
    add_migration_event(
        cb,
        nodeto=100000,
        # coverage=0.5,
        coverage=0,
        repetitions=500,
        # tsteps_btwn=30,
        tsteps_btwn=3000,
        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'
        }])

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

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

    # Add counter report for clinical incidence