from pathlib import Path import sys import pandas as pd import pytest SCRIPTS = Path(__file__).resolve().parents[1] / "scripts" sys.path.insert(0, str(SCRIPTS)) from heat_profiles import ( # noqa: E402 HeatArchetype, build_hourly_profile, estimate_annual_heat_mwh, load_archetypes, ) ARCHETYPE = HeatArchetype( sink_class="hospital", annual_heat_kwh_m2=420, base_fraction=0.55, balance_temp_c=16, supply_temp_c=70, return_temp_c=50, uncertainty_fraction=0.30, ) def test_area_and_eui_create_bounded_annual_estimate(): result = estimate_annual_heat_mwh(10_000, ARCHETYPE) assert result.mid_mwh == 4200 assert result.low_mwh == 2940 assert result.high_mwh == 5460 def test_hourly_profile_sums_to_annual_energy_and_preserves_base_load(): temperatures = pd.Series([-20.0] * 4380 + [20.0] * 4380) profile = build_hourly_profile(4200, temperatures, ARCHETYPE) assert profile.sum() / 1000 == pytest.approx(4200) assert profile.min() > 0 assert profile.iloc[0] > profile.iloc[-1] def test_reference_file_loads_all_required_archetypes(): path = Path(__file__).resolve().parents[1] / "data_reference/heat_archetypes.csv" archetypes = load_archetypes(path) assert set(archetypes) == { "hospital", "campus", "murb", "greenhouse", "food_processing", "industrial", "municipal", "district_network", }