add_mosquito_release(cb, start_day=200, species='arabiensis', repetitions=1, number=number, released_genome=[['X', 'X'], ['b0', 'b0']]) return {'Label': label, 'Number': number} if __name__ == "__main__": expname = 'vector_genetics_single_node_introgression' sim_duration = 365 * 6 num_seeds = 50 SetupParser('HPC') cb = DTKConfigBuilder.from_defaults('VECTOR_SIM') set_climate_constant(cb) set_species_param(cb, 'arabiensis', 'Larval_Habitat_Types', {"CONSTANT": 11250000000}) set_species_param(cb, 'arabiensis', 'Male_Life_Expectancy', 5) set_species_param(cb, 'arabiensis', 'Adult_Life_Expectancy', 10) set_species_param(cb, 'arabiensis', 'Transmission_Rate', 0.5) set_species_param(cb, 'arabiensis', 'Indoor_Feeding_Fraction', 1.0) ########################## VECTOR GENETICS #################################################### # Add genes genes = {'arabiensis': [{ "Alleles": {"a0": 1.0, "b0": 0.0}, "Mutations": {"a0:b0": 0.0, "b0:a0": 0.0} }]
from simtools.ModBuilder import ModFn, ModBuilder from malaria.reports.MalariaReport import add_patient_report, add_survey_report, add_summary_report from dtk.interventions.input_EIR import add_InputEIR # General -------------------------------------------------------------------------------------------------------- exp_name = 'PfPR_by_EIR_sweep_matching_regression_defaults' years = 50 # length of simulation, in years num_seeds = 5 report_start = years - 5 # Setup ---------------------------------------------------------------------------------------------------------- # config_path = os.path.join('.', 'inputs','config.json') # cb = DTKConfigBuilder.from_files(config_path) cb = DTKConfigBuilder.from_defaults('MALARIA_SIM') cb.update_params({ "Demographics_Filenames": ["Namawala_single_node_demographics_balanced_pop_growth.json"], "x_Base_Population": 1, "Enable_Disease_Mortality": 0, "Max_Individual_Infections": 10, "Number_Basestrains": 1, "Number_Substrains": 0, "Maternal_Antibodies_Type":
print "migration off!!!" cb.update_params( {'Migration_Model': 'NO_MIGRATION'} ) #'NO_MIGRATION' is actually default for MALARIA_SIM, but might as well make sure it's off if True: exp_name = 'GridTest_v2' location = 'HPC' SetupParser.default_block = location num_cores = 1 num_years = 2 cb = DTKConfigBuilder.from_defaults( 'MALARIA_SIM', #'VECTOR_SIM' Num_Cores=num_cores, Simulation_Duration=int(365 * num_years)) cb.set_experiment_executable('inputs/Eradication.exe') cb.set_input_files_root('inputs') cb.update_params({ 'Enable_Spatial_Output': 1, # spatial reporting 'Spatial_Output_Channels': [ 'Infectious_Vectors', 'Adult_Vectors', 'New_Infections', 'Population', 'Prevalence', 'New_Diagnostic_Prevalence', 'Daily_EIR', 'New_Clinical_Cases', 'Human_Infectious_Reservoir', 'Daily_Bites_Per_Human', 'Land_Temperature', 'Relative_Humidity', 'Rainfall', 'Air_Temperature' ]
from dtk.utils.core.DTKConfigBuilder import DTKConfigBuilder from dtk.vector.study_sites import configure_site from simtools.ExperimentManager.ExperimentManagerFactory import ExperimentManagerFactory from simtools.SetupParser import SetupParser # This block will be used unless overridden on the command-line SetupParser.default_block = 'HPC' cb = DTKConfigBuilder.from_defaults('VECTOR_SIM', Simulation_Duration=365) configure_site(cb, 'Namawala') # run_sim_args is what the `dtk run` command will look for run_sim_args = { 'exp_name': 'ExampleSim', 'config_builder': cb } # If you prefer running with `python example_sim.py`, you will need the following block if __name__ == "__main__": SetupParser.init() exp_manager = ExperimentManagerFactory.init() exp_manager.run_simulations(**run_sim_args) # Wait for the simulations to be done exp_manager.wait_for_finished(verbose=True) assert (exp_manager.succeeded())
foi_out = [ np.repeat(0, repeats=len(days_sim)) for ii in range(0, node_cnt) ] for ss in range(0, node_cnt): for yy in range(0, len(times[ss])): times[ss][yy] = times[ss][yy] * len(days_sim) foi_out[ss] = \ foi_out[ss] + \ heights[ss][yy] * \ sp.stats.norm(times[ss][yy], widths[ss][yy]).pdf(days_sim) return foi_out cb = DTKConfigBuilder.from_defaults( 'DENGUE_SIM') # should be from_files (check what cls means) #configure_site(cb, 'Puerto_Rico') cb.set_param('Koppen_Filename', "") climate_file_path = 'D:\\Eradication/InputDataFiles/Colombia_dept_nodes_admin2/%s/' % site_name cb.set_input_files_root(climate_file_path) cb.set_experiment_executable('D:\\Eradication\\Executable\\Eradication.exe') cb.set_dll_root('D:\\Eradication\\bin') cb.set_param('Air_Temperature_Filename', '%s_admin2_air_temperature_daily.bin' % site_name) cb.set_param('Land_Temperature_Filename', '%s_admin2_air_temperature_daily.bin' % site_name) cb.set_param('Rainfall_Filename', '%s_admin2_rainfall_daily.bin' % site_name) cb.set_param('Relative_Humidity_Filename', '%s_admin2_humidity_daily.bin' % site_name) demo_file_name = "%s_admin2_nodes_demographics.json" % site_name mig_file_name = "%s_admin2_nodes_regional_migration_hi.bin" % site_name
from dtk.generic.serialization import add_SerializationTimesteps from single_node_simulations.helper_functions import change_vector_params, update_config_params, add_reporters if __name__ == "__main__": dir = './' geography = 'Burkina Faso' prefix = 'single_node_simulations' exp = 8.60 exp_name = "insecticide_resistance_single_node_serialization" num_years = 40 num_seeds = 1 cb = DTKConfigBuilder.from_defaults('MALARIA_SIM', Simulation_Duration=int(365 * num_years)) update_config_params(cb, direc=dir, geography=geography) add_SerializationTimesteps(cb, [num_years * 365], end_at_final=True) ########################## VECTOR GENETICS #################################################### builder = ModBuilder.from_list([ [ ModFn(DTKConfigBuilder.set_param, 'Run_Number', seed), ModFn(change_vector_params, species='gambiae', mutation_rate1=mutation_rate, mutation_rate2=mutation_rate, serialization_seed=seed)
def test_bad_simtype(self): self.assertRaises(Exception, lambda: DTKConfigBuilder.from_defaults('NOT_A_SIM'))
def setUp(self): self.cb = DTKConfigBuilder.from_defaults('MALARIA_SIM', Base_Air_Temperature=26)
def test_bad_kwargs(self): self.assertRaises(Exception, lambda: DTKConfigBuilder.from_defaults('MALARIA_SIM', Not_A_Climate_Parameter=26))
cb = DTKConfigBuilder.from_defaults( "MALARIA_SIM", Simulation_Duration=int(365 * years), Config_Name=sweep_name, Birth_Rate_Dependence="FIXED_BIRTH_RATE", Age_Initialization_Distribution_Type="DISTRIBUTION_COMPLEX", Num_Cores=1, # interventions Valid_Intervention_States=[], # apparently a necessary parameter # todo: do I need listed events? Listed_Events=[ "Bednet_Discarded", "Bednet_Got_New_One", "Bednet_Using", "Received_Vaccine" ], Enable_Default_Reporting=1, Enable_Demographics_Risk=1, Enable_Vector_Species_Report=0, # ento from prashanth Antigen_Switch_Rate=pow(10, -9.116590124), Base_Gametocyte_Production_Rate=0.06150582, Base_Gametocyte_Mosquito_Survival_Rate=0.002011099, Falciparum_MSP_Variants=32, Falciparum_Nonspecific_Types=76, Falciparum_PfEMP1_Variants=1070, Gametocyte_Stage_Survival_Rate=0.588569307, MSP1_Merozoite_Kill_Fraction=0.511735322, Max_Individual_Infections=3, Nonspecific_Antigenicity_Factor=0.415111634, )
'GENERIC_SIM_SIR', 'GENERIC_SIM_SEIR', 'GENERIC_SIM_SIRS', 'GENERIC_SIM_SEIRS', 'GENERIC_SIM_SI', 'GENERIC_SIM_SIS', 'GENERIC_SIM_SIR_Vaccinations_A', 'GENERIC_SIM_SIR_Vaccinations_B', 'GENERIC_SIM_SIR_Vaccinations_C' ] if __name__ == '__main__': # Initialize the SetupParser to use HPC SetupParser.init(selected_block='HPC') # Create an experiment manager exp_mgr = ExperimentManagerFactory.init() # For each generic simulations, create a config builder from the default and run it for sim_example in generic_defaults: cb = DTKConfigBuilder.from_defaults(sim_example) cb.set_param("Config_Name", sim_example) # Create a builder in order to run a single simulation # This step is optional usually but it allows us to set tags on the simulation builder = SingleSimulationBuilder() builder.tags.update({"Simulation_Type": sim_example}) exp_mgr.run_simulations(config_builder=cb, exp_builder=builder, exp_name=experiment_name) # Wait for the experiment to finish exp_mgr.wait_for_finished() print("Congratulations! they ran.")
from dtk.interventions.malaria_drug_campaigns import add_drug_campaign from dtk.utils.analyzers.DownloadAnalyzer import DownloadAnalyzer exp_name = 'Parasite Population Surveys' testing = False """ Construct a baseline scenario with: * Holoendemic Sahel initial immunity + seasonal force-of-infection * Survey reporter into rainy season and through following dry season """ cb = DTKConfigBuilder.from_defaults('MALARIA_SIM', Num_Cores=1, Simulation_Duration=365 if testing else 365*3 ) configure_site_EIR(cb, 'Sugungum', habitat=0.01 if testing else 1, birth_cohort=False, static=True, pop_scale=0.1) cb.config['parameters']['Demographics_Filenames'].append( 'Garki_Single/immune_init/Sugungum/Garki_single_immune_init_Sugungum_x_1.0.json') cb.set_param("Immunity_Initialization_Distribution_Type", "DISTRIBUTION_COMPLEX") survey_day = 100 if testing else 365 + 280 # early October add_survey_report(cb, survey_days=[survey_day],
# Set the simulation duration. Needs to be longer than the last timestep to serialize Simulation_Duration = 365 # Choose at which timesteps we want to serialize. Here 5, 10 and 50 timesteps_to_serialize = [5, 10, 50] # Which timesteps we want to reload from ? timestep_to_reload = timesteps_to_serialize[-1] # Let's choose 50 if __name__ == "__main__": # Initialize the SetupParser SetupParser.init() # Create a configbuilder for the simulation to serialize cb_serializing = DTKConfigBuilder.from_defaults('VECTOR_SIM') configure_site(cb_serializing, 'Namawala') cb_serializing.set_param("Simulation_Duration", Simulation_Duration) # Create an experiment manager exp_manager = ExperimentManagerFactory.init() # Set those timesteps add_SerializationTimesteps(config_builder=cb_serializing, timesteps=timesteps_to_serialize, end_at_final=True) # Run the simulation exp_manager.run_simulations(config_builder=cb_serializing, exp_name="Sample serialization test") # Wait for it to finish exp_manager.wait_for_finished()