plot_sampleplots.py¶
all_age_sample_plot(wdir, df, model, timestep_var, sweep_variables, sample_channels)
¶
Generate a sample plot for all age data. This function aggregates data based on the provided sweep variables and generates a set of plots for specified channels. Each plot shows the mean of the channels over time (based on the provided timestep variable). The plots are saved as a PNG file.
Parameters: |
|
---|
Returns: |
|
---|
Saves
sampleplot_all_age_{model}.png: A PNG file containing the generated plots.
Source code in plotter\plot_sampleplots.py
assign_age_group(age_range, categories)
¶
Assign an age group based on a given age range and predefined category bounds. This function checks which predefined age category a given age range falls into by comparing the minimum and maximum age values with the bounds of each category. If the range overlaps or fits entirely within a category, the corresponding category is returned. If no match is found, the function returns None.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
clean_fname(fname, sweepvar=None, unique_groups=None, facet_var=None, unique_facets=None)
¶
Clean and modify a given filename by replacing placeholder variables with actual values. This function replaces placeholder values in the provided filename based on the provided parameters. Specifically, it replaces instances of the sweep variable and facet variable with values from the unique groups and facets, if applicable, and changes ‘models’ to ‘model’.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
color_selector(i, s)
¶
Select a color index based on the model name.
This function returns a color index based on the specified model name. If the model name is recognized, a predefined index is returned; otherwise, the input index is returned.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
convert_to_date(x)
¶
Convert a number of days since January 1, 2005, to a date.
This function takes an integer representing the number of days since January 1, 2005, and returns the corresponding date.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
custom_sort_key(age_group)
¶
Custom sort key function for sorting age groups.
This function extracts the lower bound of an age group represented as a string in the format ‘X-Y’ and returns it as an integer. It is primarily used for sorting age groups in ascending order based on their lower bounds.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
get_label(channel)
¶
Retrieve the label for a given outcome. This function returns a formatted string representing the y-axis label based on the specified channel name. The labels correspond to specific epidemiological measures. If the channel is not recognized, the function simply returns the input channel name as-is.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
get_legend_title(sweepvar, exp=None)
¶
Retrieves the corresponding legend title for a given sweep variable.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
get_output_df(wdir, models, yr=False, mth=False, daily=False, custom_name=None, save_combined=False)
¶
Load and combine data from the model output files.
This function reads model output files from a specified working directory and combines the data into a single DataFrame. It supports different data formats based on the specified parameters for yearly, monthly, or daily data.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|
Source code in plotter\plot_helper.py
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 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
|
get_x_y(df, grpvar, x_channel, y_channel)
¶
Calculate x-axis and y-axis values for each plot.
This function groups the input DataFrame by a specified variable and calculates the mean values for the specified x and y channels. It also computes the 95% confidence interval for the y values.
Parameters: |
|
---|
Returns: |
|
---|
Source code in plotter\plot_helper.py
load_exp(wdir)
¶
Load experiment setup and scenario data into an Exp object.
wdir (str): The working directory containing ‘exp_setup_df.csv’, ‘scenarios.csv’, and optionally ‘exp.obj’.
Exp: An object with attributes set from ‘exp.obj’, or dynamically built from ‘exp_setup_df.csv’ and ‘scenarios.csv’.
Source code in plotter\plot_helper.py
parse_args()
¶
Parses command-line arguments for simulation specifications.
This function uses the argparse library to handle command-line inputs required for running simulation experiments. It defines required and optional arguments, including the job directory and model names.
Returns: |
|
---|
Command Line Arguments
-d/–directory (str): The job directory where the exp.obj file is located. This argument is required. -m/–models (str): One or more model names to compare. This argument is optional and defaults to [‘EMOD’, ‘OpenMalaria’, ‘malariasimulation’].
Source code in plotter\plot_helper.py
subset_dataframe_for_plot(df, figure_vars, agegrps=None, filter_target=True)
¶
Filter the input DataFrame for plotting based on specified criteria.
This function filters the DataFrame according to the provided figure variables, optional age groups, and other selection criteria to prepare the data for visualization. It also returns a string summarizing the filtering applied.
Parameters: |
|
---|
Returns: |
|
---|
Raises: |
|
---|