Plotting Module

This page has been pre-filled with the functions that are available in the Plotting module by AI, please check the code for more details.

This module provides functions for visualizing grid components and results.

functions are found in pyflow_acdc.Graph_and_plot

Time Series

Time series results

This function is used to plot the time series results of the grid.

plot_TS_res(grid, start, end, plotting_choices=[], show=True, path=None, save_format=None)

Creates plots for time series results. The possible plotting choices are:

  • ‘Power Generation by price zone’

  • ‘Power Generation by generator’

  • ‘Curtailment’

  • ‘Market Prices’

  • ‘AC line loading’

  • ‘DC line loading’

  • ‘AC/DC Converters’

  • ‘Power Generation by generator area chart’

  • ‘Power Generation by price zone area chart’

Parameter

Type

Description

Default

grid

Grid

Grid with results

Required

start

int

Start timeframe

Required

end

int

End timeframe

Required

plotting_choices

list

Results types to plot

All

show

bool

Whether to show the plot in browser

True

path

str

Path to save the plot

Current working directory

save_format

str

Format to save the plot, if None, the plot are not saved

None

Example

import pyflow_acdc as pyf
import pandas as pd

[grid,results] = pyf.NS_MTDC()

start = 5750
end = 6000
obj = {'Energy_cost': 1}

market_prices_url = "https://raw.githubusercontent.com/BernardoCV/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_marketPrices_data_sd2024.csv"
TS_MK = pd.read_csv(market_prices_url)
pyf.add_TimeSeries(grid,TS_MK)

wind_load_url = "https://raw.githubusercontent.com/BernardoCV/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_WL_data2024.csv"
TS_wl = pd.read_csv(wind_load_url)
pyf.add_TimeSeries(grid,TS_wl)

times=pyf.TS_ACDC_OPF(grid,start,end,ObjRule=obj)

pyf.plot_TS_res(grid,start,end,save_format='svg')

Plot shown in browser:

Time Series Plot: Power Generation by price zone

Plot saved in current working directory:

Time Series Plot: Power Generation by price zone

Time series probability

This function is used to plot the probability of the time series parameters or results of the grid. Results currently available are:

  • ‘Power Generation by generator’

  • ‘Prices by price zone’

  • ‘AC line loading’

  • ‘DC line loading’

  • ‘AC/DC Converters loading’

Time_series_prob(grid, element_name, save_format=None, path=None)

Parameter

Type

Description

Default

grid

Grid Class

Grid to analyze

Required

element_name

str

Name of element to analyze

Required

save_format

str

Format to save the plot, if None, the plot are not saved

None

path

str

Path to save the plot

Current working directory

Example

import pyflow_acdc as pyf
import pandas as pd

[grid,results] = pyf.NS_MTDC()

start = 5750
end = 6000
obj = {'Energy_cost': 1}

market_prices_url = "https://raw.githubusercontent.com/BernardoCV/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_marketPrices_data_sd2024.csv"
TS_MK = pd.read_csv(market_prices_url)
pyf.add_TimeSeries(grid,TS_MK)

wind_load_url = "https://raw.githubusercontent.com/BernardoCV/pyflow_acdc/main/examples/NS_MTDC_TS/NS_TS_WL_data2024.csv"
TS_wl = pd.read_csv(wind_load_url)
pyf.add_TimeSeries(grid,TS_wl)

pyf.Time_series_prob(grid,'OWPP_BE',save_format='svg')
pyf.Time_series_prob(grid,'BE_price',save_format='svg')
pyf.Time_series_prob(grid,'L_BE',save_format='svg')
../_images/OWPP_BE_distribution.svg
../_images/BE_price_distribution.svg
../_images/L_BE_distribution.svg

Network Graph Visualization

Full grid visualization as a network graph

plot_Graph(Grid,text='inPu',base_node_size=10,G=None):

Creates an interactive network graph visualization using Plotly.

Parameter

Type

Description

Default

Grid

Grid

Grid to visualize

Required

text

str

Hover text format (‘data’ or ‘inPu’ or ‘abs’)

‘inPu’

base_node_size

int

Base size for nodes

10

G

Graph

Graph to visualize

Full grid

Example

import pyflow_acdc as pyf

grid,res = pyf.case24_3zones_acdc()

pyf.plot_Graph(grid)
case24_3zones_acdc_graph

Neighbor Graph

This function is used to plot the neighbor graph of a node. You can either provide a node or a node name, one or the other must be provided.

plot_neighbour_graph(grid, node=None, node_name=None, base_node_size=10, proximity=1)

Creates a graph visualization of a node’s neighbors.

Parameter

Type

Description

Default

grid

Grid

Grid to analyze

Required

node

Node

Node object

None

node_name

str

Node name

None

base_node_size

int

Base size for nodes

10

proximity

int

Proximity

1

Example

import pyflow_acdc as pyf

grid,res = pyf.case24_3zones_acdc()

pyf.plot_neighbour_graph(grid,node_name='111.0')
case24_3zones_acdc neighbour graph of node 111.0

Saving the Network Graph

For this function, you need to have the svgwrite library installed. You can install it using pip install svgwrite. geometry of objects is required.

save_network_svg(grid, name='grid_network', width=1000, height=800)

Saves the network graph as an SVG file.

Parameter

Type

Description

Default

grid

Grid

Grid to save

Required

name

str

Name of the file

‘grid_network’

width

int

Width of the file

1000

height

int

Height of the file

800

Example

import pyflow_acdc as pyf

grid,res = pyf.NS_MTDC()

grid.save_network_svg(grid)
grid_network