Skip to main content

PyNRPF: Python for Network Reverse Power Flow

DOI

PyNRPF detects and corrects a wrong reverse power flow (RPF) sign in fifteen-minute substation net-load data.

The problem

A substation meter records net load: demand minus local generation. When rooftop solar exceeds demand the substation exports and net load is genuinely negative. Some meters store that export as an import, so the recorded trace dips towards zero instead of crossing it. The reading passes ordinary validation but is wrong by twice its value, and it corrupts every minimum-demand study and net-load forecast built on it.

The method

M9 asks one physical question of every day: for which daytime window would flipping the recorded sign make the implied demand more plausible than keeping it, how strong is that evidence, and is it strong enough to act on? The score needs no training; two fitted numbers turn it into a probability; one control decides whether a day is corrected automatically, kept automatically, or sent to a person. Raw readings are never altered. The nine steps are one file each under src/pynrpf/m9/ and are explained in docs/method.md.

Install

Python 3.10 or later. The package depends on numpy and pandas only. Pin the version in anything that has to be reproducible:

python -m pip install pynrpf==0.4.0

On Databricks, install the same pin on the cluster or job, or copy the release wheel into a Unity Catalog Volume; docs/install.md gives both routes. examples/databricks_smoke.py is a notebook that installs the pin and runs the method on synthetic data, in pandas and through Spark, before any real readings are touched.

Quick start

import pandas as pd
import pynrpf

frame = pd.read_parquet("readings.parquet")   # substation_id, timestamp, net_load_MW, solar_MW
result = pynrpf.run(frame, c=0.7)
result.site_days      # one row per site and day: outcome, probability, window, MWh
result.intervals      # one row per reading: flag and corrected net load

On Spark: pynrpf.spark.run_per_site(sdf). From a CSV without code: pynrpf run readings.csv --out results/. Column names, the control and the calibration are documented in docs/quickstart.md.

Repository layout

src/pynrpf/                 the package: m9/ (one file per step), run, validate, schemas, impact, spark, cli
docs/                       one page per topic; mkdocs serve for a local site
tests/                      package tests on fixtures, paper tests on the reference run
publication/2_journal_article/
    paper/                  the code the paper's notebooks call: baselines, folds, metrics, figures, tables
    notebooks/              five notebooks that regenerate the reference run, two that draw every figure and table
    results/                the reference run, with a manifest per stage
    dataset/                the Alpha, Beta and Gamma datasets (anonymised Ausgrid data)
    config/evaluation.yaml  the one configuration of the reference run
    sandbox/                development history and dated studies; not maintained, not cited
publication/1_conference_paper/   the conference paper's archive, self-contained

Branches

branch holds rule
main the released, Zenodo-archived version changes arrive by pull request; a GitHub Release vX.Y.Z publishes it
dev the 0.3 package that Ausgrid's current pipeline depends on do not modify it, merge into it, or branch new work from it
feature branches work in progress branched from main, merged back by pull request

Data

All datasets derive from anonymised Ausgrid distribution network data and are committed so that the paper reproduces from the repository alone: Alpha (ten stations, three years, the wrong sign imitated by taking the absolute value), Beta (eight stations, one year, real errors labelled by two reviewers) and Gamma (one station for the forecasting case study). Details in docs/data.md.

Reproducing the paper

python -m pip install -e .[dev,paper], then open the notebooks under publication/2_journal_article/notebooks/: paper_figures.ipynb and paper_tables.ipynb regenerate every figure and table from the committed results in minutes; notebooks 01 to 05 regenerate the results themselves. See docs/reproduce.md.

Tests

python -m pip install -e .[dev,paper]
pytest -q
ruff check src/pynrpf tests publication/2_journal_article/paper

Documentation

page what it covers
docs/quickstart.md one call, the output tables column by column
docs/spark.md the per-site Spark adapter
docs/cli.md the command line
docs/api.md every public name
docs/method.md the nine steps of M9 with the formulas and a worked day
docs/calibration.md the release numbers and refitting for a new population
docs/overrides.md the review-table schema for human decisions
docs/data.md the datasets and how they were labelled
docs/evaluation.md how the paper judges a method
docs/reproduce.md the notebooks and the reference run
docs/development.md tests, lint, continuous integration, releases

Licence

MIT. See LICENSE.

Acknowledgements

This project is part of Samhan's PhD study, supported by the University International Postgraduate Award (UIPA) Scholarship from UNSW, the Industry Collaboration Project Scholarship from Ausgrid, the RACE for 2030 Scholarship, and the NSW Decarbonisation Innovation Hub (NSW Decarb Hub).

Contributors

Citation

If you use this software, please cite it using the metadata in CITATION.cff, or the archived release:

Samhan, M. S., Bruce, A., & Yildiz, B. (2026). PyNRPF: Detecting and rectifying wrong reverse power flow readings [Software]. Zenodo. https://doi.org/10.5281/zenodo.18764943

The DOI above is the concept DOI and resolves to the latest archived release; each release also has its own version DOI on Zenodo.

Metadata

Release files for pynrpf 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynrpf 0.4.0
File Size Uploaded Provenance Actions
pynrpf-0.4.0.tar.gz 41.4 kB With provenance Details for pynrpf-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pynrpf 0.4.0
File Interpreter ABI Platform Actions
pynrpf-0.4.0-py3-none-any.whl Python 3 none any Details for pynrpf-0.4.0-py3-none-any.whl

Total release size: 70.7 kB

Release files / pynrpf-0.4.0.tar.gz

Download URL pynrpf-0.4.0.tar.gz
Size 41.4 kB
Tags Source
SHA-256 checksum
How to use checksums
27a3278cc749ba1bf28cdcf32bb492ce7f81ae2de27221ff6e071631ceb5aae1
BLAKE2b-256 checksum
How to use checksums
924630420844b5e1c1333c1bc5695613205e18b50f2cd75c01d96f12bfa14578
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / pynrpf-0.4.0-py3-none-any.whl

Download URL pynrpf-0.4.0-py3-none-any.whl
Size 29.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48196114343e29c48b324808f86b09c67c8c7fcf2e07df91080fd99c1915381f
BLAKE2b-256 checksum
How to use checksums
1b058637dce34546ad842981ab51efc4c27d863b654995145bee29a7675e6ca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for pynrpf 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pynrpf-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page