Commit da576535 authored by Eric Duminil's avatar Eric Duminil
Browse files

Consistent KPI case

parent 271511e2
......@@ -12,7 +12,7 @@ from .providers import Providers
@dataclass(repr=False)
class HeatDemandResults(SimStadtResults):
"""Results for Heat Demand (and Heat+Cool Demand) workflows."""
"""Results for Heat demand (and Heat+Cool demand) workflows."""
MAX_FLAT_ROOF_DIFFERENCE = 0.1 # [m]
TOTAL_DEMAND = "Total Yearly Heating + DHW demand"
......@@ -47,7 +47,7 @@ class HeatDemandResults(SimStadtResults):
custom_kpis.extend(
[
KPI("Number of heated buildings", heated_buildings, precision=0),
KPI("Specific Heating Demand", specific_heat_demand, "kWh / (m² · a)", precision=0),
KPI("Specific Heating demand", specific_heat_demand, "kWh / (m² · a)", precision=0),
]
)
sums.extend(
......@@ -59,7 +59,7 @@ class HeatDemandResults(SimStadtResults):
if df.attrs["Cooling"]:
specific_cooling_demand = df["Yearly Cooling demand"].sum() / df["Heated area"].sum()
custom_kpis.append(KPI("Specific Cooling Demand", specific_cooling_demand, "kWh / (m² · a)", precision=0))
custom_kpis.append(KPI("Specific Cooling demand", specific_cooling_demand, "kWh / (m² · a)", precision=0))
sums.append(("Yearly Cooling demand", "kWh / a"))
# TODO: rename to average year of construction?
......@@ -73,7 +73,7 @@ class HeatDemandResults(SimStadtResults):
rot=0,
ylabel="[MWh]",
width=0.8,
color={"Monthly Heating Demand": "darkred", "Monthly Cooling Demand": "darkblue"},
color={"Monthly Heating demand": "darkred", "Monthly Cooling demand": "darkblue"},
)
plt.savefig(heat_png, bbox_inches="tight", dpi=300)
plt.close(ax.figure)
......@@ -89,5 +89,5 @@ class HeatDemandResults(SimStadtResults):
col for col in df.columns if search_str in col and "Yearly" not in col and "Specific" not in col
]
if found_cols:
monthly_df[f"Monthly {mode} Demand"] = (df[found_cols].sum() / 1000).values
monthly_df[f"Monthly {mode} demand"] = (df[found_cols].sum() / 1000).values
return monthly_df
......@@ -86,7 +86,7 @@ def test_run_files_flag(mock_simstadt, run_cli, capsys, tmp_path):
out, _ = run_cli(capsys, HEAT_TEMPLATE, CITYGML, "-p", proj, "--files")
assert "Output files:" in out
assert "MiniBuchwald_hourly_demand.csv" in out
assert "Specific Heating Demand" in out
assert "Specific Heating demand" in out
assert "Mean Uvalue" in out
......
......@@ -103,7 +103,7 @@ def test_heating_kpis(heating_results):
assert kpis["Year of construction"].value == pytest.approx(1963, abs=0.5)
assert heating_results.kpi("Number of buildings").value == 24
assert heating_results.kpi("Number of buildings").unit is None
assert heating_results.kpi("Specific Heating Demand").value == pytest.approx(
assert heating_results.kpi("Specific Heating demand").value == pytest.approx(
100, abs=5
)
with pytest.raises(ValueError, match="No 'Not here' KPI found"):
......@@ -170,11 +170,11 @@ def test_heating_and_cooling_result_type(heating_and_cooling_results):
def test_heating_and_cooling_kpis(heating_and_cooling_results):
kpis = kpis_by_name(heating_and_cooling_results)
assert "Yearly Heating demand" in kpis
assert "Specific Heating Demand" in kpis
assert "Specific Heating demand" in kpis
assert "Yearly Cooling demand" in kpis
assert "Specific Cooling Demand" in kpis
assert "Specific Cooling demand" in kpis
assert heating_and_cooling_results.kpi(
"Specific Cooling Demand"
"Specific Cooling demand"
).value == pytest.approx(20, abs=1)
assert len(kpis) == 12
......@@ -207,11 +207,11 @@ def test_cooling_result_type(cooling_results):
def test_cooling_kpis(cooling_results):
kpis = kpis_by_name(cooling_results)
assert "Yearly Heating demand" not in kpis
assert "Specific Heating Demand" not in kpis
assert "Specific Heating demand" not in kpis
assert "Yearly Cooling demand" in kpis
assert "Specific Cooling Demand" in kpis
assert kpis["Specific Cooling Demand"].value == pytest.approx(20, abs=0.5)
assert kpis["Specific Cooling Demand"].unit == "kWh / (m² · a)"
assert "Specific Cooling demand" in kpis
assert kpis["Specific Cooling demand"].value == pytest.approx(20, abs=0.5)
assert kpis["Specific Cooling demand"].unit == "kWh / (m² · a)"
assert len(kpis) == 8
......
......@@ -32,8 +32,8 @@ def test_heat_demand():
assert "Yearly Heating demand" in kpis
assert kpis["Yearly Heating demand"].value > 0
assert kpis["Yearly Heating demand"].unit == "kWh / a"
assert kpis["Specific Heating Demand"].value == pytest.approx(100, abs=30)
assert kpis["Specific Heating Demand"].unit == "kWh / (m² · a)"
assert kpis["Specific Heating demand"].value == pytest.approx(100, abs=30)
assert kpis["Specific Heating demand"].unit == "kWh / (m² · a)"
assert kpis["Mean Uvalue"].value == pytest.approx(1, abs=0.2)
assert kpis["Mean Uvalue"].unit == "W / (m² · K)"
assert kpis["Year of construction"].value == pytest.approx(1950, abs=50)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment