Esempio n. 1
0
    def __init__(self, 
                 filter_function=lambda md: True,
                 channels=[],
                 onlyPlotFailed=True):

        TimeseriesAnalyzer.__init__(self ,filter_function=filter_function, 
                                    group_function=group_by_name('Config_Name'),
                                    plot_function=plot_lines,
                                    channels=channels, 
                                    saveOutput=False)

        self.onlyPlotFailed=onlyPlotFailed
        self.results = defaultdict(list)
        setup = SetupParser()
        self.regression_path = os.path.join(setup.get('dll_root'),
                                            '..', '..', 'Regression')
Esempio n. 2
0
    def __init__(self,
                 filename=os.path.join('output', 'MalariaSummaryReport_AnnualAverage.json'),
                 filter_function=lambda md: True,  # no filtering based on metadata
                 select_function=lambda ts: pd.Series(ts),  # return complete-&-unaltered timeseries
                 group_function=lambda k, v: k,  # group by unique simid-key from parser
                 plot_function=plot_grouped_lines,
                 channels=['Annual EIR', 'PfPR_2to10'],

                 ### TODO: plot quantities versus age ###
                 # ,'Average Population by Age Bin',
                 # 'PfPR by Age Bin', 'RDT PfPR by Age Bin',
                 # 'Annual Clinical Incidence by Age Bin',
                 # 'Annual Severe Incidence by Age Bin'],

                 saveOutput=False):
        TimeseriesAnalyzer.__init__(self, filename,
                                    filter_function, select_function,
                                    group_function, plot_function,
                                    channels, saveOutput)

        self.agebins = []
Esempio n. 3
0
def builtinAnalyzers():
    analyzers = {
        'time_series':
        TimeseriesAnalyzer(select_function=sample_selection(),
                           group_function=group_by_name('_site_'),
                           plot_function=plot_grouped_lines),
        'vector_species':
        VectorSpeciesAnalyzer(select_function=sample_selection(),
                              group_function=group_by_name('_site_')),
    }

    return analyzers
Esempio n. 4
0
    def apply(self, parser):
        test_channel_data = TimeseriesAnalyzer.apply(self, parser)

        reference_path = os.path.join(self.regression_path,
                                      parser.sim_data['Config_Name'],
                                      self.filenames[0])
        with open(reference_path) as f:
            data_by_channel = json.loads(f.read())['Channels']
        ref_channel_data = self.get_channel_data(data_by_channel)

        channel_data = pd.concat(dict(test = test_channel_data, reference = ref_channel_data), axis=1)
        channel_data.group = test_channel_data.group
        channel_data.sim_id = test_channel_data.sim_id
        return channel_data
Esempio n. 5
0
        ModFn(DTKConfigBuilder.set_param, 'Run_Number', seed)
        for seed in range(5)
    ],
)

# The run_sim_args is a dictionary informing the command line of:
# - What config builder to use
# - What is the name we want for the experiment
# - Which experiment builder to use
run_sim_args = {
    'config_builder': cb,
    'exp_name': 'Sample larvicides epxeriment',
    'exp_builder': builder
}

# In this file we also decided to include the analyzers.
# When present the `analyzers` variable is an array of Analyzers that will be executed when
# the command `dtk analyze larvicides_campaign.py` is called.
# Here we are using a simple TimeSeriesAnalyzer, grouping the simulations by the larvicide_start tag (averaging
# across the Run_Number). And displaying the results for 3 vector related channels.
analyzers = [
    TimeseriesAnalyzer(group_function=group_by_name('larvicide_start'),
                       channels=['Daily EIR', 'Adult Vectors', 'Infected'])
]

if __name__ == "__main__":
    SetupParser.init()
    em = ExperimentManagerFactory.init()
    em.run_simulations(**run_sim_args)
    em.wait_for_finished(verbose=True)
Esempio n. 6
0
from dtk.utils.analyzers import TimeseriesAnalyzer, VectorSpeciesAnalyzer
from simtools.AnalyzeManager.AnalyzeManager import AnalyzeManager
from simtools.Utilities.Experiments import retrieve_experiment

if __name__ == "__main__":
    # Retrieve a couple of test experiments
    experiment1 = retrieve_experiment('158cc530-780e-e711-9400-f0921c16849c')
    experiment2 = retrieve_experiment('c62aa746-780e-e711-9400-f0921c16849c')

    # Create an analyze manager
    # Note that we are adding the experiments that we want to analyze
    am = AnalyzeManager(exp_list=[experiment1, experiment2])

    # Add the TimeSeriesAnalyzer to the manager
    am.add_analyzer(TimeseriesAnalyzer())
    am.add_analyzer(VectorSpeciesAnalyzer())

    # Analyze
    am.analyze()
from dtk.utils.analyzers import name_match_filter, group_by_name, plot_grouped_lines, \
                                TimeseriesAnalyzer, RegressionTestAnalyzer

analyzers = [
    TimeseriesAnalyzer(group_function=group_by_name('Config_Name'),
                       plot_function=plot_grouped_lines),
    RegressionTestAnalyzer(filter_function=name_match_filter('Vector'),
                           channels=[
                               'Statistical Population', 'Rainfall',
                               'Adult Vectors', 'Daily EIR', 'Infected',
                               'Parasite Prevalence'
                           ],
                           onlyPlotFailed=False)
]
Esempio n. 8
0
from dtk.utils.builders.sweep import GenericSweepBuilder
from dtk.utils.core.DTKConfigBuilder import DTKConfigBuilder
from dtk.vector.study_sites import configure_site
from simtools.Analysis.AnalyzeManager import AnalyzeManager
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')
configure_site(cb, 'Namawala')
cb.set_param('Simulation_Duration',365)


analyzers = (TimeseriesAnalyzer(),
             VectorSpeciesAnalyzer())


builder = GenericSweepBuilder.from_dict({'Run_Number': range(5)})

run_sim_args =  {
    'exp_name': 'testrunandanalyze',
    'exp_builder': builder,
    'config_builder':cb
}

if __name__ == "__main__":
    SetupParser.init(selected_block=SetupParser.default_block)
    exp_manager = ExperimentManagerFactory.from_cb(config_builder=cb)
    exp_manager.run_simulations(**run_sim_args)
Esempio n. 9
0
from dtk.utils.analyzers import TimeseriesAnalyzer, VectorSpeciesAnalyzer, sample_selection
from dtk.utils.analyzers.group import group_by_name
from dtk.utils.analyzers.plot import plot_grouped_lines

analyzers = [
    TimeseriesAnalyzer(select_function=sample_selection(),
                       group_function=group_by_name('_site_'),
                       plot_function=plot_grouped_lines),
    VectorSpeciesAnalyzer(
        select_function=sample_selection(),
        group_function=group_by_name('_site_'),
    )
]