Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SimStadt
simstadtpy
Commits
da576535
Commit
da576535
authored
May 16, 2026
by
Eric Duminil
Browse files
Consistent KPI case
parent
271511e2
Changes
4
Show whitespace changes
Inline
Side-by-side
src/simstadt/results/heat_demand.py
View file @
da576535
...
@@ -12,7 +12,7 @@ from .providers import Providers
...
@@ -12,7 +12,7 @@ from .providers import Providers
@
dataclass
(
repr
=
False
)
@
dataclass
(
repr
=
False
)
class
HeatDemandResults
(
SimStadtResults
):
class
HeatDemandResults
(
SimStadtResults
):
"""Results for Heat
D
emand (and Heat+Cool
D
emand) workflows."""
"""Results for Heat
d
emand (and Heat+Cool
d
emand) workflows."""
MAX_FLAT_ROOF_DIFFERENCE
=
0.1
# [m]
MAX_FLAT_ROOF_DIFFERENCE
=
0.1
# [m]
TOTAL_DEMAND
=
"Total Yearly Heating + DHW demand"
TOTAL_DEMAND
=
"Total Yearly Heating + DHW demand"
...
@@ -47,7 +47,7 @@ class HeatDemandResults(SimStadtResults):
...
@@ -47,7 +47,7 @@ class HeatDemandResults(SimStadtResults):
custom_kpis
.
extend
(
custom_kpis
.
extend
(
[
[
KPI
(
"Number of heated buildings"
,
heated_buildings
,
precision
=
0
),
KPI
(
"Number of heated buildings"
,
heated_buildings
,
precision
=
0
),
KPI
(
"Specific Heating
D
emand"
,
specific_heat_demand
,
"kWh / (m² · a)"
,
precision
=
0
),
KPI
(
"Specific Heating
d
emand"
,
specific_heat_demand
,
"kWh / (m² · a)"
,
precision
=
0
),
]
]
)
)
sums
.
extend
(
sums
.
extend
(
...
@@ -59,7 +59,7 @@ class HeatDemandResults(SimStadtResults):
...
@@ -59,7 +59,7 @@ class HeatDemandResults(SimStadtResults):
if
df
.
attrs
[
"Cooling"
]:
if
df
.
attrs
[
"Cooling"
]:
specific_cooling_demand
=
df
[
"Yearly Cooling demand"
].
sum
()
/
df
[
"Heated area"
].
sum
()
specific_cooling_demand
=
df
[
"Yearly Cooling demand"
].
sum
()
/
df
[
"Heated area"
].
sum
()
custom_kpis
.
append
(
KPI
(
"Specific Cooling
D
emand"
,
specific_cooling_demand
,
"kWh / (m² · a)"
,
precision
=
0
))
custom_kpis
.
append
(
KPI
(
"Specific Cooling
d
emand"
,
specific_cooling_demand
,
"kWh / (m² · a)"
,
precision
=
0
))
sums
.
append
((
"Yearly Cooling demand"
,
"kWh / a"
))
sums
.
append
((
"Yearly Cooling demand"
,
"kWh / a"
))
# TODO: rename to average year of construction?
# TODO: rename to average year of construction?
...
@@ -73,7 +73,7 @@ class HeatDemandResults(SimStadtResults):
...
@@ -73,7 +73,7 @@ class HeatDemandResults(SimStadtResults):
rot
=
0
,
rot
=
0
,
ylabel
=
"[MWh]"
,
ylabel
=
"[MWh]"
,
width
=
0.8
,
width
=
0.8
,
color
=
{
"Monthly Heating
D
emand"
:
"darkred"
,
"Monthly Cooling
D
emand"
:
"darkblue"
},
color
=
{
"Monthly Heating
d
emand"
:
"darkred"
,
"Monthly Cooling
d
emand"
:
"darkblue"
},
)
)
plt
.
savefig
(
heat_png
,
bbox_inches
=
"tight"
,
dpi
=
300
)
plt
.
savefig
(
heat_png
,
bbox_inches
=
"tight"
,
dpi
=
300
)
plt
.
close
(
ax
.
figure
)
plt
.
close
(
ax
.
figure
)
...
@@ -89,5 +89,5 @@ class HeatDemandResults(SimStadtResults):
...
@@ -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
col
for
col
in
df
.
columns
if
search_str
in
col
and
"Yearly"
not
in
col
and
"Specific"
not
in
col
]
]
if
found_cols
:
if
found_cols
:
monthly_df
[
f
"Monthly
{
mode
}
D
emand"
]
=
(
df
[
found_cols
].
sum
()
/
1000
).
values
monthly_df
[
f
"Monthly
{
mode
}
d
emand"
]
=
(
df
[
found_cols
].
sum
()
/
1000
).
values
return
monthly_df
return
monthly_df
tests/test_cli.py
View file @
da576535
...
@@ -86,7 +86,7 @@ def test_run_files_flag(mock_simstadt, run_cli, capsys, tmp_path):
...
@@ -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"
)
out
,
_
=
run_cli
(
capsys
,
HEAT_TEMPLATE
,
CITYGML
,
"-p"
,
proj
,
"--files"
)
assert
"Output files:"
in
out
assert
"Output files:"
in
out
assert
"MiniBuchwald_hourly_demand.csv"
in
out
assert
"MiniBuchwald_hourly_demand.csv"
in
out
assert
"Specific Heating
D
emand"
in
out
assert
"Specific Heating
d
emand"
in
out
assert
"Mean Uvalue"
in
out
assert
"Mean Uvalue"
in
out
...
...
tests/test_results.py
View file @
da576535
...
@@ -103,7 +103,7 @@ def test_heating_kpis(heating_results):
...
@@ -103,7 +103,7 @@ def test_heating_kpis(heating_results):
assert
kpis
[
"Year of construction"
].
value
==
pytest
.
approx
(
1963
,
abs
=
0.5
)
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"
).
value
==
24
assert
heating_results
.
kpi
(
"Number of buildings"
).
unit
is
None
assert
heating_results
.
kpi
(
"Number of buildings"
).
unit
is
None
assert
heating_results
.
kpi
(
"Specific Heating
D
emand"
).
value
==
pytest
.
approx
(
assert
heating_results
.
kpi
(
"Specific Heating
d
emand"
).
value
==
pytest
.
approx
(
100
,
abs
=
5
100
,
abs
=
5
)
)
with
pytest
.
raises
(
ValueError
,
match
=
"No 'Not here' KPI found"
):
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):
...
@@ -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
):
def
test_heating_and_cooling_kpis
(
heating_and_cooling_results
):
kpis
=
kpis_by_name
(
heating_and_cooling_results
)
kpis
=
kpis_by_name
(
heating_and_cooling_results
)
assert
"Yearly Heating demand"
in
kpis
assert
"Yearly Heating demand"
in
kpis
assert
"Specific Heating
D
emand"
in
kpis
assert
"Specific Heating
d
emand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
assert
"Specific Cooling
D
emand"
in
kpis
assert
"Specific Cooling
d
emand"
in
kpis
assert
heating_and_cooling_results
.
kpi
(
assert
heating_and_cooling_results
.
kpi
(
"Specific Cooling
D
emand"
"Specific Cooling
d
emand"
).
value
==
pytest
.
approx
(
20
,
abs
=
1
)
).
value
==
pytest
.
approx
(
20
,
abs
=
1
)
assert
len
(
kpis
)
==
12
assert
len
(
kpis
)
==
12
...
@@ -207,11 +207,11 @@ def test_cooling_result_type(cooling_results):
...
@@ -207,11 +207,11 @@ def test_cooling_result_type(cooling_results):
def
test_cooling_kpis
(
cooling_results
):
def
test_cooling_kpis
(
cooling_results
):
kpis
=
kpis_by_name
(
cooling_results
)
kpis
=
kpis_by_name
(
cooling_results
)
assert
"Yearly Heating demand"
not
in
kpis
assert
"Yearly Heating demand"
not
in
kpis
assert
"Specific Heating
D
emand"
not
in
kpis
assert
"Specific Heating
d
emand"
not
in
kpis
assert
"Yearly Cooling demand"
in
kpis
assert
"Yearly Cooling demand"
in
kpis
assert
"Specific Cooling
D
emand"
in
kpis
assert
"Specific Cooling
d
emand"
in
kpis
assert
kpis
[
"Specific Cooling
D
emand"
].
value
==
pytest
.
approx
(
20
,
abs
=
0.5
)
assert
kpis
[
"Specific Cooling
d
emand"
].
value
==
pytest
.
approx
(
20
,
abs
=
0.5
)
assert
kpis
[
"Specific Cooling
D
emand"
].
unit
==
"kWh / (m² · a)"
assert
kpis
[
"Specific Cooling
d
emand"
].
unit
==
"kWh / (m² · a)"
assert
len
(
kpis
)
==
8
assert
len
(
kpis
)
==
8
...
...
tests/test_simulations.py
View file @
da576535
...
@@ -32,8 +32,8 @@ def test_heat_demand():
...
@@ -32,8 +32,8 @@ def test_heat_demand():
assert
"Yearly Heating demand"
in
kpis
assert
"Yearly Heating demand"
in
kpis
assert
kpis
[
"Yearly Heating demand"
].
value
>
0
assert
kpis
[
"Yearly Heating demand"
].
value
>
0
assert
kpis
[
"Yearly Heating demand"
].
unit
==
"kWh / a"
assert
kpis
[
"Yearly Heating demand"
].
unit
==
"kWh / a"
assert
kpis
[
"Specific Heating
D
emand"
].
value
==
pytest
.
approx
(
100
,
abs
=
30
)
assert
kpis
[
"Specific Heating
d
emand"
].
value
==
pytest
.
approx
(
100
,
abs
=
30
)
assert
kpis
[
"Specific Heating
D
emand"
].
unit
==
"kWh / (m² · a)"
assert
kpis
[
"Specific Heating
d
emand"
].
unit
==
"kWh / (m² · a)"
assert
kpis
[
"Mean Uvalue"
].
value
==
pytest
.
approx
(
1
,
abs
=
0.2
)
assert
kpis
[
"Mean Uvalue"
].
value
==
pytest
.
approx
(
1
,
abs
=
0.2
)
assert
kpis
[
"Mean Uvalue"
].
unit
==
"W / (m² · K)"
assert
kpis
[
"Mean Uvalue"
].
unit
==
"W / (m² · K)"
assert
kpis
[
"Year of construction"
].
value
==
pytest
.
approx
(
1950
,
abs
=
50
)
assert
kpis
[
"Year of construction"
].
value
==
pytest
.
approx
(
1950
,
abs
=
50
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment