emodpy_hiv.plotting.plot_relationship_start module#
- emodpy_hiv.plotting.plot_relationship_start.extract_assortivity_risk(start_rel_filename: str, relationship_type: int, male_risk_value='LOW')[source]#
For the given relationship type, extract the number of relationships that started during each time step for each risk value pair. The male risk value is constant so it should return a dataframe with three columns.
- Parameters:
start_rel_filename (str, required) – The name and path of the RelationshipStart.csv file to be read.
relationship_type (int, required) – The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial).
male_risk_value (str, optional) – The risk value of the male in the relationship being plotted. This will be either LOW, MEDIUM, or HIGH. Capitalization matters. Default is LOW.
- Returns:
Dataframe with three columns where each column is for a risk value pairing. Each row should represent a simulation time (in days) that had relationhips created of that time and risk value pairing. There is no guarantee that relationships are created each time step.
- emodpy_hiv.plotting.plot_relationship_start.plot_relationship_assortivity_risk(dir_or_filename: str, relationship_type: int, male_risk_value: str = 'LOW', show_avg_per_run: bool = False, show_regression: bool = False, regression_dir: str | None = None, img_dir: str | None = None)[source]#
Create a plot showing the number of relationships of a given type that started during the timestep for a male with the give risk value versus females with the other possible values. For example, if the male’s risk value is HIGH, the plot will contain three curves: HIGH-LOW, HIGH-MEDIUM, and HIGH-HIGH. They will all be for the given relationship type. We only do three curves because the data can be quite noisy.
The plot also has the option to show a least squares regression line for each risk value pair. A CSV file can be saved with the regression data. This can be used to compare with the plot_a_vs_b() function to compare the regression from two different sets of files.
- Parameters:
dir_or_filename (str, required) – The directory or filename containing the RelationshipStart.csv files.
relationship_type (str, optional) – The type of relationship. Options: 0 (transitory), 1 (informal), 2 (marital), 3 (commercial).
male_risk_value (str, optional) – The risk value of the male in the relationship being plotted. This will be either LOW, MEDIUM, or HIGH. Capitalization matters. Default is LOW.
show_avg_per_run (bool, optional) – If ‘dir_or_filename’ is a directory, this will calculate the average number of relationships started at each timestep for the different files in the directory. Default is False.
show_regression (bool, optional) – If true, a least squares regression line will be calculated and shown on the plot. There will be one line for each risk value pair. Default is False.
regression_dir (str, optional) – If ‘show_regression’ is true and this provides a path to a directory, then a CSV file will be saved with the data points of the displayed regression lines. The name of the file will be the relationship type and the male’s risk value. For example, COMMERCIAL-HIGH.csv. Default is None.
img_dir (str, optional) – Directory to save the images. If None, the images will not be saved and a window will be opened.
- Returns:
None - but image will be saved or window opened.
- emodpy_hiv.plotting.plot_relationship_start.plot_relationship_assortivity_risk_all(dir_or_filename: str, regression_dir: str | None = None, img_dir: str | None = None)[source]#
Create a plot for each combination male risk value and relationship type.
- Parameters:
dir_or_filename (str, required) – The directory or filename containing the RelationshipStart.csv files or a specific file.
regression_dir (str, optional) – If provided, a CSV file will be created for each plot where the CSV file has one column for each risk value combination - three columns because the male’s value is fixed.
img_dir (str, optional) – Directory to save the images. If None, the images will not be saved and a window will be opened. Default is none - don’t save image and open a window.
- Returns:
None - but images will be saved or windows opened.