channel_report
ChannelReport
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 convert a dataframe to a channel report.
Source code in emodpy_hiv/plotting/channel_report.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
add_channel(report, channel_name, values)
Add the values of the channel to the report
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
report
|
dict
|
a channel report formatted JSON dictionary |
required |
channel_name
|
str
|
the name of the channel to add |
required |
values
|
list
|
a list of integers or floats for that channel |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The updated dictionary with the channel added. |
Source code in emodpy_hiv/plotting/channel_report.py
convert_df_to_channel_report(df)
Convert the dataframe to a dictionary of the channel report format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
a dataframe where the columns are the channels and there is a row for each time step |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary that contains the data from the dataframe and can be converted to a JSON channel report |
Source code in emodpy_hiv/plotting/channel_report.py
convert_to_df(channel_report_dict, channels_to_extract=None)
staticmethod
Convert the input dictionary into a dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel_report_dict
|
dict
|
The name of the file (including path) to contain the data/JSON. |
required |
channels_to_extract
|
list
|
A list of strings that are the channel names to extract from the JSON and put into the dataframe |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
A dataframe where the columns are the channels of the report. An extra 'Time' column is added to the dataframe |
Source code in emodpy_hiv/plotting/channel_report.py
create_empty_channel_report()
Create the dictionary that has the right format for a channel report.
Returns:
| Type | Description |
|---|---|
dict
|
A dictionary that has the header and an empty 'Channels' entry |
Source code in emodpy_hiv/plotting/channel_report.py
save(filename)
Save this report data to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file (including path) to contain the data/JSON. |
required |