Skip to main content

Fast case parsing and conversion: "pandoc for power systems"

Project description

PowerIO

PowerIO format and matrix flow

PowerIO parses power system case files into a typed Network, converts between formats, and builds sparse matrices and graph representations for solver and analysis code. Same format writes return retained source text when the reader supports it; cross format writes report fields the target cannot carry in warnings.

The core is implemented in Rust. The C ABI exposes the same parser and converter to C, C++, Julia, and other foreign function interfaces. The Python package and command line interface sit on top of the same Rust code.

Overview

When writing back to the source format, PowerIO returns the original file exactly when the parser retained it. Cross format conversion obeys sane defaults and explicitly emits Conversion::warnings for fields the target format cannot represent.

Formats

The following formats are currently supported:

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

Support for the following formats is under development (see the open pull requests):

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-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.

API docs: https://eigenergy.github.io/powerio/. 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 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

reader / writer MATPOWER PowerModels JSON PSS/E PowerWorld egret JSON pandapower JSON
MATPOWER original text full partial partial partial partial
PowerModels JSON partial original text partial partial partial partial
PSS/E full full original text partial partial partial
PowerWorld full full partial original text partial partial
PowerWorld .pwb full full partial partial partial partial
PSLF .epc partial partial partial partial partial partial
egret JSON partial full partial partial original text partial
pandapower JSON partial partial partial partial partial original text

partial means the target lacks fields present in the source. The writer reports those cases in Conversion::warnings. PowerWorld .pwb is read only (no writer, no retained source): the row shows where its decoded power flow core lands. PSLF .epc reads and writes the power flow core; same format writes echo retained source text, and unsupported EPC sections are reported as read warnings. 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 live in docs/powerworld.md.

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

PyPSA CSV folders and GridFM Parquet are not in this table only because they are directory datasets, not single text outputs. Both read and write: PyPSA with regenerable committed fixtures (tests/data/pypsa/README.md), GridFM with a deliberately lossy read that recovers the power flow core. 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 low-level 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, 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 interface for PowerIO currently includes an optional MCP server exposing semantic tools for conversion, saving, summaries, parsing, normalization, matrix outputs, and display data.

pip install 'powerio[mcp]'
powerio-mcp

The PowerIO MCP server is currently being integrated as the low-level data exchange substrate for the MCP server bundle in PowerMCP. The PowerMCP bundle ships the same tool surface as PowerIO alongside a wide array of simulator servers, whose bridges ingest the transport directly.

GridFM (experimental)

PowerIO ships first-class support 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 functionality is currently lossy. What it recovers, what it drops, and the warnings contract are in the format fidelity guide. Improving gridfm read/write functionality is a key priority for the initial development of PowerIO.

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 when the optional oracle is installed.

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 benchmarks/RESULTS.md.

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.3.3.tar.gz (533.9 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.3.3-cp39-abi3-win_amd64.whl (3.4 MB view details)

Uploaded CPython 3.9+Windows x86-64

powerio-0.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

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

powerio-0.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

powerio-0.3.3-cp39-abi3-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

powerio-0.3.3-cp39-abi3-macosx_10_12_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for powerio-0.3.3.tar.gz
Algorithm Hash digest
SHA256 5db0da7db2fc588c49b94b66a4070e64e478f2d1b7c242ee3eedc6fb40785038
MD5 1f075594a942887170880774583cbd19
BLAKE2b-256 f81fe9a4c601309d0f5853919adaa98eae8129e83126c067f10a244152339739

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: powerio-0.3.3-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.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.3.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 a992f1f83f2516a1861f247f6713199d7f413fa4b1b48b27d2bfbc87aaf85ddc
MD5 d5639db735bd6f88ac80b8b6adfabd69
BLAKE2b-256 caff41aea6b9e287e31ccc79e465c0df6b918ab8963835d1ef73a73841775c79

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.3.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6f2bea296032d206656781cb6a6f0ae21563fdae831b1bac0ccf5674bb560a7
MD5 3ebb85ac24a58e6d21c84a8423d1b7d3
BLAKE2b-256 a2a503166483f3ac02d35066d87a8bd67aa3d4321627f66ace64308c4296acc2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.3.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 747e783c7818564605cc8199191eeca5a258efef4a6d66c8d6b0908616c16f62
MD5 bfda5e6e86b95b1ef6727f77761007a0
BLAKE2b-256 03313935a31330fbd585a787b1872c824fc89da0ffe5905c4be8ce27bdceccc3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.3.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af71865944ab89a67cc70d68947ecf7fb877f7fcff3ac8a7e5fd79bf11d64ef5
MD5 0e1659474a890ab7ee79f284836ac2fc
BLAKE2b-256 f5829c4680a4e8dbd64956d27d2571d94d91bd939616523b62698a731d5c9d6b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.3.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1b853d640481212c525da559b065a2a80ecdb20143ba8aa0ea26019a5306e0a5
MD5 a45372679f907ca1a9e7b6e15daceceb
BLAKE2b-256 027e6fa389415c4fe43a4fd88fb8f917082db3c36a4033f84f1fc2619e494631

See more details on using hashes here.

Provenance

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