SAP 10.2 Appendix M1 §6 (p.94): "When calculating the fuel cost benefits ... apply the normal import electricity price to PV energy used within the dwelling and the 'electricity sold to grid, PV' price from Table 12 to the energy exported." Adds the third leg of the β-factor split (PE was S0380.45, CO2 was S0380.46). Now uniform across all three cascades: PE → IMPORT PEF × E_dw + EXPORT PEF × E_ex CO2 → IMPORT CO2 × E_dw + EXPORT CO2 × E_ex Cost → IMPORT £ × E_dw + EXPORT £ × E_ex Mechanism: - `worksheet/fuel_cost.py`: optional `pv_dwelling_kwh_per_yr` + `pv_exported_kwh_per_yr` + `pv_dwelling_import_price_gbp_per_kwh` keyword args; when all three are set, split the credit; otherwise fall back to legacy single-rate-EXPORT (preserves synthetic test constructions). - `rdsap/cert_to_inputs.py`: new `_pv_dwelling_import_price_gbp_per_kwh` helper that pulls Table 32 code 30 (standard electricity = 13.19 p/kWh) for standard tariff; off-peak branch uses `prices.e7_low_rate_p_per_kwh` as the natural extension point when the first off-peak PV cert lands (currently short-circuited by the `Tariff != STANDARD` guard at line 2710). - `calculator.py`: new `pv_dwelling_import_price_gbp_per_kwh` field on `CalculatorInputs` with synthetic-fallback split logic mirroring the precomputed-fuel_cost path. Maintains the cross-cascade architecture documented in the prior handover. Cohort impact: **none**. Per ADR-0010 RdSAP10 amendment, Table 32 collapses code 30 (standard electricity import) and code 60 (electricity sold to grid, PV) to the SAME 13.19 p/kWh rate. So the β-split's E_dw × 13.19 + E_ex × 13.19 == E_total × 13.19, matching the legacy single-rate credit at 1e-4 — 763 pass + 0 fail across the full chain test suite (Elmhurst U985, cohort-1 ASHP, cohort-2 38-cert sweep, 15-cert golden fixtures). The β-split shape is now in place for the off-peak case (where weighted Table 12a high/low rates would diverge) and any future amendment that splits import/export prices. Pyright net-zero on touched files (34 errors before, 34 after — all pre-existing). |
||
|---|---|---|
| .devcontainer | ||
| .github/workflows | ||
| .idea | ||
| .vscode | ||
| applications | ||
| asset_list | ||
| backend | ||
| backlog | ||
| datatypes | ||
| deployment/terraform | ||
| docs/adr | ||
| domain | ||
| epr_data_exports | ||
| etl | ||
| infrastructure | ||
| model_data/requirements | ||
| orchestration | ||
| recommendations | ||
| repositories | ||
| scripts | ||
| sfr/principal_pitch | ||
| survey_report | ||
| tests | ||
| utilities | ||
| utils | ||
| .coveragerc | ||
| .dockerignore | ||
| .gitignore | ||
| __init__.py | ||
| ara_backend_design.md | ||
| BaseUtility.py | ||
| CLAUDE.md | ||
| conftest.py | ||
| CONTEXT.md | ||
| devcontainer.sh | ||
| Dockerfile.test | ||
| Dockerfile.test.dockerignore | ||
| Makefile | ||
| MEMORY.md | ||
| package-lock.json | ||
| package.json | ||
| pyproject.toml | ||
| pyrightconfig.json | ||
| pytest.ini | ||
| README.md | ||
| run_lambda_local.sh | ||
| serverless.yml | ||
| test.requirements.txt | ||
| tox.ini | ||
| UBIQUITOUS_LANGUAGE.md | ||
Model Repository
This repository contains the code pertaining to the development of the data science and machine learning products being utilised by Hestia.
The different folders in this repository relate to services that can be used independently, or can be imported and used as part of a larger application
Getting Started
Prerequisites
Dev Container Setup
This repo uses a Docker Compose-based dev container. The model-backend service joins a shared-dev Docker network so it can communicate with other local services (e.g. a frontend container) running on your machine.
VS Code users: The initializeCommand in devcontainer.json creates the shared-dev network automatically before the container starts. No manual step required — just open the repo and select Reopen in Container.
Non-VS Code / CI workflows: Run the following once before starting the container:
make dev-setup
This is idempotent and safe to re-run if the network already exists.
Folders
backend/
This folder contains the code for the fastapi backend service, which provides an interface to much of the functionality in this repository, for the frontend
model_data/
This folder contains related to the reading and preparation of assessment model data, including pulling out epc attributes
Testing
All tests can be run, against the configuration in pytest.ini running
pytest
This will run the complete panel of tests and report on coverage in the locations specified by the pytest.ini file.
To run tests in a specific service, e.g. inside of model_data, simply run
pytest --cov-config=model_data/.coveragerc --cov=model_data
This will produce the test results and coverage reports