Comparison¶
API reference for the comparison and visualization steps:
scripts.make_comparison: builds tabular comparisons between reference statistics and network statistics, and produces a GeoJSON with line ratios.scripts.visualize_data: generates plots from the comparison tables.
Module: scripts.make_comparison¶
make_comparison
¶
This script compares the reference and network statistics by searching unique region and carrier combinations for capacities and unique countries for demand. It also compares transmission line properties (s_nom and length) by computing ratios and outputs a comparison GeoJSON.
compute_line_ratios_geojson(reference_path, model_path, output_path)
¶
Compute the ratio of s_nom and length between model and reference networks, and store the results in a new GeoJSON with only ratio values.
Module: scripts.visualize_data¶
visualize_data
¶
plot_demand_comparison(demand_df, output_path)
¶
Plot a side-by-side bar graph comparing electricity demand for each region (reference vs network).
plot_carrier_capacity_comparison(installed_capacity_df, optimal_capacity_df, output_path, carrier='coal', normalize=False)
¶
Plot a side-by-side bar graph comparing installed, optimal, and reference capacities for a given carrier (default: coal).
plot_stack_carrier_capacity_comparison(installed_capacity_df, optimal_capacity_df, output_path, stack_percent=False)
¶
Plot a single stacked bar graph comparing network, optimal, and reference capacity mix for each region. Each region will have 3 bars side by side: one for reference capacity, one for network capacity, and one for optimal capacity. The bars will be stacked with different carriers' capacities.
plot_capacity_grid_comparison(installed_capacity_df, optimal_capacity_df, output_path, normalize=False, share_y=False)
¶
Create a subplot grid where: - Rows = regions (unique) - Columns = carriers - Each subplot shows bar plots: [Reference, Network, Optimal] for that region-carrier combo
get_voltage_color(voltage, line_voltages, voltage_colors)
¶
Get the line colors corresponding to a voltage level based on defined thresholds.
plot_grid_network(input, output, line_voltages, voltage_colors, plot_circuits)
¶
Plot the grid network with lines colored by voltage levels and substations highlighted.
Parameters:¶
input: dict[str, str] A dictionary containing paths to input files, specifically: - "osm_lines": Path to the GeoJSON file containing line geometries and attributes. - "osm_substations": Path to the GeoJSON file containing substation geometries. output: str A dictionary containing paths to output files, specifically: - "plot_grid_network": Path where the generated grid network plot will be saved (e.g., as a PNG file). line_voltages: list[float] A list of voltage thresholds used to categorize lines into different voltage levels for coloring. voltage_colors: list[str] A list of colors corresponding to each voltage level in line_voltages. plot_circuits: bool Whether to display the number of circuits on the plot.
compute_line_lengths_by_voltage(input, output)
¶
Compute total line lengths by voltage level and save to CSV.
Parameters:¶
input: dict[str, str] A dictionary containing paths to input files, specifically: - "osm_lines": Path to the GeoJSON file containing line geometries and attributes. output: dict[str, str] A dictionary containing paths to output files, specifically: - "line_length_by_voltage": Path where the computed line lengths by voltage will be saved as a CSV file.