class AnnualAgebinPfPRAnalyzer(IAnalyzer):
def __init__(self, expt_name, sweep_variables=None, working_dir='./', start_year=2022,
=2025, burnin=None):
end_yearsuper(AnnualAgebinPfPRAnalyzer, self).__init__(working_dir=working_dir,
=["output/MalariaSummaryReport_Annual_Agebin.json"]) filenames
By Time and Age Bin
Analyze MalariaSummaryReport
The summary report aggregates the monitored simulation outputs into user-specified agebins, monitoring intervals, and/or parasitemia bins. Outputs such as prevalence by age, incidence by age, and parasite density by age can be obtained through the summary report. Multiple summary reports can be requested in the simulation run script, and analyzers can be built to handle working with multiple summary reports.
Documentation on the summary report is here. If you are writing a new summary report analyzer, you will need to know which part of the summary report contains the data you need.
Within each summary report the channel DataByTimeAndAgeBins
reports monitored outputs per time and age it therefore needs to be indexed twice, one for selecting time range and one for selecting agebin. The outer list is time and the inner list is age.
In this example, the data of interest is in DataByTimeAndAgeBins
: we extract, for each age group, annually-aggregated PfPR, clinical incidence, severe incidence, and population. All outcomes are combined into a dataframe for each age group, then the age-specific dataframes are concatenated into a single dataframe.
Attaching the sweep variable for the respective simulation is done the same way across analyzers.
def map(self, data, simulation):
= pd.DataFrame()
adf = (self.end_year - self.start_year)
nyears = data[self.filenames[0]]['Metadata']['Age Bins']
age_bins = data[self.filenames[0]]['DataByTimeAndAgeBins']
d for age in range(len(age_bins)):
= [x[age] for x in d['PfPR by Age Bin'][:nyears]]
pfpr = [x[age] for x in d['Annual Clinical Incidence by Age Bin'][:nyears]]
clinical_cases = [x[age] for x in d['Annual Severe Incidence by Age Bin'][:nyears]]
severe_cases = [x[age] for x in d['Average Population by Age Bin'][:nyears]]
pop = pd.DataFrame({'year': range(self.start_year, self.end_year),
simdata 'PfPR': pfpr,
'Cases': clinical_cases,
'Severe cases': severe_cases,
'Pop': pop})
'agebin'] = age_bins[age]
simdata[= pd.concat([adf, simdata])
adf for sweep_var in self.sweep_variables:
if sweep_var in simulation.tags.keys():
= simulation.tags[sweep_var]
adf[sweep_var] return adf