plot_timeseries.py¶
annual_timeseries(fdir, df, channel, sweepvar='models', facet_var='seasonality', agegrps=['0-100'], calendar_year=False, facet_name=None, exp=None)
¶
Parameters: |
|
---|
Returns: None (plots are saved to disk).
Source code in plotter\plot_timeseries.py
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
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
|
monthly_timeseries(fdir, df, channel, sweepvar='models', facet_var='ageGroup', agegrps=['0-100'], calendar_year=False, facet_name=None, exp=None)
¶
Parameters: |
|
---|
Returns: None (plots are saved to disk).
Source code in plotter\plot_timeseries.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 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 |
|
monthly_trends(fdir, df, channel, sweepvar='models', facet_var='target_output_values', agegrps=['0-100'], new_index=None, facet_name=None, exp=None)
¶
Generate line plots for monthly trends for channel (yaxis) by sweepvar for selected age groups. Note, assumed single occurence per month, i.e. aggregated across years (reads in mmmpy_mth.csv) Parameters: fdir (str): Directory where the plot will be saved. df (pandas dataframe): Dataframe that includes combined model results. channel (str): Variable representing the y-axis data to be plotted. sweepvar (str, optional): Variable to group the data and create multiple lines on the plot. Default is ‘target_output_values’. agegrp (str, optional): Age group filter for the data. Default is ‘0-5’. Returns: None (plots are saved to disk). Raises: ValueError: If no seasonal transmission pattern is specified in the data.
Source code in plotter\plot_timeseries.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: |
|
---|
Source code in plotter\plot_helper.py
|