sid.plotting

Module Contents

Functions

plot_policy_gantt_chart(policies, effects=False, colors='categorical', fig_kwargs=None)

Plot a Gantt chart of the policies.

_complete_dates(df)

Complete dates.

_add_color_to_gantt_groups(df, colors)

Add a color for each affected contact model.

_add_positions(df)

Add positions.

_create_y_ticks_and_labels(df)

Create the positions and their related labels for the y axis.

plot_infection_rates_by_contact_models(df_or_time_series: Union[pandas.DataFrame, dask.dataframe.core.DataFrame], show_reported_cases: bool = False, unit: str = 'share', fig_kwargs: Optional[Dict[str, Any]] = None) → holoviews.HeatMap

Plot infection rates by contact models.

_is_data_prepared_for_heatmap(df)

Is the data prepared for the heatmap plot.

prepare_data_for_infection_rates_by_contact_models(time_series: dask.dataframe.core.DataFrame, show_reported_cases: bool = False, unit: str = 'share') → pandas.DataFrame

Prepare the data for the heatmap plot.

_adjust_channel_infected_by_contact_to_new_known_cases(df)

Adjust channel of infections by contacts to new known cases.

_find_channel_of_infection_for_individuals(df)

Find the channel of infected by contact for each individual.

_patch_channel_infected_by_contact(df, s)

Patch channel of infections by contact to only show channels for known cases.

Attributes

DEFAULT_FIGURE_KWARGS[source]
plot_policy_gantt_chart(policies, effects=False, colors='categorical', fig_kwargs=None)[source]

Plot a Gantt chart of the policies.

_complete_dates(df)[source]

Complete dates.

_add_color_to_gantt_groups(df, colors)[source]

Add a color for each affected contact model.

_add_positions(df)[source]

Add positions.

This functions computes the positions of policies, displayed as segments on the time line. For example, if two policies affecting the same contact model have an overlapping time windows, the segments are stacked and drawn onto different horizontal lines.

_create_y_ticks_and_labels(df)[source]

Create the positions and their related labels for the y axis.

ERROR_MISSING_CHANNEL = 'channel_infected_by_contact' is necessary to plot infection rates by contact models. Re-run the...[source]
DEFAULT_IR_PER_CM_KWARGS[source]
plot_infection_rates_by_contact_models(df_or_time_series: Union[pandas.DataFrame, dask.dataframe.core.DataFrame], show_reported_cases: bool = False, unit: str = 'share', fig_kwargs: Optional[Dict[str, Any]] = None) holoviews.HeatMap[source]

Plot infection rates by contact models.

Parameters
  • df_or_time_series (Union[pandas.DataFrame, dask.dataframe.core.DataFrame]) –

    The input can be one of the following two.

    1. It is a dask.dataframe.core.DataFrame which holds the time series from a simulation.

    2. It can be a pandas.DataFrame which is created with prepare_data_for_infection_rates_by_contact_models(). It allows to compute the data for various simulations with different seeds and use the average over all seeds.

  • show_reported_cases (bool, optional) – A boolean to select between reported or real cases of infections. Reported cases are identified via testing mechanisms.

  • unit (str) –

    The arguments specifies the unit shown in the figure.

    • "share" means that daily units represent the share of infection caused by a contact model among all infections on the same day.

    • "population_share" means that daily units represent the share of infection caused by a contact model among all people on the same day.

    • "incidence" means that the daily units represent incidence levels per 100,000 individuals.

  • fig_kwargs (Optional[Dict[str, Any]], optional) – Additional keyword arguments which are passed to heatmap.opts to style the plot. The keyword arguments overwrite or extend the default arguments.

Returns

heatmap – The heatmap object.

Return type

hv.HeatMap

_is_data_prepared_for_heatmap(df)[source]

Is the data prepared for the heatmap plot.

prepare_data_for_infection_rates_by_contact_models(time_series: dask.dataframe.core.DataFrame, show_reported_cases: bool = False, unit: str = 'share') pandas.DataFrame[source]

Prepare the data for the heatmap plot.

Parameters
  • time_series (dask.dataframe.core.DataFrame) – The time series of a simulation.

  • show_reported_cases (bool, optional) – A boolean to select between reported or real cases of infections. Reported cases are identified via testing mechanisms.

  • unit (str) –

    The arguments specifies the unit shown in the figure.

    • "share" means that daily units represent the share of infection caused by a contact model among all infections on the same day.

    • "population_share" means that daily units represent the share of infection caused by a contact model among all people on the same day.

    • "incidence" means that the daily units represent incidence levels per 100,000 individuals.

Returns

time_series – The time series with the prepared data for the plot.

Return type

pandas.DataFrame

_adjust_channel_infected_by_contact_to_new_known_cases(df)[source]

Adjust channel of infections by contacts to new known cases.

Channel of infections are recorded on the date an individual got infected which is not the same date an individual is tested positive with a PCR test.

This function adjusts "channel_infected_by_contact" such that the infection channel is shifted to the date when an individual is tested positive.

_find_channel_of_infection_for_individuals(df)[source]

Find the channel of infected by contact for each individual.

_patch_channel_infected_by_contact(df, s)[source]

Patch channel of infections by contact to only show channels for known cases.