ricnogfer / pypsatopo

PyPSATopo is a tool that allows generating the topographical representation of any arbitrary PyPSA-based network
14 stars 3 forks source link
energy-system-model pypsa

Description

PyPSATopo is a tool that allows generating the topographical representation of any arbitrary PyPSA-based network (thanks to the DOT language). Besides easing the understanding of a network by providing its graphical representation, the tool helps debug it given that broken links and missing buses are shown in (slightly) different shapes and colors. Technically speaking, PyPSATopo can be thought of as a reverse engineering tool for PyPSA-based networks.

To get a quick overview of the capabilities of PyPSATopo, simply launch it in a terminal as follows:

python pypsatopo.py

This will create a PyPSA-based network made of the following components:

# create dummy (PyPSA-based) network
network = pypsa.Network(name = "My Dummy Network")

# add some dummy components to dummy network
network.add("Bus", "oil")
network.add("Bus", "electricity")
network.add("Bus", "transport")
network.add("Generator", "oil", bus = "oil")
network.add("Generator", "solar", bus = "electricity")
network.add("Load", "vehicle", bus = "transport")
network.add("Store", "battery", bus = "electricity")
network.add("StorageUnit", "hydro", bus = "electricity")
network.add("Link", "ICEV", bus0 = "oil", bus1 = "transport")
network.add("Link", "BEV", bus0 = "electricity", bus1 = "transport")

... as well as generate the corresponding topographical representation of the network in the SVG format:

Topographical representation of network 'My Dummy Network'

Installation

PyPSATopo can be installed on the machine using pip, a package management system for Python. To install the tool using pip, open a terminal and execute the following:

pip install pypsatopo

PyPSATopo leverages several components to accomplish its functionalities, namely: Python, PyPSA, Pandas and Dot (from Graphviz). Consequently, these should be installed before running PyPSATopo. While PyPSA and Pandas are automatically installed by PyPSATopo in case they are missing, Dot must be manually installed by the user (see download for additional details). Alternatively, in case of working with Conda (or Miniconda), Dot may be installed automatically by opening a terminal and executing the following:

conda install -c conda-forge python-graphviz

As a reference, PyPSATopo is known to work correctly with the following versions of the components:

In addition, PyPSATopo should work on any platform (i.e. operating system) as long as the components that this tool depends on are supported on the target platform. As a reference, the tool is known to work correctly in Windows, Linux and macOS.

Usage

PyPSATopo can be used in two different ways to generate the topographical representation of a PyPSA-based network, either through its application programming interface or a command-line interface.

To use PyPSATopo through its application programming interface, the following (generic) recipe should be followed:

# import PyPSATopo module
import pypsatopo

# create (PyPSA-based) network named 'my_network'
my_network = pypsa.Network()

# add components to network 'my_network'
# (...)

# generate topographical representation of network 'my_network' in the SVG format
pypsatopo.generate(my_network)

To use PyPSATopo through a command-line interface, execute the following in a terminal (where my_network.nc refers to the NetCDF file containing the PyPSA-based network):

python pypsatopo.py my_network.nc

In addition, to see all the valid parameters accepted by the tool, specify parameter --help when executing it in a terminal. In other words:

python pypsatopo.py --help

PyPSA Components

Currently, PyPSATopo supports some of the most important PyPSA components, namely: Bus, Generator, Load, Store, Storage unit, Link and Line. These are graphically represented by PyPSATopo as follows:

Functionalities

As stated previously, PyPSATopo is a tool that allows generating the topographical representation of any arbitrary PyPSA-based network. It basically allows to reverse engineer such type of network to ease its understanding. To that end, PyPSATopo provides several functionalities to cover as many use-cases as possible. These functionalities are described below, and their usage exemplified using both the application programming interface and the command-line interface.

Support

PyPSATopo is actively developed and maintained by the Energy Systems Group at Aarhus University (Denmark). Please open a ticket here in case a bug is found or a feature is missing in this tool.