-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_LGA_2020_forward.py
178 lines (155 loc) · 8.07 KB
/
run_LGA_2020_forward.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
143
144
145
146
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
from dtk.utils.core.DTKConfigBuilder import DTKConfigBuilder
from simtools.ExperimentManager.ExperimentManagerFactory import ExperimentManagerFactory
from simtools.SetupParser import SetupParser
from simtools.ModBuilder import ModBuilder, ModFn
from malaria.reports.MalariaReport import add_filtered_report, add_summary_report
#from simulation.load_paths import load_box_paths
from simulation.simulation_setup_helpers import update_basic_params, set_up_hfca, load_master_csv, habitat_scales, add_all_interventions, update_drug_config
import os
from malaria.interventions.malaria_drug_campaigns import add_drug_campaign
import pandas as pd
#datapath, projectpath = load_box_paths()
user_path = 'C:/Users/ido0493'
home_path = os.path.join(user_path, 'Box', 'NU-malaria-team')
datapath = os.path.join(home_path, 'data')
projectpath = os.path.join(home_path, 'projects', 'hbhi_nigeria')
num_seeds = 5
years = 11
ser_date = 10*365
serialize = False
pull_from_serialization = True
sulf_C50 = 0.2
burnin_id = '606a2551-46d9-eb11-a9ec-b88303911bc1'
if __name__ == "__main__":
scenario_fname = os.path.join(projectpath, 'simulation_inputs',
'projection_csvs', 'projection_v4', 'Intervention_scenarios_nigeria_v4.csv') # use script for loading all files for scenarios
scen_df = pd.read_csv(scenario_fname)
scen_index = scen_df[scen_df['status'] == 'run'].index[0]
expname = 'NGA projection scenario %d' % scen_df.at[scen_index, 'Scenario_no']
cb = DTKConfigBuilder.from_defaults('MALARIA_SIM')
cb.update_params({
'Simulation_Duration': years * 365 + 1,
"Vector_Species_Names": ['arabiensis', 'funestus', 'gambiae'],
'Enable_Default_Reporting': 0,
'Enable_Property_Output': 0,
'Enable_Vector_Species_Report': 0,
'Report_Detection_Threshold_Blood_Smear_Parasites': 50,
"Parasite_Smear_Sensitivity": 0.02, # 50/uL
# 'Base_Population_Scale_Factor' : 0.01,
'x_Temporary_Larval_Habitat' : 0.03/0.15,
"Report_Event_Recorder" : 1,
"Report_Event_Recorder_Individual_Properties" : [],
"Report_Event_Recorder_Events" : ['Received_Severe_Treatment'],
"Report_Event_Recorder_Ignore_Events_In_List" : 0,
'Listed_Events' : ['Bednet_Got_New_One', 'Bednet_Using', 'Bednet_Discarded','Received_Severe_Treatment']
})
if serialize:
cb.update_params({
'Serialization_Time_Steps': [365 * years],
'Serialization_Type': 'TIMESTEP',
'Serialization_Mask_Node_Write': 0,
'Serialization_Precision': 'REDUCED'
})
# BASIC SETUP
update_basic_params(cb)
# INTERVENTIONS
# malaria testing prompted by NMF
for nmf_years in range(years):
add_drug_campaign(cb, 'MSAT', 'AL',
start_days=[1 + 365 * nmf_years],
coverage=0.0038,
repetitions=365, tsteps_btwn_repetitions=1,
diagnostic_type='PF_HRP2', diagnostic_threshold=5,
receiving_drugs_event_name='Received_NMF_Treatment')
# health-seeking
try:
hs_df = pd.read_csv(os.path.join(projectpath, 'simulation_inputs','projection_csvs', 'projection_v4',
'%s.csv' % scen_df.at[scen_index, 'CM_filename']))
except IOError:
hs_df = pd.DataFrame()
# ITNs
try :
itn_df = pd.read_csv(os.path.join(projectpath, 'simulation_inputs','projection_csvs', 'projection_v4',
'%s.csv' % scen_df.at[scen_index, 'ITN_filename']))
except IOError :
itn_df = pd.DataFrame()
# ITN ANC
try:
itn_anc_df = pd.read_csv(os.path.join(projectpath, 'simulation_inputs', 'projection_csvs', 'projection_v4',
'%s.csv' % scen_df.at[scen_index, 'ANC_filename']))
except IOError:
itn_anc_df = pd.DataFrame()
# IRS
try:
irs_df = pd.read_csv(os.path.join(projectpath, 'simulation_inputs', 'projection_csvs', 'projection_v4',
'%s.csv' % scen_df.at[scen_index, 'IRS_filename']))
except IOError:
irs_df = pd.DataFrame()
# SMC
try :
smc_df = pd.read_csv(os.path.join(projectpath, 'simulation_inputs', 'projection_csvs', 'projection_v4',
'%s.csv' % scen_df.at[scen_index, 'SMC_filename']))
except IOError :
smc_df = pd.DataFrame()
# CUSTOM REPORTS
add_filtered_report(cb, start=0, end=years * 365)
for year in range(years):
for year in range(years):
add_summary_report(cb, start=365 * year,
age_bins= [0.25, 5, 15, 30,50, 125],
interval=30, duration_days=365,
description='Monthly%d' %(year + 2020), parasitemia_bins = [10, 50, 1e9])
add_summary_report(cb, start=365 * year, age_bins=[1, 5, 120],
interval=30, duration_days=365,
description='FineMonthly%d' %(year + 2020), parasitemia_bins = [10, 50, 1e9])
# FOR CONFIGURING LARVAL HABTIATS
hab_scale_factor_fname = os.path.join(projectpath, 'simulation_inputs', 'larval_habitats',
'larval_habitat_multipliers_v4.csv')
hab_df = pd.read_csv(hab_scale_factor_fname)
hab_df = hab_df.set_index('LGA')
rel_abundance_df = habitat_scales()
lhdf = pd.read_csv(os.path.join(projectpath, 'simulation_inputs', 'larval_habitats','monthly_habitatv2.csv'))
df = load_master_csv()
df.reset_index(inplace=True)
df = df.set_index('LGA')
my_ds_list = list(df.index.values)
# BUILDER
builder = ModBuilder.from_list([[ModFn(set_up_hfca, hfca=my_hfca,
archetype_hfca=df.at[my_hfca, 'Archetype'],
pull_from_serialization=pull_from_serialization,
burnin_id=burnin_id,
ser_date=ser_date,
hdf=rel_abundance_df,
lhdf=lhdf,
from_arch=False,
hab_multiplier=hab_df.at[df.at[my_hfca, 'Archetype'], 'Habitat_Multiplier'],
run_number=0),
ModFn(add_all_interventions,
irs_df=irs_df,
smc_df=smc_df,
itn_df=itn_df,
itn_anc_df=itn_anc_df,
hs_df=hs_df,
hfca=my_hfca),
ModFn(update_drug_config,
# note: this call updates all other drug params to the values specified in the update_drug_params.py file
list_drug_param=['Sulfadoxine', 'Drug_PKPD_C50'],
value=sulf_C50),
ModFn(DTKConfigBuilder.set_param, 'Run_Number', x),
ModFn(DTKConfigBuilder.set_param, 'Scenario_Number', scen_index),
ModFn(DTKConfigBuilder.set_param, 'Habitat_Multiplier',
hab_df.at[my_hfca, 'Habitat_Multiplier']),
]
# for my_hfca in ['Silame']
for my_hfca in df.index
for x in range(num_seeds)
])
run_sim_args = {
'exp_name': expname,
'config_builder': cb,
'exp_builder': builder
}
SetupParser.default_block = 'HPC'
SetupParser.init()
exp_manager = ExperimentManagerFactory.init()
exp_manager.run_simulations(**run_sim_args)