GLOBALGRID2050 / EXPLORE CODE

Part of: Explore Code / Electricity markets and data pipelines / globalgrid2050 / automation/convergence

Build Renewable Energy Planning Database (REPD) Datacentres (part 2)

A Python command-line tool in the convergence folder of GlobalGrid2050 that reads datacentre proximity, colocation candidates, rollup region and rollup cluster, using EPSG:27700 and SHA-256.

363 lines of Python from globalgrid2050, in 1 file. Topic: Electricity markets and data pipelines. Section 772 of 2044.

Cut 2026-12-06T03:07:51+00:00. A copy for reading; the repository at the stated commit is the source.

In the State lines below, domain stage, users and canonical status are rule-based first approximations from code and path evidence (rules explore-agent-rules-v1), not observed facts: the rules.

In this section

  1. Build Renewable Energy Planning Database (REPD) Datacentres geodesy · globalgrid2050 / automation/convergence/build_repd_datacentres.py lines 701–1063

Build Renewable Energy Planning Database (REPD) Datacentres

A Python command-line tool in the convergence folder of GlobalGrid2050 that reads datacentre proximity, colocation candidates, rollup region and rollup cluster, using EPSG:27700 and SHA-256.

geodesyglobalgrid2050 / automation/convergence/build_repd_datacentres.py · lines 701–1063 of 1063 (continued from section 771) · Entry point · pattern norm_operator (shared by 2 files)

What it does
It loads datacentre proximity, colocation candidates, rollup region and rollup cluster. Defines 47 functions or classes, including _tokens, _op_core, norm_operator, operator_keys, site_tokens. Uses libraries __future__, argparse, csv, hashlib, io. Side effects: reads or writes files; starts processes.
Why it exists in the grid workflow
Domain stage upstream_foresight (path word 'datacentres'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: 132kV.
Inputs & outputs
In: JSON file datacentre_proximity.json; JSON file colocation_candidates.json; JSON file rollup_region.json; JSON file rollup_cluster.json; JSON file schema.json; command-line arguments. Out: JSON file. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326. Voltage levels named: 132kV.
Downstream impact
Used directly by 1 file: Test Build Renewable Energy Planning Database (REPD) Datacentres (globalgrid2050). Reached from 1 other entry point, including GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
What it achieves
It parses capacity (`parse_capacity`), parses coord (`parse_coord`) and loads REPD (`load_repd`). REPD x UK data-centre convergence: one deterministic, offline join. Its code works with 132 kV. It accepts `--repd`, `--identity` and `--datacentres`.
Why it matters
Checked by Test Build Renewable Energy Planning Database (REPD) Datacentres.
Application
globalgrid2050 · automation/convergence · Python CLI
Uses
__future__, argparse, csv, hashlib, io, json, math, re
Used by
imported by Test Build Renewable Energy Planning Database (REPD) Datacentres (sys.path import)
Produces
norm_operator, operator_keys, site_tokens, bng_to_wgs84, haversine_km, r3, msum, sha256_file, parse_capacity, parse_coord, load_repd, load_datacentres
Defines here
flat_cells, csv_dc, csv_proj, csv_coloc, csv_region, csv_cluster, to_csv_bytes, to_json_bytes, schema_doc, run, inp, main
Cannot conclude
Whether this code runs, is used by a live app today, or is correct. This is a static reading.
Evidence
globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 automation/convergence/build_repd_datacentres.py:701-1063 · blob 12fbe3b0d728fc7858a24cbb79e81bcf3b903fe2 · GitHub at these lines
State
achieves: comment · context: readme_derived · stage: output · effects: filesystem, process · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
                emit("D_same_site_proximity", p, dc, d, {"radius_km": SAME_SITE_KM})
    coloc.sort(key=lambda c: (c["evidence_class"], c["datacentre"]["id"], int(c["repd"]["ref"])))

    # ---- (d) roll-ups
    regions = defaultdict(lambda: {"cells": empty_cells(), "dc": Counter(), "it": [], "gc": [], "dc_ids": []})
    for p in [p for p in repd_rows if p["tech_group"] and p["status_group"] and p["ref"] not in dups]:
        add_cell(regions[p["region"] or "(blank)"]["cells"], p)
    for dc in placed:
        g = regions[dc["region_inferred"] or "(unplaced)"]
        g["dc"][dc["status"]] += 1
        g["dc_ids"].append(dc["id"])
        if dc["it_load_mw"]["value"] is not None:
            g["it"].append(dc["it_load_mw"]["value"])
        if dc["grid_connection_mw"]["value"] is not None:
            g["gc"].append(dc["grid_connection_mw"]["value"])
    region_rows = []
    for name in sorted(regions):
        g = regions[name]
        region_rows.append({"level": "region", "name": name, "country": country_of(name) if name[0] != "(" else None,
                            "repd": close_cells(g["cells"]), "datacentres": sum(g["dc"].values()),
                            "datacentres_by_status": dict(sorted(g["dc"].items())),
                            "it_load_mw_stated": msum(g["it"]), "it_load_mw_known_sites": len(g["it"]),
                            "grid_connection_mw_stated": msum(g["gc"]),
                            "grid_connection_mw_known_sites": len(g["gc"])})
    countries = defaultdict(list)
    for rr in region_rows:
        if rr["country"]:
            countries[rr["country"]].append(rr)
    for cname in sorted(countries):
        rs = countries[cname]
        cells = {t: {s: {"count": sum(r["repd"][t][s]["count"] for r in rs),
                         "mw_stated": msum([r["repd"][t][s]["mw_stated"] for r in rs]),
                         "count_mw_unknown": sum(r["repd"][t][s]["count_mw_unknown"] for r in rs)}
                     for s in STATUS_ORDER} for t in TECH_ORDER}
        st = Counter()
        for r in rs:
            st.update(r["datacentres_by_status"])
        region_rows.append({"level": "country", "name": cname, "country": cname, "repd": cells,
                            "datacentres": sum(st.values()), "datacentres_by_status": dict(sorted(st.items())),
                            "it_load_mw_stated": msum([r["it_load_mw_stated"] for r in rs]),
                            "it_load_mw_known_sites": sum(r["it_load_mw_known_sites"] for r in rs),
                            "grid_connection_mw_stated": msum([r["grid_connection_mw_stated"] for r in rs]),
                            "grid_connection_mw_known_sites": sum(r["grid_connection_mw_known_sites"] for r in rs)})

    cluster_rows = []
    for c in clusters:
        mem = c["members"]
        lat = round(math.fsum(m["lat"] for m in mem) / len(mem), 5)
        lon = round(math.fsum(m["lon"] for m in mem) / len(mem), 5)
        st = Counter(m["status"] for m in mem)
        it = [m["it_load_mw"]["value"] for m in mem if m["it_load_mw"]["value"] is not None]
        gc = [m["grid_connection_mw"]["value"] for m in mem if m["grid_connection_mw"]["value"] is not None]
        reg = Counter(m["region_inferred"] for m in mem)
        region = sorted(reg, key=lambda r: (-reg[r], r or ""))[0]
        label_node = None
        if node_index:
            d, n = node_index.nearest(lat, lon, 1, key=lambda n: n["site_code"])[0]
            label_node = node_brief(n, d)
        cells_by_r = {r: empty_cells() for r in RADII_KM}
        top = {"solar": [], "battery": []}
        for p in live:
            dmin = min(haversine_km(m["lat"], m["lon"], p["lat"], p["lon"]) for m in mem)
            if dmin > RADII_KM[-1]:
                continue
            for r in RADII_KM:
                if dmin <= r:
                    add_cell(cells_by_r[r], p)
            if dmin <= CLUSTER_TOP_RADIUS_KM and p["status_group"] == "consented" and p["tech_group"] in top:
                top[p["tech_group"]].append((p, dmin))
        radii = {str(r): close_cells(cells_by_r[r]) for r in RADII_KM}
        tops = {}
        for t, lst in top.items():
            lst.sort(key=lambda x: (-(x[0]["capacity_mw"] if x[0]["capacity_mw"] is not None else -1),
                                    int(x[0]["ref"])))
            tops[t] = [project_brief(p, d) for p, d in lst[:CLUSTER_TOP_PROJECTS]]
        cluster_rows.append({"level": "cluster", "cluster_id": c["cluster_id"], "sites": len(mem),
                             "centroid": {"lat": lat, "lon": lon}, "region_inferred": region,
                             "label_transmission_node": label_node,
                             "datacentres_by_status": dict(sorted(st.items())),
                             "member_ids": [m["id"] for m in mem],
                             "it_load_mw_stated": msum(it), "it_load_mw_known_sites": len(it),
                             "grid_connection_mw_stated": msum(gc), "grid_connection_mw_known_sites": len(gc),
                             "repd_within_km_of_any_member": radii,
                             "largest_consented_within_%dkm" % CLUSTER_TOP_RADIUS_KM: tops})

    stats = {
        "repd_records": len(repd_rows),
        "repd_live_target_projects_located": len(live),
        "repd_target_projects_located_all_statuses": len(targets),
        "datacentres": len(dcs), "datacentres_placed": len(placed),
        "datacentres_proximity_reliable": len(reliable),
        "transmission_nodes_located": len(nodes), "osm_substations_132kv_plus": len(osm or []),
        "clusters": len(clusters),
        "repd_duplicates_collapsed": len(dups),
        "datacentres_geometry_rejected": sum(1 for d in dcs if d.get("geometry_issue")),
        "colocation_candidates_by_class": dict(sorted(Counter(c["evidence_class"] for c in coloc).items())),
    }
    return {"datacentre_proximity": dc_rows, "repd_datacentre_proximity": proj_rows,
            "colocation_candidates": coloc, "rollup_region": region_rows, "rollup_cluster": cluster_rows,
            "stats": stats, "duplicates": dups}


# ---------------------------------------------------------------------------------------------- CSV flattening
def flat_cells(prefix, cells, out):
    for t in TECH_ORDER:
        for s in STATUS_ORDER:
            c = cells[t][s]
            out["%s%s_%s_mw" % (prefix, t, s)] = c["mw_stated"]
            out["%s%s_%s_count" % (prefix, t, s)] = c["count"]
            out["%s%s_%s_mw_unknown" % (prefix, t, s)] = c["count_mw_unknown"]


def csv_dc(rows):
    out = []
    for r in rows:
        o = {k: r[k] for k in ("id", "name", "status", "precision", "proximity_reliable", "operator", "lat", "lon",
                               "cluster_id", "region_inferred", "country_inferred", "it_load_mw",
                               "grid_connection_mw", "unclassified_mw", "unclassified_mw_label")}
        n = r.get("nearest_transmission_node") or {}
        o["nearest_node_site_code"] = n.get("site_code")
        o["nearest_node_name"] = n.get("name")
        o["nearest_node_km"] = n.get("distance_km")
        sh = r.get("shared_node") or {}
        o["shared_node_repd_projects"] = sh.get("repd_projects")
        for t in TECH_ORDER:
            nb = (r.get("nearest_by_technology") or {}).get(t) or {}
            o["nearest_%s_ref" % t] = nb.get("ref")
            o["nearest_%s_km" % t] = nb.get("distance_km")
            o["nearest_%s_status" % t] = nb.get("status")
            o["nearest_%s_mw" % t] = nb.get("capacity_mw")
        if sh:
            flat_cells("shared_node_", sh["by_technology"], o)
        for rad in RADII_KM:
            if r.get("radii"):
                flat_cells("r%dkm_" % rad, r["radii"][str(rad)], o)
        out.append(o)
    return out


def csv_proj(rows):
    out = []
    for r in rows:
        o = {k: r[k] for k in ("ref", "gg_project_id", "site_name", "technology", "tech_group", "status",
                               "status_group", "capacity_mw", "region", "country", "lat", "lon", "duplicate_of")}
        for i in range(NEAREST_DC_LIST):
            nd = r["nearest_datacentres"][i] if i < len(r["nearest_datacentres"]) else {}
            o["dc%d_id" % (i + 1)] = nd.get("id")
            o["dc%d_name" % (i + 1)] = nd.get("name")
            o["dc%d_status" % (i + 1)] = nd.get("status")
            o["dc%d_km" % (i + 1)] = nd.get("distance_km")
        for rad in RADII_KM:
            w = r["within"][str(rad)]
            for k in ("datacentres", "operational", "pipeline", "it_load_mw_stated", "it_load_mw_known_sites",
                      "grid_connection_mw_stated", "grid_connection_mw_known_sites"):
                o["r%dkm_%s" % (rad, k)] = w[k]
        n = r.get("nearest_transmission_node") or {}
        o["nearest_node_site_code"] = n.get("site_code")
        o["nearest_node_km"] = n.get("distance_km")
        out.append(o)
    return out


def csv_coloc(rows):
    return [{"evidence_class": c["evidence_class"], "datacentre_id": c["datacentre"]["id"],
             "datacentre_name": c["datacentre"]["name"], "datacentre_status": c["datacentre"]["status"],
             "repd_ref": c["repd"]["ref"], "gg_project_id": c["repd"]["gg_project_id"],
             "repd_site_name": c["repd"]["site_name"], "repd_technology": c["repd"]["technology"],
             "repd_status": c["repd"]["status"], "repd_capacity_mw": c["repd"]["capacity_mw"],
             "distance_km": c["distance_km"], "evidence": json.dumps(c["evidence"], sort_keys=True)} for c in rows]


def csv_region(rows):
    out = []
    for r in rows:
        o = {"level": r["level"], "name": r["name"], "country": r["country"], "datacentres": r["datacentres"],
             "datacentres_by_status": json.dumps(r["datacentres_by_status"], sort_keys=True),
             "it_load_mw_stated": r["it_load_mw_stated"], "it_load_mw_known_sites": r["it_load_mw_known_sites"],
             "grid_connection_mw_stated": r["grid_connection_mw_stated"],
             "grid_connection_mw_known_sites": r["grid_connection_mw_known_sites"]}
        flat_cells("repd_", r["repd"], o)
        out.append(o)
    return out


def csv_cluster(rows):
    out = []
    for r in rows:
        n = r["label_transmission_node"] or {}
        o = {"cluster_id": r["cluster_id"], "sites": r["sites"], "centroid_lat": r["centroid"]["lat"],
             "centroid_lon": r["centroid"]["lon"], "region_inferred": r["region_inferred"],
             "label_node_site_code": n.get("site_code"), "label_node_name": n.get("name"),
             "datacentres_by_status": json.dumps(r["datacentres_by_status"], sort_keys=True),
             "it_load_mw_stated": r["it_load_mw_stated"], "it_load_mw_known_sites": r["it_load_mw_known_sites"],
             "grid_connection_mw_stated": r["grid_connection_mw_stated"],
             "grid_connection_mw_known_sites": r["grid_connection_mw_known_sites"],
             "member_ids": ";".join(r["member_ids"])}
        for rad in RADII_KM:
            flat_cells("r%dkm_" % rad, r["repd_within_km_of_any_member"][str(rad)], o)
        out.append(o)
    return out


def to_csv_bytes(rows):
    if not rows:
        return b""
    cols = list(rows[0].keys())
    for r in rows[1:]:
        for k in r:
            if k not in cols:
                cols.append(k)
    buf = io.StringIO()
    w = csv.DictWriter(buf, fieldnames=cols, lineterminator="\n")
    w.writeheader()
    for r in rows:
        w.writerow({k: ("" if r.get(k) is None else r.get(k)) for k in cols})
    return buf.getvalue().encode("utf-8")


def to_json_bytes(obj, compact=False):
    if compact:
        return (json.dumps(obj, ensure_ascii=False, separators=(",", ":")) + "\n").encode("utf-8")
    return (json.dumps(obj, ensure_ascii=False, indent=1) + "\n").encode("utf-8")


# ---------------------------------------------------------------------------------------------- schema
def schema_doc():
    cell = {"count": "projects in the cell", "mw_stated": "sum of stated Installed Capacity (MWelec); blanks excluded",
            "count_mw_unknown": "projects in the cell whose capacity is blank (unknown, not zero)"}
    return {
        "schema": SCHEMA_ID,
        "tool_version": TOOL_VERSION,
        "parameters": {"radii_km": list(RADII_KM), "technology_groups": TECH_GROUPS, "status_groups": STATUS_GROUPS,
                       "proximity_precisions": sorted(PROXIMITY_PRECISIONS), "cluster_link_km": CLUSTER_LINK_KM,
                       "cluster_min_sites": CLUSTER_MIN_SITES, "region_vote_k": REGION_VOTE_K,
                       "same_site_km": SAME_SITE_KM, "same_site_operator_km": SAME_SITE_OPERATOR_KM,
                       "name_match_km": NAME_MATCH_KM, "name_token_max_df": NAME_TOKEN_MAX_DF,
                       "earth_radius_km": EARTH_R_KM},
        "caveats": CAVEATS,
        "cell": cell,
        "files": {
            "datacentre_proximity.json": {
                "key": "id (data-centre id from the baseline)",
                "fields": {
                    "precision": "baseline location.precision; proximity_reliable is true for exact_site and settlement",
                    "region_inferred": "majority REPD Region of the %d nearest located onshore REPD records (any technology or status); an inference, not a source field" % REGION_VOTE_K,
                    "it_load_mw / grid_connection_mw": "baseline values as published; null is unknown",
                    "unclassified_mw (+label)": "passed through, never summed: the label says what the figure is",
                    "radii[<km>][<tech>][<status>]": "cell of REPD projects within <km> straight line",
                    "nearest_by_technology[<tech>]": "nearest REPD project of that technology in the four live status groups",
                    "nearest_transmission_node": "nearest located NESO ETYS node (connection-points.v3, >=132 kV)",
                    "shared_node": "live REPD projects (four technologies) whose own nearest ETYS node is the same node",
                    "nearest_osm_substation_132kv_plus": "nearest OpenStreetMap substation tagged >= 132 kV"}},
            "repd_datacentre_proximity_{solar,battery,wind}.json": {
                "key": "ref (REPD Ref ID); gg_project_id from the V6 identity",
                "layout": "columnar (columns + rows) with the same columns as the CSV, for size; one file per technology part",
                "scope": "solar, battery, onshore and offshore wind with usable coordinates, every status (status_group null outside the live pipeline); ordered solar, battery, wind onshore, wind offshore, then ref",
                "fields": {"duplicate_of": "set when this live record repeats a site (same technology group, normalised site name, stated capacity and point); the record named is counted instead and this one is in no radius or roll-up",
                           "nearest_datacentres": "up to %d nearest proximity-reliable data centres" % NEAREST_DC_LIST,
                           "within[<km>]": "proximity-reliable data centres within <km>: count, operational, pipeline (every other status), stated IT load MW and grid connection MW with the number of sites stating each"}},
            "colocation_candidates.json": {
                "key": "(evidence_class, datacentre.id, repd.ref)",
                "evidence_classes": {
                    "A_same_site_and_operator": "strict operator match and <= %.1f km, data centre at exact_site precision" % SAME_SITE_OPERATOR_KM,
                    "B_operator_match": "strict operator match at any distance (dcmerge norm_operator after dropping a parenthesised gloss; exact equality; ';' splits several operators)",
                    "C_same_site_name_and_proximity": ">= 2 shared site-name tokens, at least one distinctive (in <= %d REPD name+address strings), and <= %.1f km" % (NAME_TOKEN_MAX_DF, NAME_MATCH_KM),
                    "D_same_site_proximity": "<= %.1f km, data centre at exact_site precision; any REPD technology or status" % SAME_SITE_KM,
                    "E_repd_text_mentions_datacentre": "REPD Site Name or Address mentions a data centre; paired with the nearest proximity-reliable data centre, which may be far away (evidence.nearest_within_name_match_km says whether it is within %.1f km): the REPD text is the evidence, the pairing is only a pointer" % NAME_MATCH_KM},
                "note": "a candidate is evidence to review, not a confirmed relationship"},
            "rollup_region.json": {"levels": "region (REPD Region; data centres by region_inferred) and country",
                                   "repd": "live-pipeline cells of the four technologies"},
            "rollup_cluster.json": {"clusters": "single-linkage of proximity-reliable data centres at %.0f km, at least %d sites; ids by size then member id" % (CLUSTER_LINK_KM, CLUSTER_MIN_SITES),
                                    "repd_within_km_of_any_member": "live REPD projects within <km> of any member, each counted once",
                                    "largest_consented_within_%dkm" % CLUSTER_TOP_RADIUS_KM: "the %d largest stated-capacity Awaiting Construction solar and battery projects within %d km of any member (unknown capacity last)" % (CLUSTER_TOP_PROJECTS, CLUSTER_TOP_RADIUS_KM)},
            "CSV files": "flattened views of the JSON files: columns r<km>km_<tech>_<status>_{mw,count,mw_unknown}; blank cell = null",
        },
    }


# ---------------------------------------------------------------------------------------------- main
def run(args):
    out = Path(args.out)
    out.mkdir(parents=True, exist_ok=True)
    repd_rows, excluded = load_repd(args.repd, args.identity)
    dcs, dc_meta = load_datacentres(args.datacentres)
    nodes, node_meta = load_connection_points(args.connection_points) if args.connection_points else ([], None)
    osm, osm_meta = load_osm_substations(args.osm_substations) if args.osm_substations else (None, None)
    res = build(repd_rows, dcs, nodes, osm)

    files = {}
    meta = {"schema": SCHEMA_ID, "caveats": CAVEATS}
    for name, rows, flat in (("datacentre_proximity", res["datacentre_proximity"], csv_dc),
                             ("colocation_candidates", res["colocation_candidates"], csv_coloc),
                             ("rollup_region", res["rollup_region"], csv_region),
                             ("rollup_cluster", res["rollup_cluster"], csv_cluster)):
        files[name + ".json"] = to_json_bytes({**meta, "records": rows})
        files[name + ".csv"] = to_csv_bytes(flat(rows))
    # the per-project table is split by technology and written compactly so every file stays under the
    # repository's 5 MB per-file guard (.github/workflows/pr-file-size-guard.yml MAX_MB)
    for part, groups in PROJECT_PARTS:
        rows = [r for r in res["repd_datacentre_proximity"] if r["tech_group"] in groups]
        flat = csv_proj(rows)
        cols = list(flat[0].keys()) if flat else []
        files["repd_datacentre_proximity_%s.json" % part] = to_json_bytes(
            {**meta, "layout": "columnar: one array per project in the order of columns; null is unknown",
             "columns": cols, "rows": [[r.get(c) for c in cols] for r in flat]}, compact=True)
        files["repd_datacentre_proximity_%s.csv" % part] = to_csv_bytes(flat)
    files["schema.json"] = to_json_bytes(schema_doc())

    def inp(label, path, extra=None):
        p = Path(path)
        o = {"role": label, "file": p.name, "sha256": sha256_file(p), "bytes": p.stat().st_size}
        if extra:
            o.update(extra)
        return o

    inputs = [inp("repd_register", args.repd, {"records": len(repd_rows)})]
    if args.identity:
        inputs.append(inp("repd_identity", args.identity))
    inputs.append(inp("datacentre_baseline", args.datacentres,
                      {"features": len(dcs), "title": dc_meta.get("title")}))
    if args.connection_points:
        inputs.append(inp("transmission_nodes", args.connection_points, node_meta))
    if args.osm_substations:
        inputs.append(inp("osm_substations", args.osm_substations, osm_meta))
    manifest = {
        "schema": SCHEMA_ID + ".manifest",
        "tool": {"file": "automation/convergence/build_repd_datacentres.py", "version": TOOL_VERSION,
                 "sha256": sha256_file(__file__)},
        "release": args.release,
        "inputs": inputs,
        "excluded_repd_geography": sorted(excluded, key=lambda e: int(e["ref"]) if e["ref"].isdigit() else 0),
        "repd_duplicates_collapsed": [{"ref": r, "kept_ref": k} for r, k in
                                      sorted(res["duplicates"].items(), key=lambda kv: int(kv[0]))],
        "datacentres_geometry_rejected": [{"id": d["id"], "reason": d["geometry_issue"]} for d in dcs
                                          if d.get("geometry_issue")],
        "stats": res["stats"],
        "outputs": [{"file": n, "sha256": hashlib.sha256(b).hexdigest(), "bytes": len(b)}
                    for n, b in sorted(files.items())],
    }
    files["manifest.json"] = to_json_bytes(manifest)
    for n, b in files.items():
        (out / n).write_bytes(b)
    return manifest


def main(argv=None):
    ap = argparse.ArgumentParser(description=__doc__.split("\n")[0])
    ap.add_argument("--repd", required=True)
    ap.add_argument("--identity")
    ap.add_argument("--datacentres", required=True)
    ap.add_argument("--connection-points")
    ap.add_argument("--osm-substations")
    ap.add_argument("--release", default="2026q3")
    ap.add_argument("--out", required=True)
    a = ap.parse_args(argv)
    m = run(a)
    json.dump(m["stats"], sys.stdout, indent=1)
    sys.stdout.write("\n")
    return 0


if __name__ == "__main__":
    sys.exit(main())