Tools for visualizing and analyzing electrical grid network topology
Project description
Network Visualization
Interactive visualization and analysis tools for Calliope energy system models. Extract and visualize network topology with a single line of code.
โจ Features
- Universal Data Extraction: Handles ANY Calliope naming structure and format
- One-Line Visualization: Create interactive HTML visualizations instantly
- Connectivity Analysis: Identify isolated nodes and network components
- Flexible Format Support: Works with any coordinate system (lat/lon, x/y, custom)
- Smart Type Detection: Automatically classifies generation, demand, and transmission nodes
๐ Quick Start
Installation
# From PyPI
pip install network-visualization
# From source
pip install -e .
Basic Usage
import network_visualization as nv
# Visualize your network
nv.plot_network("path/to/calliope/model")
# Analyze connectivity
analysis = nv.analyze_network("path/to/calliope/model")
print(f"Components: {analysis['num_components']}")
print(f"Isolated nodes: {len(analysis['isolated_nodes'])}")
# Find isolated nodes with demand
isolated = nv.find_isolated_nodes("path/to/model")
print(f"Isolated with demand: {isolated['isolated_with_demand']}")
# Get connection suggestions
suggestions = nv.suggest_connections("path/to/model", max_distance_km=50)
# Quick visualization (fastest)
nv.quick_viz("path/to/model")
๐ API Reference
plot_network(model_path, output_file, auto_open, title)
Create an interactive network visualization.
Parameters:
model_path(str): Path to Calliope model directoryoutput_file(str, optional): Output HTML filename. Default:"network_visualization.html"auto_open(bool, optional): Auto-open in browser. Default:Truetitle(str, optional): Visualization title. Default:"Energy Network Visualization"
Returns: Path to generated HTML file
Example:
nv.plot_network(
model_path="models/my_model",
output_file="my_network.html",
auto_open=False,
title="My Energy Network"
)
analyze_network(model_path, save_report, output_dir)
Analyze network connectivity and identify issues.
Parameters:
model_path(str): Path to Calliope model directorysave_report(bool, optional): Save text report to file. Default:Falseoutput_dir(str, optional): Report output directory. Default:"outputs/reports"
Returns: Dictionary with analysis results:
{
'num_components': int, # Number of connected components
'isolated_nodes': list, # List of isolated node names
'demand_isolated': set, # Demand substations that are isolated
'is_fully_connected': bool, # Whether network is fully connected
'total_nodes': int, # Total nodes in graph
'total_edges': int, # Total edges in graph
'components': list # List of component sets
}
find_isolated_nodes(model_path)
Find all isolated nodes in the network.
Returns: Dictionary with isolated node lists:
{
'all_isolated': list, # All isolated nodes
'isolated_with_demand': list # Isolated nodes with demand
}
suggest_connections(model_path, max_distance_km, top_n)
Get smart connection suggestions based on proximity.
Parameters:
model_path(str): Path to Calliope model directorymax_distance_km(float, optional): Maximum connection distance. Default:100top_n(int, optional): Number of suggestions to return. Default:10
Returns: List of suggested connections with distances
quick_viz(model_path)
Fastest way to visualize - one function call with all defaults.
๐ฏ Calliope Format Support
This package handles any Calliope model structure:
Standard Format
locations:
region1:
coordinates: {lat: 40, lon: -2}
techs: {ccgt:, demand_power:}
Split Coordinates
locations:
region1-1.coordinates: # or region1:coords, region1_position, etc.
lat: 41
lon: -2
Shared Technologies
locations:
"region1-1, region1-2, region1-3": # or region1-1|region1-2|region1-3
techs: {csp:}
Any Coordinate System
- Geographic:
lat/lon,latitude/longitude - Cartesian:
x/y - Custom: Any numeric coordinate pairs
Flexible Naming
No restrictions on naming patterns:
- Delimiters:
.,:,_,-,|,, - Suffixes:
coordinates,coords,position,latlon, etc. - Patterns: Any naming convention (regions, nodes, stations, areas, etc.)
The parser automatically detects and handles all patterns!
๐ Example Output
Visualization
Interactive HTML with:
- Color-coded nodes (generation, demand, transmission)
- Hover info showing technologies
- Zoom and pan navigation
- Network statistics overlay
Analysis Report
================================================================================
NETWORK ANALYSIS REPORT
================================================================================
1. NETWORK SUMMARY
Total Locations: 9
- Power Plants: 5
- Substations with Demand: 0
- Transmission Nodes: 1
Total Connections: 9
- Power Links: 2
- Transmission Links: 7
2. CONNECTIVITY ANALYSIS
Connected Components: 1
[OK] Network is fully connected
[OK] No isolated nodes
3. DEMAND SUBSTATIONS STATUS
[OK] All demand substations are connected
================================================================================
๐ Project Structure
network_visualization/
โโโ network_visualization.py # Main API module
โโโ setup.py # Package configuration
โโโ requirements.txt # Dependencies
โโโ README.md # This file
โ
โโโ utils/ # Core utilities
โ โโโ load_data.py # Universal data loader
โ โโโ graph_builder.py # Network graph construction
โ โโโ geo_utils.py # Geographic calculations
โ โโโ report_generator.py # Report generation
โ
โโโ scripts/ # Command-line tools
โ โโโ visualize_network.py
โ โโโ analyze_isolated.py
โ โโโ suggest_connections.py
โ
โโโ examples/ # Usage examples
โโโ basic_visualization.py
๐ ๏ธ Requirements
- Python 3.8+
- Dependencies:
networkx,plotly,pyyaml,pandas,numpy,geopy
๐ Development
# Clone repository
git clone <repository-url>
cd network_visualization
# Install in development mode
pip install -e .
# Run tests
python -m pytest tests/
๐ค Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit changes (
git commit -m 'Add improvement') - Push to branch (
git push origin feature/improvement) - Open a Pull Request
๐ License
MIT License - see LICENSE file for details.
๐ Links
- PyPI: https://pypi.org/project/network-visualization/
- GitLab: https://mygit.th-deg.de/thd-spatial-ai/example_models/calliope_plots
- Calliope: https://calliope.readthedocs.io/
๐ Acknowledgments
Built for Calliope energy system modeling framework. Supports any Calliope model structure with universal data extraction.
Version: 1.0.1 | Updated: November 2025
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file network_visualization-1.0.1.tar.gz.
File metadata
- Download URL: network_visualization-1.0.1.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0ece1fd936f7e30212dfc2a6b9970432bc2d62fe8e94f24e2b850b9af142bc6
|
|
| MD5 |
00fb465d15573781f29e3dc43a13858f
|
|
| BLAKE2b-256 |
9f6db50a8cf5e7e55f22a49d9cb1a75be7a16d8dfcfef5d6fbe8ecc2c9cfacdd
|
File details
Details for the file network_visualization-1.0.1-py3-none-any.whl.
File metadata
- Download URL: network_visualization-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ea475b1f1aa6f774844cab83e7266015bd55ec6602eed4c1819812a0cce81a6
|
|
| MD5 |
7f8a2f3cf2fe7824d6c6a02205cedd0e
|
|
| BLAKE2b-256 |
0997c96702806ed2f9a60ddd7d163befd32fdf264e42ed284435a82d08ebfef9
|