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()            # 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
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, 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.

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
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.1.tar.gz (728.6 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.1-cp39-abi3-win_amd64.whl (4.5 MB view details)

Uploaded CPython 3.9+Windows x86-64

powerio-0.6.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

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

powerio-0.6.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

powerio-0.6.1-cp39-abi3-macosx_11_0_arm64.whl (3.8 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

powerio-0.6.1-cp39-abi3-macosx_10_12_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: powerio-0.6.1.tar.gz
  • Upload date:
  • Size: 728.6 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.1.tar.gz
Algorithm Hash digest
SHA256 6039d7676846041efe4d6eba2d1d753f55a589435ae3c66ed98b6a69b185c820
MD5 48c0e3f52b29a7ce8498bda2e60d4525
BLAKE2b-256 6ca2ba6a261f101dbc485009e17e68389370c2cb42de5b68c8f26e3733ea8ac6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: powerio-0.6.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.5 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.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 7047f32718a8b02a07e65ac1d927501eeb69d0604167a15f3a76702411f1ef76
MD5 2a207beeadf9ab8d1d94aef53feeac98
BLAKE2b-256 f2d711e2b95a6b8a9d8a601c5fce488e99c3d7a5d66db6e41962066988787b6e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.6.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d06bcf5ecfc497ec9ed74e9e1b59326308857a900408709f1d9cf48357135bb
MD5 ca961b01673f03fedf45c02ef8d7ddd7
BLAKE2b-256 a652b682b93e7c4a42ef76b5d425da11daf3a7cd3f4dde99d5d56279bbf62aca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.6.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e9b5e0afb0de1aa64aeb10c8506f859a77e623247a84679e827771fa79fae4e8
MD5 9a8c2f83ceda49d4fa79817d02896b4d
BLAKE2b-256 179ac3b378847e3228016480118e81409a213e3ffdf681c2e0b99efa04a040d7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.6.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7e11942dc7712225aba5a6cc19782e836f6449e9854121ebc165132e9fa173ae
MD5 e21493ad3466101fcab946b849fc7f06
BLAKE2b-256 3c230512fa8e488dffcac75b713a8b9ca15acec31002cbcb9fea8ac987067dad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.6.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 0a3256fafbaf2573896c8a0e71674be8ad921b0ac4aec800f9c687d7e3f9a33b
MD5 bd046f75b56b09c6c2e5ae37de038cd6
BLAKE2b-256 b35f448f21c6471938d4fad3799edff9ed97978aa70ed67c976e8072b9c0b0da

See more details on using hashes here.

Provenance

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