Skip to main content

Tools for visualizing and analyzing electrical grid network topology

Project description

Network Visualization

PyPI Python License

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 directory
  • output_file (str, optional): Output HTML filename. Default: "network_visualization.html"
  • auto_open (bool, optional): Auto-open in browser. Default: True
  • title (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 directory
  • save_report (bool, optional): Save text report to file. Default: False
  • output_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 directory
  • max_distance_km (float, optional): Maximum connection distance. Default: 100
  • top_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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit changes (git commit -m 'Add improvement')
  4. Push to branch (git push origin feature/improvement)
  5. Open a Pull Request

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ”— Links

๐Ÿ™ 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

network_visualization-1.0.1.tar.gz (24.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

network_visualization-1.0.1-py3-none-any.whl (18.7 kB view details)

Uploaded Python 3

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

Hashes for network_visualization-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f0ece1fd936f7e30212dfc2a6b9970432bc2d62fe8e94f24e2b850b9af142bc6
MD5 00fb465d15573781f29e3dc43a13858f
BLAKE2b-256 9f6db50a8cf5e7e55f22a49d9cb1a75be7a16d8dfcfef5d6fbe8ecc2c9cfacdd

See more details on using hashes here.

File details

Details for the file network_visualization-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for network_visualization-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ea475b1f1aa6f774844cab83e7266015bd55ec6602eed4c1819812a0cce81a6
MD5 7f8a2f3cf2fe7824d6c6a02205cedd0e
BLAKE2b-256 0997c96702806ed2f9a60ddd7d163befd32fdf264e42ed284435a82d08ebfef9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page