Skip to content

Commit

Permalink
Merge pull request #55 from ddceruti/dev
Browse files Browse the repository at this point in the history
Improve error handling for non-residential shlp type
  • Loading branch information
p-snft authored Jun 25, 2024
2 parents 5cb5784 + a8e869f commit 00452ca
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Authors

(alphabetic order)

* Amedeo Ceruti
* Birgit Schachler
* Caroline Möller
* Guido Plessmann
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ New features

Bug fixes
#########
*
* Raise error for non supported shlp_type
in non-commercial buildings

Other changes
#############
* Adhere to packaging standards
* Raise errors in sigmoid parameter queries


v0.1.9 (2023-03-18)
Expand Down
31 changes: 25 additions & 6 deletions src/demandlib/bdew/heat_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class HeatBuilding:
annual_heat_demand : float
annual heat demand of building in kWh
building_class: int
class of building according to bdew classification
possible numbers are: 1 - 11
class of building according to bdew classification:
possible numbers for EFH and MFH are: 1 - 11.
Possible numbers for non-residential buildings are: 0.
shlp_type : string
type of standardized heat load profile according to bdew
possible types are:
Expand All @@ -62,6 +63,11 @@ def __init__(self, df_index, **kwargs):
self.shlp_type = kwargs.get("shlp_type").upper()
self.wind_class = kwargs.get("wind_class")
self.building_class = kwargs.get("building_class", 0)
# raise error if building class is not 0 for non-residential buildings
if (self.shlp_type not in ["EFH", "MFH"]) and (self.building_class != 0):
raise ValueError(
"Building class must be 0 for non-residential buildings"
)
self.ww_incl = kwargs.get("ww_incl", True)
self.name = kwargs.get("name", self.shlp_type)

Expand Down Expand Up @@ -268,11 +274,24 @@ def get_sigmoid_parameters(self, filename="shlp_sigmoid_factors.csv"):
+ "wind_impact=={0}".format(self.wind_class)
)

a = float(sigmoid["parameter_a"])
b = float(sigmoid["parameter_b"])
c = float(sigmoid["parameter_c"])
wrong_number_of_parameters_message = (
"{} sigmoid parameters found for "
+ f"building_class={self.building_class}, shlp_type={self.shlp_type}, "
+ f"wind_class={self.wind_class}. Should be 1."
)

# check if it does not find one row of sigmoid parameters
if len(sigmoid) != 1:
raise ValueError(
wrong_number_of_parameters_message.format(len(sigmoid))
)

# get sigmoid parameters, avoid warning
a = sigmoid["parameter_a"].iloc[0]
b = sigmoid["parameter_b"].iloc[0]
c = sigmoid["parameter_c"].iloc[0]
if self.ww_incl:
d = float(sigmoid["parameter_d"])
d = sigmoid["parameter_d"].iloc[0]
else:
d = 0
return a, b, c, d
Expand Down

0 comments on commit 00452ca

Please sign in to comment.