From 4472e47ed40217c27d93b1c29eeb8ba60b5fbb9c Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Wed, 15 Jul 2026 13:41:17 +0000 Subject: [PATCH] =?UTF-8?q?Charge=20the=20C6=20half=20heat-network=20stand?= =?UTF-8?q?ing=20charge=20on=20a=20water-only=20dwelling's=20fuel=20cost?= =?UTF-8?q?=20worksheet=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- c6_cohort.py | 41 ------------------- .../sap10_calculator/rdsap/cert_to_inputs.py | 15 +++---- 2 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 c6_cohort.py diff --git a/c6_cohort.py b/c6_cohort.py deleted file mode 100644 index 25c18c5cd..000000000 --- a/c6_cohort.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Which 21.0.1-corpus certs are in #1606's C6 half-charge cohort? -Cohort = WHC in {950,951,952} AND space main is NOT a heat network. -""" -import json -from pathlib import Path -from datatypes.epc.domain.mapper import EpcPropertyDataMapper -from datatypes.epc.domain.field_mappings import is_heat_network_main -from domain.sap10_calculator.rdsap.cert_to_inputs import ( - _first_main_heating, _heat_network_standing_charge_gbp, - _WATER_HEAT_NETWORK_ONLY_CODES, -) - -path = Path("backend/epc_api/json_samples/RdSAP-Schema-21.0.1/corpus.jsonl") -certs = [json.loads(l) for l in path.read_text().splitlines() if l.strip()] - -hits = [] -for c in certs: - epc = EpcPropertyDataMapper.from_api_response(c) - whc = epc.sap_heating.water_heating_code if epc.sap_heating else None - if whc not in _WATER_HEAT_NETWORK_ONLY_CODES: - continue - m1 = _first_main_heating(epc) - net = is_heat_network_main(m1) - hits.append({ - "rrn": c.get("rrn") or c.get("lmk_key"), - "uprn": c.get("uprn"), - "addr": (c.get("address1") or "")[:34], - "whc": whc, - "main_code": m1.sap_main_heating_code if m1 else None, - "main_is_network": net, - "net_standing": _heat_network_standing_charge_gbp(epc, m1), - "in_C6_half_cohort": not net, - }) - -print(f"WHC 950/951/952 certs in 21.0.1 corpus: {len(hits)}\n") -for h in hits: - flag = " <== C6 HALF COHORT" if h["in_C6_half_cohort"] else "" - print(f" rrn={h['rrn']} uprn={h['uprn']}") - print(f" addr={h['addr']!r} whc={h['whc']} main={h['main_code']} " - f"network_main={h['main_is_network']} net_standing={h['net_standing']}{flag}") -print(f"\nIn C6 half cohort: {sum(h['in_C6_half_cohort'] for h in hits)}") diff --git a/domain/sap10_calculator/rdsap/cert_to_inputs.py b/domain/sap10_calculator/rdsap/cert_to_inputs.py index 9bfa07707..0ae21a4fe 100644 --- a/domain/sap10_calculator/rdsap/cert_to_inputs.py +++ b/domain/sap10_calculator/rdsap/cert_to_inputs.py @@ -7723,15 +7723,12 @@ def _fuel_cost( table_32_unit_price_p_per_kwh(60) * _PENCE_TO_GBP ) - heat_network_standing = _heat_network_standing_charge_gbp(epc, main) - standing = ( - heat_network_standing - if heat_network_standing is not None - else additional_standing_charges_gbp( - main_fuel_code=main_fuel_code, - water_heating_fuel_code=water_heating_fuel_code, - tariff=tariff, - ) + standing = _standing_charges_total_gbp( + epc, + main, + main_fuel_code=main_fuel_code, + water_heating_fuel_code=water_heating_fuel_code, + tariff=tariff, ) # Worksheet display convention: when a row's kWh is zero (no main 2, no