sid.visualize_simulation_results
¶
Module Contents¶
Functions¶
|
Visualize the results one or more simulation results. |
|
|
|
Create the statistics for each dataset and merge them into one dataset. |
|
|
|
Calculate the infection rates and reproduction numbers for each date. |
|
|
|
Plot all rates for a single background variable |
|
Plot the rates over time. |
|
Save all plots as png and the layout as html. |
|
|
|
- visualize_simulation_results(data, outdir_path, infection_vars, background_vars, window_length=7)[source]¶
Visualize the results one or more simulation results.
- Parameters
data (str, pandas.DataFrame, Path, list) – list of paths to the pickled simulation results.
outdir_path (path) – path to the folder where to save the results. Careful, all contents are removed when the function is called.
infection_vars (list) – list of infection rates to plot
background_vars (list) – list of background variables by whose value to group the results. Have to be present in all simulation results.
window_length (int) – How many dates to use for the reproduction numbers.
- _create_rates_for_all_data(datasets, infection_vars, background_vars, window_length)[source]¶
Create the statistics for each dataset and merge them into one dataset.
- Parameters
datasets (list) – list of str, Paths to pickled DataFrames or pd.DataFrames.
infection_vars (list) – list of infection rates to plot
background_vars (list) – list of background variables by whose value to group the results. Have to be present in all simulation results.
window_length (int) – How many dates to use for the reproduction numbers.
- rates (pandas.DataFrame): DataFrame with the dates as index.
The columns are a MultiIndex with four levels: The outermost is the “bg_var” (“general” for the overall rate). The next is the “rate” (e.g. the infectious rate or r zero), then “bg_value”, the value of the background variable and last “data_id”.
- _create_statistics(df, infection_vars, background_vars, window_length)[source]¶
Calculate the infection rates and reproduction numbers for each date.
- Parameters
df (pandas.DataFrame) – The simulation results.
infection_vars (list) – list of infection rates to plot
background_vars (list) – list of background variables by whose value to group the results. Have to be present in all simulation results.
window_length (int) – How many dates to use for the reproduction numbers.
- Returns
- DataFrame with the statistics of one simulation run.
The index are the dates. The columns are a MultiIndex with three levels: The outermost is the “bg_var” (“general” for the overall rate). The next is the “bg_value”, the last is the “rate” (e.g. the infectious rate or r zero).
- Return type
rates (pandas.DataFrame)
- _create_rate_plots(rates, colors, title)[source]¶
Plot all rates for a single background variable
- Parameters
rates (pandas.DataFrame) – DataFrame with the dates as index. The columns are a MultiIndex with three levels: The outermost is the variable name (e.g. infectious or r_zero). The next are the values the background variable can take, the last “data_id”.
colors (list) – list of colors to use.
title (str) – the plot title will be the name of the rate plus this string.
- Returns
list of bokeh plots.
- Return type
plots (list)
- _export_plots_and_layout(title, plots, outdir_path)[source]¶
Save all plots as png and the layout as html.
- Parameters
title (bokeh.Div) – title element.
plots (list) – list of bokeh plots
outdir_path (pathlib.Path) – base path to which to append the plot name to build the path where to save each plot.