Skip to main content

Lossless power system case file IO, format conversion, and sparse matrix and graph views

Project description

PowerIO

PowerIO logo

PowerIO reads power system case files into a typed Network, writes them back, converts between common formats, and builds the sparse matrices and graph views used by analysis and solver code. It aspires to be "the pandoc for power systems."

Supported formats:

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 emits Conversion::warnings for fields the target format cannot represent.

PowerIO format and matrix flow

Packages

powerio          parser, Network model, source retaining writers, converters
powerio-matrix   sparse matrices, DC sensitivity factors, graph views
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

API docs: https://eigenergy.github.io/powerio/. Language API map: docs/languages.md.

Install

cargo add --git https://github.com/eigenergy/powerio powerio
cargo add --git https://github.com/eigenergy/powerio powerio-matrix
cargo install --git https://github.com/eigenergy/powerio 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

PowerIO is implemented in Rust and features a low-level C ABI. This lets PowerIO talk to many of your favorite languages. Any language with a C foreign function interface can call it.

Rust

use powerio::{TargetFormat, parse_file};

let net = parse_file("case14.m")?;
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]
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 psse -o case14.raw
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

Current Format Fidelity

reader / writer MATPOWER PowerModels JSON PSS/E PowerWorld egret JSON
MATPOWER original text full partial partial partial
PowerModels JSON partial original text partial partial partial
PSS/E full full original text partial partial
PowerWorld full full partial original text partial
egret JSON partial full partial partial original text

partial means the target lacks fields present in the source. The writer reports those cases in Conversion::warnings. Known limits are documented in docs/format-fidelity.md.

Matrices

powerio-matrix derives an IndexedNetwork with dense bus indices and builds:

  • 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
  • Matrix Market bundle for DC OPF solvers
  • Adjacency matrix and petgraph view

Current conventions for signs, taps, phase shifts, per unit scaling, reference buses, and DC susceptance are documented in docs/matrices.md.

Normalized View

Network::to_normalized derives a solver oriented copy of a case with sane defaults. Powers are provided in per unit, voltage phase angles are in radians, inactive elements are removed, tap == 0 replaced with 1, surviving buses are reindexed to a dense 1-based id space, and bus types are made consistent with generator placement and reference buses. Computing it carries no retained source text, so writing the normalized network emits the derived model rather than the original file.

Python exposes the normalized view as case.to_normalized(), the C ABI as pio_to_normalized, and Julia as to_normalized(case).

Special features

GridFM

PowerIO supports the GridFM framework. The command powerio gridfm <case> -o <dir> writes the Parquet tables consumed by gridfm-datakit and gridfm-graphkit: bus_data, gen_data, branch_data, and y_bus_data under <dir>/<case>/raw/. A case file is one scenario. Passing several compatible cases stacks them by scenario id.

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_export_arrow over the Arrow C Data Interface.

MCP Server

The Python package includes an optional MCP server with convert_case and case_summary tools. Interoperability with the PowerAgent project is planned.

pip install 'powerio[mcp]'
powerio-mcp

Validation

The Rust test suite covers parsers, writers, format conversion, matrix builders, and normalization; the C ABI crate carries its own tests (it is outside the default members, so it needs an explicit -p powerio-capi), and pytest covers the Python bindings. The benchmark validation suite compares selected outputs against PowerModels.jl, egret, ExaPowerIO.jl, and pandapower.

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:

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.0.1.tar.gz (185.5 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.0.1-cp39-abi3-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

powerio-0.0.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view details)

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

powerio-0.0.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

powerio-0.0.1-cp39-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

powerio-0.0.1-cp39-abi3-macosx_10_12_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for powerio-0.0.1.tar.gz
Algorithm Hash digest
SHA256 29e259f9a319d5f2ee690a500819e755eb339059cbcac99f62b96bd23986d774
MD5 ddf2774618ab8567f3d276e4b92576c8
BLAKE2b-256 9a4429539cddacc01d905baf7a38c85b6f2437f1dfdb05d4ec980eec76b32d16

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: powerio-0.0.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 1.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.0.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b5cd027410c3dddf337e760248baf7bc9ed3c22cecdf203e580eb7ff1ca5709
MD5 3f39f53f2bead93ea89c746244680e15
BLAKE2b-256 f352c3f5eab6d75123551e6d100f197743ac006092ce7e79b6d7dd9391b95fdc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.0.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d38c1de3bb93eb1c79d4b861a036b214af019ec1f00987771440607a755f9b1
MD5 29001caca45fffc3cd24b87e23e0a4e3
BLAKE2b-256 677c7e325001ec6dce36824eec6777fbae63629ae8372c499b0ca741bd76d86e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.0.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2b647ff02e04931fae78365a1ea8bc6f05afdbea2e247e2b6efbb88db9d31020
MD5 e221ad93ed77596d3f6aae0d1f4bb2fc
BLAKE2b-256 f70fc0d4fa91e36b10d66d8b3af41b9b0a498745f804404f8f2415612a2307bc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.0.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 45dbcffb954f760910fc82ff4b59656afd8ba79f14142202d64c5457359761bc
MD5 b202516355be3c222ab1d18c09c4dfe0
BLAKE2b-256 0598e69aea850ed9f701f41aca4e1edfaa6898465cc1f8ff289dfd0de16e6a17

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for powerio-0.0.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 72810a8f4b9b4e7f39391af8ef4e8b4c432fe2bd4b21490f22271d0d66611749
MD5 af9979dbedea8f6ea221e2a67686dff5
BLAKE2b-256 f67298be72b90420777eff6cba85db81c96c9f2ed47059810fe5f9a17b1b08dc

See more details on using hashes here.

Provenance

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