from simtools.SetupParser import SetupParser try: from malaria.study_sites.DielmoCalibSite import DielmoCalibSite except ImportError as e: message = "The malaria package needs to be installed before running this example...\n" \ "Please run `dtk get_package malaria -v HEAD` to install" raise ImportError(message) SetupParser.default_block = 'HPC' cb = DTKConfigBuilder.from_defaults('MALARIA_SIM') sites = [DielmoCalibSite()] plotters = [LikelihoodPlotter(combine_sites=True), SiteDataPlotter(num_to_plot=5, combine_sites=True), # 10 OptimToolSPSAPlotter()] # OTP must be last because it calls gc.collect() # Antigen_Switch_Rate (1e-10 to 1e-8, log) # Falciparum_PfEMP1_Variants (900 to 1700, linear int) # Falciparum_MSP_Variants (5 to 50, linear int) # The following params can be changed by stopping 'calibool', making a modification, and then resuming. # Things you can do: # * Change the min and max, but changing the guess of an existing parameter has no effect # * Make a dynamic parameter static and vise versa # * Add and remove (needs testing) parameters params = [ { 'Name': 'Clinical Fever Threshold High',
##Incubation period and reporting delays cb.set_param('Incubation_Period_Log_Mean', log(3)) cb.set_param('Incubation_Period_Log_Width', log(1.04)) cb.set_param('Reporting_Period_Log_Mean', log(7)) cb.set_param('Reporting_Period_Log_Width', log(2)) ###Simulation parameters sim_length = 159 * 7 #Length of Colombia timeseries cb.set_param('Simulation_Duration', sim_length) #86*7) cb.campaign["Campaign_Name"] = "Campaign - Outbreak" # add_OutbreakIndivisualDengue(cb, 520, {},0.0005, 'Strain_1', []) # add_OutbreakIndivisualDengue(cb, 580, {},0.0005, 'Strain_1', []) # add_OutbreakIndivisualDengue(cb, 640, {},0.0005, 'Strain_1', []) cb.params['.logLevel_JsonConfigurable'] = 'WARNING' sites = [ColombiaTSSite(site_name)] plotters = [LikelihoodPlotter(True)] def create_param(name, guess, min, max): return { 'Name': name, 'Dynamic': True, 'Guess': guess, 'Min': min, 'Max': max } params = [] # Add TEMPORARY_RAINFALL
force_apply=True # Set to True to re-download and call "apply" again ) ] # # ***************************** END PRINCIPAL SECTION OF THIS EXAMPLE **************************** # # dtk analyze compatibility site = sites[0] analyzers = site.analyzers # Restrict to only those params that are initially active params = [p for p in params if p['Dynamic']] plotters = [LikelihoodPlotter(), OptimToolPlotter()] # Setting up our model configuration from templates dir_path = os.path.dirname(os.path.realpath(__file__)) template_files_dir = os.path.join(dir_path, 'Templates') static_files_dir = os.path.join(dir_path, 'Static') demog = DemographicsTemplate.from_file( os.path.join(static_files_dir, 'Rakai_Demographics_With_Properties.json')) demog_pfa = DemographicsTemplate.from_file( os.path.join(template_files_dir, 'PFA_Overlay.json')) demog_acc = DemographicsTemplate.from_file( os.path.join(template_files_dir, 'Accessibility_and_Risk_IP_Overlay.json')) demog_asrt = DemographicsTemplate.from_file( os.path.join(template_files_dir, 'Risk_Assortivity_Overlay.json'))
from calibtool.Prior import MultiVariatePrior from calibtool.algorithms.IMIS import IMIS from calibtool.plotters.LikelihoodPlotter import LikelihoodPlotter from calibtool.plotters.SiteDataPlotter import SiteDataPlotter from calibtool.study_sites.DielmoCalibSite import DielmoCalibSite from dtk.utils.core.DTKConfigBuilder import DTKConfigBuilder from simtools.SetupParser import SetupParser cb = DTKConfigBuilder.from_defaults('MALARIA_SIM') sites = [DielmoCalibSite()] prior = MultiVariatePrior.by_range(Antigen_Switch_Rate_LOG=('linear', -10, -8), ) plotters = [LikelihoodPlotter(True), SiteDataPlotter(True)] def sample_point_fn(cb, sample_dimension_values): ''' A simple example function that takes a list of sample-point values and sets parameters accordingly using the parameter names from the prior. Note that more complicated logic, e.g. setting campaign event coverage or habitat abundance by species, can be encoded in a similar fashion using custom functions rather than the generic "set_param". ''' sample_point = prior.to_dict(sample_dimension_values) params_to_update = dict() params_to_update['Simulation_Duration'] = 365 for sample_dimension_name, sample_dimension_value in sample_point.items(): param_name = sample_dimension_name.replace('_LOG', '') params_to_update[param_name] = pow(10, sample_dimension_value)