Plot statistics
add_second_xaxis(data, ax, label, **kwargs)
Add a secondary X-axis to the plot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Series
|
The data to plot. Its values will be plotted on the secondary X-axis. |
required |
ax
|
Axes
|
The main matplotlib Axes object. |
required |
label
|
str
|
The label for the secondary X-axis. |
required |
**kwargs
|
Optional keyword arguments for plot styling. |
{}
|
Source code in workflow/scripts/plot_statistics.py
filter_small_caps(n, threshold=100)
Drop small capacities for plotting (eliminate numerical zeroes) -> this would be more robust based on the objective cost tolerance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Network
|
the pypsa network to remove small comps from |
required |
threshold
|
int
|
the removal threshold. Defaults to 100. |
100
|
Source code in workflow/scripts/plot_statistics.py
fix_load_carriers(n, config)
Set unspecified load carriers to load
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Network
|
The PyPSA network instance. |
required |
config
|
dict
|
the plotting config |
required |
Source code in workflow/scripts/plot_statistics.py
plot_capacity_factor(cf_filtered, theo_cf_filtered, ax, colors, **kwargs)
Plot actual and theoretical capacity factors for each technology.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cf_filtered
|
Series
|
Actual capacity factors indexed by technology. |
required |
theo_cf_filtered
|
Series
|
Theoretical capacity factors indexed by technology. |
required |
ax
|
Axes
|
The axis to plot on. |
required |
colors
|
dict
|
Color mapping for technologies. |
required |
Returns:
| Type | Description |
|---|---|
|
matplotlib.axes.Axes: The axis with the plot. |
Source code in workflow/scripts/plot_statistics.py
plot_province_peakload_capacity(df_plot, bar_cols, color_list, outp_dir)
Plot province peak load vs installed capacity by technology.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_plot
|
DataFrame with provinces as index, columns as technologies and 'Peak Load'. |
required | |
bar_cols
|
List of technology columns to plot as bars. |
required | |
color_list
|
List of colors for each technology. |
required | |
outp_dir
|
Output directory for saving the figure. |
required |
Source code in workflow/scripts/plot_statistics.py
plot_static_per_carrier(ds, ax, colors, drop_zero_vals=True, add_labels=True)
Generic function to plot different statics
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Series
|
the data to plot |
required |
ax
|
Axes
|
plotting axes |
required |
colors
|
Series
|
colors for the carriers |
required |
drop_zero_vals
|
bool
|
Drop zeroes from data. Defaults to True. |
True
|
add_labels
|
bool
|
Add value labels on bars. If None, reads from config. Defaults to None. |
True
|
Source code in workflow/scripts/plot_statistics.py
prepare_capacity_factor_data(n, carrier)
Prepare Series for actual and theoretical capacity factors per technology. Args: n (pypsa.Network): The PyPSA network instance. carrier (str): The carrier for which to prepare the data. Returns: cf_filtered: Series of actual capacity factors (index: nice_name) theo_cf_filtered: Series of theoretical capacity factors (index: nice_name)
Source code in workflow/scripts/plot_statistics.py
prepare_province_peakload_capacity_data(n, attached_carriers=None)
Prepare DataFrame for province peak load and installed capacity by technology.
Returns:
| Name | Type | Description |
|---|---|---|
df_plot |
DataFrame with provinces as index, columns as technologies and 'Peak Load'. |
|
bar_cols |
List of technology columns to plot as bars. |
|
color_list |
List of colors for each technology. |
Source code in workflow/scripts/plot_statistics.py
set_link_output_capacities(n, carriers)
Set link capacity to output and not input. PyPSA uses input link capacities but typically want to report output capacities (e.g MWel)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
Network
|
The PyPSA network instance. |
required |
carriers
|
list
|
List of carrier names to adjust. |
required |
Returns: pd.DataFrame: the original link capacities.