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 package serves as a unified network payload under declared schema versions, which records where the data came from, and how it maps back to the original source file. Furthermore, the package contains structured diagnostics, validation, and replayable operating points, enabling many downstream tasks.

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 compiler package envelope
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()            # 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
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 packages 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
PowerIO JSON yes yes structured model snapshot, not byte exact source echo lossless for Network fields except retained source text

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:

  • B' and B'' DCPF and FDPF matrices
  • Nodal admittance matrix
  • LACPF block matrix
  • Signed incidence, weighted Laplacian, and flow map matrices
  • PTDF and LODF sensitivity matrices
  • 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 package 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.

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 the .pio.json 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.

Compiler Packages

.pio.json packages wrap one balanced or multiconductor payload with provenance, source maps, diagnostics, validation, summaries, lowering history, optional derived metadata, and optional operating_points. A GO Challenge 3 package stores the static first interval in model and the full replayable time series in operating_points; materializing one point returns a static package 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 packages 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
cargo clippy --all-targets
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.0.tar.gz (694.3 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.0-cp39-abi3-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

powerio-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

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

powerio-0.6.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

powerio-0.6.0-cp39-abi3-macosx_11_0_arm64.whl (3.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

powerio-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: powerio-0.6.0.tar.gz
  • Upload date:
  • Size: 694.3 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.0.tar.gz
Algorithm Hash digest
SHA256 b94838ebe5b8c27029a5ef336ed356f4db177cc2e4a18aef58eea170b86a368f
MD5 4a3ce3d3342ed32f053370e8e20b95fd
BLAKE2b-256 be0a53919146a98d5cf69eed782c6be2eb08e96cb18e7bb76eca634c4fa0b4cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0.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.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: powerio-0.6.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.4 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.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 596ec930a6c54a753a52d3150b5c25b6cbd622aa4ff2897a861499231244fbc6
MD5 26495c675c90e83050f3bc4618521934
BLAKE2b-256 f6297576a871a8ac393c5daf9bba892ff24800c5aae570fa31a1c0aafe14785c

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0-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.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for powerio-0.6.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 638fc2db66dac5a835fade7270fe697d919a23778aec846666275786f1b89660
MD5 2f57a6710906aa5ad8fa0a9397f4d8b0
BLAKE2b-256 e04b48f5826a97768635adfc546b6c49d734ad992c67582a03ba856516417bff

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0-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.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for powerio-0.6.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c417cfb70ccead4140004f29ebfd99d71d4b28571593a14ca562f94e73779707
MD5 7f95dbefffcef95f0d27eceadd336253
BLAKE2b-256 5b9e75a3a1857949dc9ca69f4d1e75b2f20d9e5ddb9e91c461cad7f007d819fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0-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.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for powerio-0.6.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e0f6b307691302a7c037560b0cde2df98743ca0aeac86c2fcf6299e5db558df
MD5 2e169f74c2d055c2a0ba2cf6fab26f0a
BLAKE2b-256 4751f842ae3b2896523dbb51a4f85e611635b6b4939284fcb49a20b04e0bed38

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0-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.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for powerio-0.6.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42a369bea28328e14e7d3d6bdb9ae1b045ac61a6bc3316dcd50d7871f58e393b
MD5 0971cfe23ad43a118fc9204565746c35
BLAKE2b-256 609b784fa35144898036ccb1622eab25895cfce50256b175b543d3b7deb0ca6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for powerio-0.6.0-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