Skip to main content

Case parsing, conversion, matrices, and language bindings for power system data

Project description

PowerIO

PowerIO format and matrix flow

PowerIO is compiler infrastructure for power systems. Case files from a dozen transmission and distribution formats parse into typed intermediate representations (IR). Once parsed, you can perform explicit, recorded operations, like normalization, validation, and lowering. You can compile/write the case back into any supported target format, sparse matrix families, and ML model formats.

The .pio.json document carries one model JSON object under declared schema versions, with metadata that records where the data came from and how it maps back to the original source file. It also contains structured diagnostics, validation, and replayable operating points.

Data fidelity and interoperability is the primary goal of the PowerIO project. Writing a parsed file back to its own format returns the original text when the reader kept it. Converting to another format writes the modeled electrical data and reports every field the target cannot carry in Conversion::warnings.

The core of PowerIO is written in Rust. The Rust version is used to create the Python package and the command line interface, both of which sit in this repo. The Rust implementation also enables the creation of a C ABI, which exposes PowerIO capabilities to C, C++, Julia, and other foreign function interfaces (FFIs).

Overview

PowerIO is a community infrastructure project intended to serve all developers working on electric power systems. Everyone is welcome to use, build upon, and contribute to the PowerIO infrastructure project.

Formats

Supported formats:

Distribution networks are supported in wire coordinates via powerio-dist:

Other formats are planned; see the GitHub issues. If a format you need is missing, open an issue or a pull request. All are welcome to contribute to this community project.

Packages

This repository contains multiple packages.

powerio          # parser, Network model, source retaining writers, converters
powerio-matrix   # sparse matrices, DC sensitivity factors, graph representations
powerio-dist     # multiconductor distribution model, dss/PMD/BMOPF converters
powerio-pkg      # .pio.json document metadata and model JSON
powerio-cli      # the `powerio` command and ratatui TUI
powerio-py       # PyO3 extension for the Python `powerio` package
powerio-capi     # C ABI for C, C++, Julia, and other foreign function interfaces
PowerIO.jl       # Julia bindings over the C ABI

The core powerio Rust crate keeps parsing and conversion separate from matrix, TUI, and data frame dependencies. The Python package imports with no required third party packages; matrix and graph helpers live behind extras.

Docs site: https://powerio.dev. Language API map: languages guide.

Install

cargo add powerio
cargo add powerio-matrix
cargo install powerio-cli

pip install powerio
pip install 'powerio[all]'     # scipy, numpy, networkx, polars extras
pip install 'powerio[gridfm]'  # polars for Parquet inspection
pip install 'powerio[pandas]'  # pandas, pyarrow compatibility reads (Python 3.10+)

julia -e 'using Pkg; Pkg.add(url="https://github.com/eigenergy/PowerIO.jl")'

Use

Rust

use powerio::{TargetFormat, parse_file};

let parsed = parse_file("case14.m", None)?;
let net = parsed.network;
let conv = net.to_format(TargetFormat::PowerModelsJson)?;

for warning in &conv.warnings {
    eprintln!("conversion warning: {warning}");
}

std::fs::write("case14.json", conv.text)?;

Python

import powerio as pio

case = pio.parse_file("case9.m")
bprime = case.bprime()            # MATPOWER Bp, scipy.sparse, needs powerio[matrix]
display = pio.parse_display_file("case.pwd")
raw, warnings = pio.convert_file("case9.m", "psse")

Julia

using PowerIO

case = parse_file("case9.m")
text = to_matpower(case)
json, warnings = to_format(case, "powermodels-json")

Command line interface (CLI)

powerio convert tests/data/case14.m --to psse35 -o case14.raw
powerio convert tests/data/case14.m --to pandapower-json -o case14.pp.json
powerio convert tests/data/case14.m --to pypsa-csv -o pypsa_case
powerio convert pypsa_case --from pypsa-csv --to matpower -o case14.m
powerio convert case.epc --from pslf --to matpower -o case.m
powerio convert case.surge.json --from surge-json --to matpower -o case.m
powerio convert goc3_case.json --from goc3-json --to matpower -o case.m
powerio package tests/data/case14.m -o case14.pio.json
powerio package goc3_case.json --from goc3-json -o goc3_case.pio.json
powerio verify tests/data/case30.m --kind bdoubleprime
powerio dcopf tests/data/case30.m -o out
powerio sensitivities tests/data/case30.m -o out --solver auto --drop-tolerance 1e-10
powerio gridfm tests/data/case14.m -o out
powerio

Features

Current Format Fidelity

Every network reader lowers to Network. The table separates writing back to the original file type from converting to a different file type.

file type read write writing back to the original file type converting to another file type
MATPOWER .m yes yes byte exact retained source canonical MATPOWER blocks; warnings for fields MATPOWER cannot carry
PowerModels JSON yes yes byte exact retained source per unit structured data checked against PowerModels.jl
PSS/E .raw yes yes byte exact only when writing the source revision power flow core; revision downgrade and unsupported records are warned
PowerWorld .aux yes yes byte exact retained source power flow core; PowerWorld only fields are projected or warned
PowerWorld .pwb yes no n/a read only binary case; decoded core converts through every text writer
PSLF .epc yes yes byte exact retained source power flow core; unsupported EPC sections are read warnings
egret JSON yes yes byte exact retained source ModelData shape checked against egret and PowerModels.jl
pandapower JSON yes yes byte exact retained source pandapower import validator checks counts and Y_bus
PyPSA CSV folder yes yes directory output, not text echo PyPSA import validator checks the exported static components
GO Challenge 3 JSON yes source echo only byte exact retained source first interval maps to the static power flow core; .pio.json documents retain time series as operating points
Surge JSON yes yes byte exact retained source versioned JSON network body; unsupported source sections stay in retained source or warnings
GridFM Parquet yes yes directory output, deliberately lossy read recovers the power flow core for conversion back to classical formats

PowerWorld .pwd is display data, not a network case, so it is outside this conversion table and uses parse_display_file / parse_display_bytes. The decoded vintages and per field evidence are maintainer notes at powerio/src/format/powerworld/FORMAT.md.

The distribution matrix (dss, PMD JSON, BMOPF JSON, per fixture) is generated under powerio-dist/docs/. Vendored test data keeps its own licenses next to the fixtures under tests/data/dist/.

Known limits for every format are documented in the format fidelity guide.

Matrices

The powerio-matrix Rust crate derives an IndexedNetwork with dense bus indices. It enables you to build common power system matrices with minimal dependencies:

  • MATPOWER Bp/Bpp FDPF matrices
  • DC bus susceptance matrix L = A diag(b) A^T and flow map matrices
  • Nodal admittance matrix
  • LACPF block matrix
  • Signed incidence matrix
  • PTDF and LODF sensitivity matrices, with dense and iterative solver paths
  • Streamed CLI PTDF/LODF writes for iterative sensitivity exports
  • Adjacency matrix and petgraph graph output
  • Matrix Market bundles for OPF solvers
  • KKT operators for OPF solvers (experimental)

Current conventions for signs, taps, phase shifts, per unit scaling, reference buses, and line parameters are documented in the matrices guide.

Normalized Form

Network::to_normalized derives a post processed copy of a case for solvers:

  • powers are in per unit,
  • voltage phase angles are in radians,
  • inactive elements are removed,
  • tap == 0 replaced with 1,
  • surviving buses keep their source bus ids, and
  • bus types are made consistent with generator placement and reference buses.

The normalized copy carries no retained source text, so writing it emits the derived model rather than the original file.

Python exposes the normalized form as case.to_normalized(), the C ABI as pio_normalize, and Julia as to_normalized(case).

C ABI

powerio-capi exposes parse, query, conversion, JSON transport, normalization, .pio.json document handles, and numeric table extraction through pio_* functions. The public header is powerio-capi/include/powerio.h. Build with --features arrow to enable pio_to_arrow over the Arrow C Data Interface, and add --features matrix for sparse matrix COO tables. Matrix Arrow ABI v1 is COO plus explicit matrix_bus and matrix_branch axis map tables; language bindings assemble native sparse matrix types on their side.

PowerAgent

PowerIO is part of the PowerAgent community. The Python package includes an optional MCP server with tools for conversion, saving, summaries, parsing, normalization, matrix outputs, and display data.

pip install 'powerio[mcp]'
powerio-mcp

MCP clients can keep a case in .pio.json document JSON through the package transport:

parsed = parse(path="case9.m", transport="package")
pkg = parsed["package_json"]
summary(package_json=pkg)
matrix("bprime", package_json=pkg)
save(out_path="case9.raw", to_format="psse", package_json=pkg)
diagnostics(pkg)

The PowerMCP bundle in PowerMCP uses the same PowerIO tool surface alongside simulator servers and bridge tools.

.pio.json Documents

.pio.json documents carry one balanced or multiconductor model JSON object with metadata: provenance, source maps, diagnostics, validation, summaries, lowering history, optional derived metadata, and optional operating_points. A GO Challenge 3 document stores the static first interval in model and the full replayable time series in operating_points; materializing one point returns a static document with the updates applied and the series cleared.

Rust uses powerio_pkg::NetworkPackage, Python uses the powerio.Package class, the C ABI uses pio_package_*, and the CLI writes documents with powerio package.

GridFM (experimental)

PowerIO writes datasets for the LF Energy open Grid Foundation Model (GridFM) project. In the command line:

powerio gridfm <case> -o <dir>

This writes the Parquet tables gridfm-datakit and gridfm-graphkit consume under <dir>/<case>/raw/; several compatible cases stack by scenario id.

The gridfm feature also supports reading a .parquet dataset back into a Network (read_gridfm_dataset in powerio-matrix, pio.read_gridfm in Python), so a perturbed training scenario or a GNN predicted state can be extracted and converted back out in any classical format:

powerio convert out/case14/raw --from gridfm --to matpower -o case14.m

The --from gridfm read path is lossy. What it recovers, what it drops, and its warning behavior are in the format fidelity guide.

Validation

The Rust test suite covers parsers, writers, format conversion, matrix builders, and normalization; the C ABI crate carries its own tests, and pytest covers the Python bindings. The benchmark validation suite compares selected outputs against PowerModels.jl, egret, ExaPowerIO.jl, and pandapower, and imports PowerIO's PyPSA CSV folders with PyPSA. Install the oracle stack from benchmarks/requirements.txt into the same Python 3.11+ venv that holds the local powerio wheel.

cargo fmt --all --check
cargo test
cargo test -p powerio-capi
bash scripts/ci-clippy.sh
pytest python/tests
bash benchmarks/run_validation.sh

Benchmark method, environment, and current tables are documented in the performance guide.

License

PowerIO is distributed under either of:

PowerIO logo

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

powerio-0.6.3.tar.gz (746.4 kB view details)

Uploaded Source

Built Distributions

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

powerio-0.6.3-cp39-abi3-win_amd64.whl (4.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

powerio-0.6.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

powerio-0.6.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

powerio-0.6.3-cp39-abi3-macosx_11_0_arm64.whl (3.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

powerio-0.6.3-cp39-abi3-macosx_10_12_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file powerio-0.6.3.tar.gz.

File metadata

  • Download URL: powerio-0.6.3.tar.gz
  • Upload date:
  • Size: 746.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for powerio-0.6.3.tar.gz
Algorithm Hash digest
SHA256 b5b6d5d1de56fb128dfe55d3d225e6f5fdee89a958aa94869591e943215fa320
MD5 70835f3b282e93b5345f41008902895a
BLAKE2b-256 1d0ca6660404cf844b790b58030082acb274be4f3b3483e01d53378f0ffd84f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3.tar.gz:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file powerio-0.6.3-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: powerio-0.6.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.7 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for powerio-0.6.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9489c1d9eb579167caf0105aa65eb001229cb8a6e6bba7361bb31ee835e88c9b
MD5 987b9b1cfc19bcc3357374ce4799b303
BLAKE2b-256 fc1ab938739d1094975c157ae747f2e2b677ba3a700fb122f437de32ee70c93f

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3-cp39-abi3-win_amd64.whl:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file powerio-0.6.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for powerio-0.6.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af3acc2bb874f1e2598858258bda5f73543715f2e8a5eb2e3aff0141ad22e12f
MD5 a24130d98fb1e504765834c966531c24
BLAKE2b-256 f954eff454ba0eba843fa7afda3f2af10e45bacebc627c352475f006db64c143

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file powerio-0.6.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for powerio-0.6.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 489174c61a03798f9b1d0a46b5280c57676ef80d3aafcd4b9fe54a563a333e5a
MD5 ba638aa1408e6f4d7a87ce284235dcd0
BLAKE2b-256 999244e2822afb4c500334cf9adc2e57c443416eb6a9bc8ac3f8951436cdea25

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file powerio-0.6.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for powerio-0.6.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1acff3274bfe1bd7188ca89a212d2a0366beb36f287042aa66c0a78f57a0c02
MD5 0b9bb7f79ea2b6bd5c50050d56bb3e1d
BLAKE2b-256 775509a6b3164599b632688370d515192aa3df72603d6473199b8e51a282e493

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file powerio-0.6.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for powerio-0.6.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0666a2f08e378f48bbb563981cdf617e5e07cf0c7bacb8f2b51b58bd96fd2f3d
MD5 6e89185e7a64df925cf188fd916ebbae
BLAKE2b-256 380b91fb8b093295c41924dcdc9f62b2d68322a90828727894a0270766af5b74

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.3-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: python.yml on eigenergy/powerio

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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