emodpy_hiv.plotting.channel_report module#

class emodpy_hiv.plotting.channel_report.ChannelReport(df: DataFrame | None = None)[source]#

Bases: object

A class that can be used to convert an EMOD channel report/dictionary (i.e. InsetChart, DemographicsSummary, PropertyReport, etc) into a dataframe. A static method is provided to go the other way.

create_empty_channel_report()[source]#

Create the dictionary that has the right format for a channel report. It would be really nice if we could include Start_Time & Simulation_Timestep from the input files, but these are hardcoded for now.

Args: :returns: A dictionary that has the header and an emtpy ‘Channels’ entry

add_channel(report, channel_name, values)[source]#

Add the values of the channel to the report

Parameters:
  • report – a channel report formatted JSON dictionary

  • channel_name – the name of the channel to Add

  • values – a list of integers or floats for that channel

Returns:

The ‘report’ object is modified

convert_df_to_channel_report(df)[source]#

Convert the dataframe to a dictionary of the channel report format.

Parameters:

df – a dataframe where the columns are the channels and there is a row for each time step

Returns:

A dictionary that contains the data from the dataframe and can be converted to a JSON channel report

save(filename)[source]#

Save this report data to a file. :param filename: The name of the file (including path) to contain the data/JSON.

Returns:

A file should be saved

static convert_to_df(channel_report_dict, channels_to_extract=None)[source]#

Convert the input dictionary into a dataframe

Parameters:
  • channel_report_dict – The name of the file (including path) to contain the data/JSON.

  • channels_to_extract – A list of strings that are the channel names to extract from the JSON and put into the dataframe

Returns:

A dataframe where the columns are the channels of the report. An extra ‘Time’ column is added to the dataframe