config — Building Configuration
- Source:
buem/config/
Purpose
Ingests a building description (JSON dict or API payload), fills in defaults for every missing attribute, validates the result, and exposes it to the thermal model as a normalised Python object.
Key Components
cfg_attribute.py — Attribute Definitions
Defines 250 + building attributes in the ATTRIBUTE_SPECS dictionary.
Each entry specifies:
category — WEATHER, FIXED, BOOLEAN, or OTHER
type — FLOAT, INT, BOOL, STR, SERIES, DATAFRAME, OBJECT, LIST
default — a sensible fallback (e.g. A_ref = 100 m², comfortT_lb = 21 °C)
Selected attributes:
Attribute |
Category |
Type |
Default / Notes |
|---|---|---|---|
|
WEATHER |
DataFrame |
8760 h (T, GHI, DNI, DHI), Loenen NL |
|
OTHER |
OBJECT |
Hierarchical envelope (Walls, Roof, Floor, Windows, Doors, Ventilation) |
|
FIXED |
FLOAT |
100.0 m² |
|
FIXED |
STR |
|
|
FIXED |
FLOAT |
175.0 kJ/(m² K) |
|
FIXED |
FLOAT |
21.0 / 24.0 °C |
|
FIXED |
FLOAT |
0.5 |
|
FIXED |
SERIES |
Auto-generated from |
|
BOOLEAN |
BOOL |
Active configuration flags |
Electricity and occupancy profiles are generated automatically when not supplied by the caller.
cfg_building.py — Configuration Container
Main entry point for consumers:
CfgBuilding(cfg_dict)Accepts a raw JSON/dict payload. Normalises it using ATTRIBUTE_SPECS defaults, converts serialisable dicts to pandas objects, and exposes
to_cfg_dict()/to_serializable()for downstream use.
Helper dataclasses: WeatherConfig, BooleanConfig, FixedConfig.
validator.py — Configuration Validator
validate_cfg(cfg_dict) → list[str]
Returns an empty list when the configuration is valid. Checks include:
componentstree present (not legacyA_*keys)Per-component U > 0 or per-element U provided
Element areas > 0 and unique IDs
Weather timeseries length consistent (8760 h)
Attribute Precedence
When the API receives a request, attributes are resolved in this order:
API payload (highest priority)
Database (if a
building_idis provided)ATTRIBUTE_SPECS defaults (lowest priority)
Components Structure
The components attribute follows this hierarchy:
components
├── Walls → U [W/(m²K)], b_transmission, elements[{id, area, azimuth, tilt}]
├── Roof → U, elements[{id, area, azimuth, tilt}]
├── Floor → U, elements[{id, area}]
├── Windows → U, g_gl, elements[{id, area, azimuth, tilt, surface_ref}]
├── Doors → U, elements[{id, area, surface_ref}]
└── Ventilation → elements[{id, air_changes}]
Orientations use azimuth 0–360° (0 = North, clockwise) and tilt 0–90° (0 = horizontal, 90 = vertical).