Contains projects associated to the development of modeling products
Find a file
Khalim Conn-Kowlessar 637df557bb Slice S0380.113: H=0 gable lodgement deducts per RdSAP 10 §3.9.2 step (b)
RdSAP 10 §3.9.2 step (b) (PDF p.23) verbatim:

  "Software calculates the area of each gable or adjacent wall by
  using the equation:
         A_RR_gable = L_gable × (0.25 + H_gable) − [(H_gable − H_common_1)² / 2
                                                   + (H_gable − H_common_2)² / 2]"

Step (d):
  A_RR_final = A_RR_wall − (Σ A_common + Σ A_gable + Σ A_party
                            + Σ A_sheltered + Σ A_connected)

The spec equation is signed and applies for all L > 0 — including
H_gable = 0. When the gable is shorter than the common walls the
correction term `(H_gable − H_common)² / 2` exceeds the
L × (0.25 + H_gable) term, producing a negative A_RR_gable.
Elmhurst's worksheet evaluates the equation literally; the negative
value adjusts A_RR_final upward via step (d) without billing a
physical wall area.

Cert 000565 §8.1 lodges Ext3's RR (Simplified Type 2) with an
absent Gable Wall 2:

  Gable Wall 1   L=9.00  H=7.00   Exposed     U=0.45
  Gable Wall 2   L=4.00  H=0.00               U=0.00   ← lodged but H=0
  Common Wall 1  L=5.00  H=1.50               U=0.45
  Common Wall 2  L=7.50  H=0.30               U=0.45

Spec equation for Gable Wall 2:
  A_gable_2 = 4 × (0.25 + 0) − (0 − 1.5)²/2 − (0 − 0.30)²/2
            = 1.0 − 1.125 − 0.045 = −0.17 m²

Worksheet (30) Ext3 residual = 17.35 m² back-solves exactly:
  A_RR_shell = 12.5 × √(32.0 / 1.5)                = 57.7350
  Σ walls (incl. -0.17 absent gable)               = 40.3850
  residual = shell − walls                         = 17.3500  ✓ 4 d.p.

Pre-slice the mapper had two clamps that together dropped the
spec-computed −0.17 m² adjustment:

  mapper.py:3350  `if length_m <= 0 or height_m <= 0: return None`
                  → filtered out any H=0 surface
  mapper.py:3443  `area_m2 = max(0.0, length_m * (0.25 + H) − correction)`
                  → clamped negative gable areas at 0

Combined the cascade computed residual = 17.18 m² (cascade UNDER
by 0.17). Plus a related secondary `if height_m > h` filter on the
correction sum that masked the all-common-walls-taller case.

3-layer fix:

1. `datatypes/epc/domain/mapper.py` `_map_elmhurst_rir_surface`:
   - Split the early-return filter: drop only when L<=0 (no wall),
     OR when H<=0 AND not (Simplified Type 2 with common walls).
   - Apply the spec gable-area formula to BOTH `gable_wall` (party
     default) and `gable_wall_external` kinds in Simplified Type 2
     (the U-value routing differs by kind, but the area equation
     is the same).
   - Remove `max(0.0, ...)` clamp so the signed result reaches the
     cascade.
   - Remove `if height_m > h` correction-sum filter (spec applies
     the full square unconditionally).

2. `domain/sap10_calculator/worksheet/heat_transmission.py` per-
   surface loop:
   - `gable_wall` branch: skip `party += 0.25 × area` when area < 0
     (wall doesn't exist physically) but still add the signed area
     to `rr_walls_in_a_rr_area` so the residual deduction in step (d)
     grows by |area|.
   - `gable_wall_external` branch: same skip pattern for `walls +=
     u × area` and `rr_detailed_area += area`.

Cohort safety: only cert 000565 Ext3 hits this in the corpus. All
other cohort certs are Type 1 RR (no common walls, formula gives
the same answer) or have all gables H > 0. The cascade's per-element
test pins (Ext1's Connected gable + Exposed gable, Ext4's Detailed
RR) unchanged.

Cert 000565 cascade snapshot (HEAD a461b70d → this):
  roof_w_per_k         51.3185 → 51.3768  ✓ EXACT (Δ -0.06 → -0.003)
  total_external_area 857.46  → 857.6323  ✓ EXACT (Δ -0.18 → -0.008)
  thermal_bridging    128.62  → 128.6448  ✓ EXACT (Δ -0.03 → -0.005)
  total_w_per_k       936.97  → 937.0563  ✓ EXACT (Δ -0.09 → -0.004)

  sap_score (int)         29 ✓ EXACT (preserved)
  sap_score_continuous 28.5027 → 28.5007 (Δ -0.0060 → -0.0080)
  ecf                   5.3877 →  5.3876
  total_fuel_cost_gbp  4681.01 → 4680.97
  co2_kg_per_yr        6448.59 → 6448.53
  space_heating_kwh   59019.21 → 59018.52
  main_heating_fuel   34715.31 → 34716.78

**Cert 000565 fabric cascade now essentially exact** (HTC −0.004 W/K
total residual across all 8 fabric components). The remaining
continuous SAP -0.0080 / cost +£0.71 / SH +10 kWh residuals come
from non-fabric upstream (likely ventilation or appliances) —
candidates for a future audit.

Pyright net-zero (57 → 57 errors across touched files).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 16:28:47 +00:00
.devcontainer pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
.github/workflows added landlord description overrides 2026-05-29 12:12:54 +00:00
.idea scaffolding for ml pipeline 2026-05-16 14:15:56 +00:00
.vscode added utils to allow easier subtask management 2026-03-02 15:15:39 +00:00
applications move landlord overrides 2026-06-01 15:46:46 +00:00
asset_list redeploy old postcode splitter 2026-05-21 09:46:47 +00:00
backend Slice S0380.113: H=0 gable lodgement deducts per RdSAP 10 §3.9.2 step (b) 2026-06-01 16:28:47 +00:00
backlog implemented onboarding 2026-04-21 20:23:33 +00:00
datatypes Slice S0380.113: H=0 gable lodgement deducts per RdSAP 10 §3.9.2 step (b) 2026-06-01 16:28:47 +00:00
deployment/terraform added landlord description overrides 2026-05-29 12:12:54 +00:00
docs/adr move landlord overrides 2026-06-01 15:46:46 +00:00
domain Slice S0380.113: H=0 gable lodgement deducts per RdSAP 10 §3.9.2 step (b) 2026-06-01 16:28:47 +00:00
epr_data_exports allowing carbon and energy otimisation by removing slack 2025-07-31 19:13:16 +01:00
etl booking status 2026-06-01 16:28:47 +00:00
infrastructure GoogleSolarApiClient raises BuildingInsightsNotFoundError on 404 entity-not-found 🟩 2026-06-01 16:28:47 +00:00
model_data/requirements its working the way khalim wanted wiht postcode and then search that 2026-01-22 15:17:13 +00:00
orchestration moved classifier data transformation to an easy one 2026-06-01 14:53:34 +00:00
recommendations save 2026-05-07 15:55:44 +00:00
repositories move landlord overrides 2026-06-01 15:46:46 +00:00
scripts Slice S0380.39: bulk-fetch 38 cohort-2 EPC API JSONs for cross-mapper parity 2026-06-01 16:28:47 +00:00
sfr/principal_pitch added added historic epc data class with shape 2026-05-08 12:03:35 +00:00
survey_report quidos site notes extraction 2025-02-18 19:49:29 +00:00
tests GoogleSolarApi translates BuildingInsightsNotFoundError to sentinel dict 🟩 2026-06-01 16:28:47 +00:00
utilities get rid of comments 2026-05-20 13:21:11 +00:00
utils rename files in sharepoint to desired structure 2026-05-20 16:26:07 +00:00
.coveragerc fixed unit tests 2023-10-05 16:04:12 +01:00
.dockerignore deployment from infrastructure 2026-05-19 12:55:30 +00:00
.gitignore fixed merge conflicts from main 2026-05-26 11:21:09 +00:00
__init__.py added checking for directory before creation and made some minor style changes 2023-08-25 15:21:17 +01:00
ara_backend_design.md refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
BaseUtility.py fixed missing task and subtask for single remote assessments 2025-11-27 17:50:26 +00:00
CLAUDE.md fixed merge conflicts from main 2026-05-26 11:21:09 +00:00
conftest.py working on integrating new EPC api into address2UPRN 2026-04-27 11:32:44 +00:00
CONTEXT.md refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
devcontainer.sh add dev container 2026-04-17 14:50:57 +00:00
Dockerfile.test fix: address 22 project-wide test failures from previous sweep 2026-05-26 13:34:51 +00:00
Dockerfile.test.dockerignore deployment from infrastructure 2026-05-19 12:55:30 +00:00
Makefile adding to dev container to create shared network on start up 2026-04-25 15:03:07 +00:00
MEMORY.md memory 2026-04-02 10:24:31 +00:00
package-lock.json restructuring openUrpn code 2023-07-20 11:41:43 +01:00
package.json restructuring openUrpn code 2023-07-20 11:41:43 +01:00
pyproject.toml slice 14a: ml_training_data pkg + sample.py (CSV filter + random sample) 2026-05-16 17:39:43 +00:00
pyrightconfig.json slice 14d: build_features wires bulk reader -> mapper -> EpcMlTransform 2026-05-16 18:38:41 +00:00
pytest.ini refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
README.md adding to dev container to create shared network on start up 2026-04-25 15:03:07 +00:00
run_lambda_local.sh debugging local lambda run and updating the sap point checking condition 2023-09-13 18:47:12 +01:00
serverless.yml added logic to add to serverless 2026-04-22 12:39:44 +00:00
test.requirements.txt tests wrong environemnt 2026-05-29 16:17:06 +00:00
tox.ini removing playright install for integration test 2026-04-30 20:08:13 +00:00
UBIQUITOUS_LANGUAGE.md postcode_splitter: pure domain (UserAddress, sanitise_postcode, postcode_batching) 2026-05-19 16:45:47 +00:00

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