curtailment 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BitSquad LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: curtailment
3
+ Version: 0.1.0
4
+ Summary: Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log
5
+ Author-email: BitSquad LLC <admin@megawattland.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://megawattland.com
8
+ Project-URL: Repository, https://github.com/chutch62416-netizen/vault
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # curtailment
19
+
20
+ Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ curtailment report curtail.csv [--spike 100] [--days 30] [--json]
26
+ ```
27
+
28
+ `curtail.csv` has columns `ts,hosts_ok,hosts_total,kw,ths,price_mwh` (ISO timestamp, kW, $/MWh).
29
+ The report gives baseline load below the spike threshold, load during spikes, curtailment
30
+ percentage, zone average price and the load-weighted price actually paid.
31
+
32
+ ```python
33
+ from curtailment import report
34
+ report(rows, spike=100, days=30)
35
+ ```
36
+
37
+ Maintained by [BitSquad LLC / MegawattLand](https://megawattland.com). MIT license. Source: https://github.com/chutch62416-netizen/vault
@@ -0,0 +1,20 @@
1
+ # curtailment
2
+
3
+ Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ curtailment report curtail.csv [--spike 100] [--days 30] [--json]
9
+ ```
10
+
11
+ `curtail.csv` has columns `ts,hosts_ok,hosts_total,kw,ths,price_mwh` (ISO timestamp, kW, $/MWh).
12
+ The report gives baseline load below the spike threshold, load during spikes, curtailment
13
+ percentage, zone average price and the load-weighted price actually paid.
14
+
15
+ ```python
16
+ from curtailment import report
17
+ report(rows, spike=100, days=30)
18
+ ```
19
+
20
+ Maintained by [BitSquad LLC / MegawattLand](https://megawattland.com). MIT license. Source: https://github.com/chutch62416-netizen/vault
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "curtailment"
7
+ version = "0.1.0"
8
+ description = "Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ authors = [{name = "BitSquad LLC", email = "admin@megawattland.com"}]
12
+ requires-python = ">=3.9"
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+
20
+ [project.urls]
21
+ Homepage = "https://megawattland.com"
22
+ Repository = "https://github.com/chutch62416-netizen/vault"
23
+
24
+ [project.scripts]
25
+ curtailment = "curtailment:main"
26
+
27
+ [tool.setuptools.packages.find]
28
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,88 @@
1
+ """curtailment: prove that a flexible load actually comes off when the zone price spikes.
2
+
3
+ Input CSV columns: ts,hosts_ok,hosts_total,kw,ths,price_mwh (price in $/MWh, blank = unknown)
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import argparse
8
+ import csv
9
+ import datetime as dt
10
+ import json
11
+ import statistics
12
+ import sys
13
+ from pathlib import Path
14
+
15
+ __version__ = "0.1.0"
16
+ __all__ = ["report", "main", "__version__"]
17
+
18
+
19
+ def report(rows: list[dict], spike: float = 100.0, days: int = 30, now: dt.datetime | None = None) -> dict:
20
+ """Summarise curtailment behaviour from logged (ts, kw, price_mwh) rows."""
21
+ now = now or dt.datetime.now()
22
+ cutoff = now - dt.timedelta(days=days)
23
+ rows = [r for r in rows if dt.datetime.fromisoformat(r["ts"]) >= cutoff and r.get("price_mwh")]
24
+ if not rows:
25
+ return {"intervals": 0}
26
+ kw = [float(r["kw"]) for r in rows]
27
+ pr = [float(r["price_mwh"]) for r in rows]
28
+ spikes = [(k, p) for k, p in zip(kw, pr) if p >= spike]
29
+ normal = [k for k, p in zip(kw, pr) if p < spike]
30
+ neg = [k for k, p in zip(kw, pr) if p < 0]
31
+ base = statistics.mean(normal) if normal else 0.0
32
+ spike_kw = statistics.mean(k for k, _ in spikes) if spikes else None
33
+ weighted_cost = sum(k * p for k, p in zip(kw, pr)) / max(sum(kw), 1e-9) # kW-weighted $/MWh paid
34
+ return {
35
+ "intervals": len(rows),
36
+ "days": days,
37
+ "spike_threshold": spike,
38
+ "spike_intervals": len(spikes),
39
+ "baseline_kw": round(base, 1),
40
+ "kw_during_spikes": None if spike_kw is None else round(spike_kw, 1),
41
+ "curtailment_pct": None if spike_kw is None or base == 0 else round(100 * (1 - spike_kw / base), 1),
42
+ "zone_avg_price": round(statistics.mean(pr), 2),
43
+ "paid_avg_price": round(weighted_cost, 2),
44
+ "negative_price_intervals": len(neg),
45
+ "kw_at_negative_price": round(statistics.mean(neg), 1) if neg else None,
46
+ }
47
+
48
+
49
+ def _print(r: dict) -> None:
50
+ print(f"Curtailment proof - last {r['days']} days, {r['intervals']} priced intervals")
51
+ print(f" baseline load (price < ${r['spike_threshold']:.0f}) {r['baseline_kw']:.1f} kW")
52
+ if r["kw_during_spikes"] is not None:
53
+ print(f" load during spikes (>= ${r['spike_threshold']:.0f}, {r['spike_intervals']} intervals) "
54
+ f"{r['kw_during_spikes']:.1f} kW -> curtailed {r['curtailment_pct']:.0f}%")
55
+ else:
56
+ print(f" no intervals at or above ${r['spike_threshold']:.0f}/MWh in range")
57
+ print(f" zone average price {r['zone_avg_price']:.2f} $/MWh")
58
+ print(f" load-weighted price actually paid {r['paid_avg_price']:.2f} $/MWh")
59
+ if r["negative_price_intervals"]:
60
+ print(f" negative-price intervals {r['negative_price_intervals']} (load {r['kw_at_negative_price']:.1f} kW)")
61
+
62
+
63
+ def main(argv=None) -> int:
64
+ p = argparse.ArgumentParser(prog="curtailment", description=__doc__,
65
+ formatter_class=argparse.RawDescriptionHelpFormatter)
66
+ p.add_argument("--version", action="version", version=__version__)
67
+ sub = p.add_subparsers(dest="cmd", required=True)
68
+ r = sub.add_parser("report", help="summarise a curtailment log CSV")
69
+ r.add_argument("log")
70
+ r.add_argument("--spike", type=float, default=100.0, help="spike threshold $/MWh (default 100)")
71
+ r.add_argument("--days", type=int, default=30)
72
+ r.add_argument("--json", action="store_true", help="emit JSON")
73
+ a = p.parse_args(argv)
74
+ with Path(a.log).open(newline="") as f:
75
+ rows = list(csv.DictReader(f))
76
+ res = report(rows, a.spike, a.days)
77
+ if not res["intervals"]:
78
+ print("no priced intervals in range", file=sys.stderr)
79
+ return 1
80
+ if a.json:
81
+ print(json.dumps(res, indent=2))
82
+ else:
83
+ _print(res)
84
+ return 0
85
+
86
+
87
+ if __name__ == "__main__":
88
+ raise SystemExit(main())
@@ -0,0 +1,3 @@
1
+ from . import main
2
+
3
+ raise SystemExit(main())
@@ -0,0 +1,37 @@
1
+ Metadata-Version: 2.4
2
+ Name: curtailment
3
+ Version: 0.1.0
4
+ Summary: Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log
5
+ Author-email: BitSquad LLC <admin@megawattland.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://megawattland.com
8
+ Project-URL: Repository, https://github.com/chutch62416-netizen/vault
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Dynamic: license-file
17
+
18
+ # curtailment
19
+
20
+ Curtailment proof report: measured load vs. ERCOT real-time price from a CSV log
21
+
22
+ ## Usage
23
+
24
+ ```
25
+ curtailment report curtail.csv [--spike 100] [--days 30] [--json]
26
+ ```
27
+
28
+ `curtail.csv` has columns `ts,hosts_ok,hosts_total,kw,ths,price_mwh` (ISO timestamp, kW, $/MWh).
29
+ The report gives baseline load below the spike threshold, load during spikes, curtailment
30
+ percentage, zone average price and the load-weighted price actually paid.
31
+
32
+ ```python
33
+ from curtailment import report
34
+ report(rows, spike=100, days=30)
35
+ ```
36
+
37
+ Maintained by [BitSquad LLC / MegawattLand](https://megawattland.com). MIT license. Source: https://github.com/chutch62416-netizen/vault
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/curtailment/__init__.py
5
+ src/curtailment/__main__.py
6
+ src/curtailment.egg-info/PKG-INFO
7
+ src/curtailment.egg-info/SOURCES.txt
8
+ src/curtailment.egg-info/dependency_links.txt
9
+ src/curtailment.egg-info/entry_points.txt
10
+ src/curtailment.egg-info/top_level.txt
11
+ tests/test_curtailment.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ curtailment = curtailment:main
@@ -0,0 +1 @@
1
+ curtailment
@@ -0,0 +1,23 @@
1
+ import datetime as dt
2
+ from curtailment import report
3
+
4
+
5
+ def test_report_curtails():
6
+ now = dt.datetime(2026, 1, 10)
7
+ rows = [
8
+ {"ts": "2026-01-09T00:00:00", "kw": "1000", "price_mwh": "30"},
9
+ {"ts": "2026-01-09T00:15:00", "kw": "1000", "price_mwh": "40"},
10
+ {"ts": "2026-01-09T00:30:00", "kw": "100", "price_mwh": "500"},
11
+ {"ts": "2026-01-09T00:45:00", "kw": "1000", "price_mwh": "-5"},
12
+ {"ts": "2025-01-01T00:00:00", "kw": "999", "price_mwh": "999"}, # out of range
13
+ ]
14
+ r = report(rows, spike=100, days=30, now=now)
15
+ assert r["intervals"] == 4
16
+ assert r["spike_intervals"] == 1
17
+ assert r["baseline_kw"] == 1000.0
18
+ assert r["curtailment_pct"] == 90.0
19
+ assert r["negative_price_intervals"] == 1
20
+
21
+
22
+ def test_empty():
23
+ assert report([], 100, 30)["intervals"] == 0