Coverage for teaser/data/utilities.py: 93%

103 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2025-04-29 16:01 +0000

1"""This module provides the definitions and mappings for various building archetypes and construction standards 

2used in the TEASER framework. The module includes enumerations for different geometry types of buildings and 

3construction data types, as well as dictionaries that map these enumerations to their corresponding building classes. 

4Additionally, it defines which construction data types are allowed for each building geometry data and 

5includes functions to set the suitable construction_data.""" 

6from enum import Enum 

7from teaser.logic.archetypebuildings.bmvbs.office import Office 

8from teaser.logic.archetypebuildings.bmvbs.custom.institute import Institute 

9from teaser.logic.archetypebuildings.bmvbs.custom.institute4 import Institute4 

10from teaser.logic.archetypebuildings.bmvbs.custom.institute8 import Institute8 

11from teaser.logic.archetypebuildings.urbanrenet.est1a import EST1a 

12from teaser.logic.archetypebuildings.urbanrenet.est1b import EST1b 

13from teaser.logic.archetypebuildings.urbanrenet.est2 import EST2 

14from teaser.logic.archetypebuildings.urbanrenet.est3 import EST3 

15from teaser.logic.archetypebuildings.urbanrenet.est4a import EST4a 

16from teaser.logic.archetypebuildings.urbanrenet.est4b import EST4b 

17from teaser.logic.archetypebuildings.urbanrenet.est5 import EST5 

18from teaser.logic.archetypebuildings.urbanrenet.est6 import EST6 

19from teaser.logic.archetypebuildings.urbanrenet.est7 import EST7 

20from teaser.logic.archetypebuildings.urbanrenet.est8a import EST8a 

21from teaser.logic.archetypebuildings.urbanrenet.est8b import EST8b 

22from teaser.logic.archetypebuildings.tabula.de.singlefamilyhouse import ( 

23 SingleFamilyHouse, 

24) 

25from teaser.logic.archetypebuildings.tabula.dk.singlefamilyhouse import ( 

26 SingleFamilyHouse as SingleFamilyHouse_DK, 

27) 

28from teaser.logic.archetypebuildings.tabula.de.terracedhouse import TerracedHouse 

29from teaser.logic.archetypebuildings.tabula.dk.terracedhouse import ( 

30 TerracedHouse as TerracedHouse_DK, 

31) 

32from teaser.logic.archetypebuildings.tabula.de.multifamilyhouse import MultiFamilyHouse 

33from teaser.logic.archetypebuildings.tabula.de.apartmentblock import ApartmentBlock 

34from teaser.logic.archetypebuildings.tabula.dk.apartmentblock import ( 

35 ApartmentBlock as ApartmentBlock_DK, 

36) 

37from teaser.logic.archetypebuildings.bmvbs.singlefamilydwelling import ( 

38 SingleFamilyDwelling, 

39) 

40 

41 

42class GeometryData(Enum): 

43 """ 

44 The GeometryData enumeration replaces the former parameter "usage" and 

45 represents different archetypes of residential and non-residential buildings. 

46 """ 

47 IwuSingleFamilyDwelling = "iwu_single_family_dwelling" 

48 

49 TabulaDeSingleFamilyHouse = "tabula_de_single_family_house" 

50 TabulaDeTerracedHouse = "tabula_de_terraced_house" 

51 TabulaDeMultiFamilyHouse = "tabula_de_multi_family_house" 

52 TabulaDeApartmentBlock = "tabula_de_apartment_block" 

53 

54 TabulaDkSingleFamilyHouse = "tabula_dk_single_family_house" 

55 TabulaDkTerracedHouse = "tabula_dk_terraced_house" 

56 TabulaDkApartmentBlock = "tabula_dk_apartment_block" 

57 

58 BmvbsOffice = "bmvbs_office" 

59 BmvbsInstitute = "bmvbs_institute" 

60 BmvbsInstitute4 = "bmvbs_institute4" 

61 BmvbsInstitute8 = "bmvbs_institute8" 

62 

63 UrbanrenetEst1a = "urbanrenet_est1a" 

64 UrbanrenetEst1b = "urbanrenet_est1b" 

65 UrbanrenetEst2 = "urbanrenet_est2" 

66 UrbanrenetEst3 = "urbanrenet_est3" 

67 UrbanrenetEst4a = "urbanrenet_est4a" 

68 UrbanrenetEst4b = "urbanrenet_est4b" 

69 UrbanrenetEst5 = "urbanrenet_est5" 

70 UrbanrenetEst6 = "urbanrenet_est6" 

71 UrbanrenetEst7 = "urbanrenet_est7" 

72 UrbanrenetEst8a = "urbanrenet_est8a" 

73 UrbanrenetEst8b = "urbanrenet_est8b" 

74 

75class ConstructionData(Enum): 

76 """ 

77 The ConstructionData enumeration combines the former parameters “method” and “construction_type”. 

78 The prefix of each value is used to select the appropriate json file as input data. 

79 The complete value is used to search for the appropriate element within the json file. 

80 """ 

81 iwu_heavy = "iwu_heavy" 

82 iwu_light = "iwu_light" 

83 tabula_de_standard = "tabula_de_standard" 

84 tabula_de_retrofit = "tabula_de_retrofit" 

85 tabula_de_adv_retrofit = "tabula_de_adv_retrofit" 

86 tabula_dk_standard = "tabula_dk_standard" 

87 tabula_dk_retrofit = "tabula_dk_retrofit" 

88 tabula_dk_adv_retrofit = "tabula_dk_adv_retrofit" 

89 kfw_40 = "kfw_40" 

90 kfw_55 = "kfw_55" 

91 kfw_70 = "kfw_70" 

92 kfw_85 = "kfw_85" 

93 kfw_100 = "kfw_100" 

94 

95 def get_prefix(self): 

96 parts = self.value.split("_", 2) 

97 if len(parts) == 2: 

98 return parts[0] 

99 elif len(parts) == 3: 

100 return "_".join(parts[:2]) 

101 else: 

102 return self.value 

103 def is_iwu(self): 

104 return self.get_prefix() == "iwu" 

105 

106 def is_tabula_de(self): 

107 return self.get_prefix() == "tabula_de" 

108 

109 def is_tabula_dk(self): 

110 return self.get_prefix() == "tabula_dk" 

111 

112 def is_kfw(self): 

113 return self.get_prefix() == "kfw" 

114 

115# Dictionary that maps GeometryData enumeration values to their corresponding building classes. 

116geometries = { 

117 #non residential: 

118 #BMVBS 

119 GeometryData.BmvbsOffice: Office, 

120 GeometryData.BmvbsInstitute: Institute, 

121 GeometryData.BmvbsInstitute4: Institute4, 

122 GeometryData.BmvbsInstitute8: Institute8, 

123 

124 #residential: 

125 #IWU 

126 GeometryData.IwuSingleFamilyDwelling: SingleFamilyDwelling, 

127 #Tabula DE 

128 GeometryData.TabulaDeSingleFamilyHouse: SingleFamilyHouse, 

129 GeometryData.TabulaDeTerracedHouse: TerracedHouse, 

130 GeometryData.TabulaDeMultiFamilyHouse: MultiFamilyHouse, 

131 GeometryData.TabulaDeApartmentBlock: ApartmentBlock, 

132 #Tabula DK 

133 GeometryData.TabulaDkSingleFamilyHouse: SingleFamilyHouse_DK, 

134 GeometryData.TabulaDkTerracedHouse: TerracedHouse_DK, 

135 GeometryData.TabulaDkApartmentBlock: ApartmentBlock_DK, 

136 #Urbanrenet 

137 GeometryData.UrbanrenetEst1a: EST1a, 

138 GeometryData.UrbanrenetEst1b: EST1b, 

139 GeometryData.UrbanrenetEst2: EST2, 

140 GeometryData.UrbanrenetEst3: EST3, 

141 GeometryData.UrbanrenetEst4a: EST4a, 

142 GeometryData.UrbanrenetEst4b: EST4b, 

143 GeometryData.UrbanrenetEst5: EST5, 

144 GeometryData.UrbanrenetEst6: EST6, 

145 GeometryData.UrbanrenetEst7: EST7, 

146 GeometryData.UrbanrenetEst8a: EST8a, 

147 GeometryData.UrbanrenetEst8b: EST8b, 

148} 

149 

150# Dictionary that defines which building geometries are allowed for each construction data type. 

151allowed_geometries = { 

152 ConstructionData.iwu_heavy: [GeometryData.IwuSingleFamilyDwelling, GeometryData.BmvbsOffice, 

153 GeometryData.BmvbsInstitute, GeometryData.BmvbsInstitute4, 

154 GeometryData.BmvbsInstitute8, GeometryData.UrbanrenetEst1a, 

155 GeometryData.UrbanrenetEst1b, GeometryData.UrbanrenetEst2, 

156 GeometryData.UrbanrenetEst3, GeometryData.UrbanrenetEst4a, 

157 GeometryData.UrbanrenetEst4b, GeometryData.UrbanrenetEst5, 

158 GeometryData.UrbanrenetEst6, GeometryData.UrbanrenetEst7, 

159 GeometryData.UrbanrenetEst8a, GeometryData.UrbanrenetEst8b], 

160 ConstructionData.iwu_light: [GeometryData.IwuSingleFamilyDwelling, GeometryData.BmvbsOffice, 

161 GeometryData.BmvbsInstitute, GeometryData.BmvbsInstitute4, 

162 GeometryData.BmvbsInstitute8, GeometryData.UrbanrenetEst1a, 

163 GeometryData.UrbanrenetEst1b, GeometryData.UrbanrenetEst2, 

164 GeometryData.UrbanrenetEst3, GeometryData.UrbanrenetEst4a, 

165 GeometryData.UrbanrenetEst4b, GeometryData.UrbanrenetEst5, 

166 GeometryData.UrbanrenetEst6, GeometryData.UrbanrenetEst7, 

167 GeometryData.UrbanrenetEst8a, GeometryData.UrbanrenetEst8b], 

168 

169 ConstructionData.tabula_de_standard: [GeometryData.TabulaDeSingleFamilyHouse, GeometryData.TabulaDeTerracedHouse, 

170 GeometryData.TabulaDeMultiFamilyHouse, GeometryData.TabulaDeApartmentBlock], 

171 ConstructionData.tabula_de_retrofit: [GeometryData.TabulaDeSingleFamilyHouse, GeometryData.TabulaDeTerracedHouse, 

172 GeometryData.TabulaDeMultiFamilyHouse, GeometryData.TabulaDeApartmentBlock], 

173 ConstructionData.tabula_de_adv_retrofit: [GeometryData.TabulaDeSingleFamilyHouse, GeometryData.TabulaDeTerracedHouse, 

174 GeometryData.TabulaDeMultiFamilyHouse, GeometryData.TabulaDeApartmentBlock], 

175 

176 ConstructionData.tabula_dk_standard: [GeometryData.TabulaDkSingleFamilyHouse, GeometryData.TabulaDkTerracedHouse, 

177 GeometryData.TabulaDkApartmentBlock], 

178 ConstructionData.tabula_dk_retrofit: [GeometryData.TabulaDkSingleFamilyHouse, GeometryData.TabulaDkTerracedHouse, 

179 GeometryData.TabulaDkApartmentBlock], 

180 ConstructionData.tabula_dk_adv_retrofit: [GeometryData.TabulaDkSingleFamilyHouse, GeometryData.TabulaDkTerracedHouse, 

181 GeometryData.TabulaDkApartmentBlock], 

182 

183 ConstructionData.kfw_40: [GeometryData.IwuSingleFamilyDwelling, GeometryData.TabulaDeSingleFamilyHouse], 

184 ConstructionData.kfw_55: [GeometryData.IwuSingleFamilyDwelling, GeometryData.TabulaDeSingleFamilyHouse], 

185 ConstructionData.kfw_70: [GeometryData.IwuSingleFamilyDwelling, GeometryData.TabulaDeSingleFamilyHouse], 

186 ConstructionData.kfw_85: [GeometryData.IwuSingleFamilyDwelling, GeometryData.TabulaDeSingleFamilyHouse], 

187 ConstructionData.kfw_100: [GeometryData.IwuSingleFamilyDwelling, GeometryData.TabulaDeSingleFamilyHouse], 

188} 

189 

190 

191def check_construction_data_setter_iwu(value): 

192 """This function validates and sets the construction_data for buildings using the iwu construction_data.""" 

193 if value is None: 

194 return ConstructionData.iwu_heavy 

195 if isinstance(value, str): 

196 return ConstructionData(value) 

197 if isinstance(value, ConstructionData): 

198 return value 

199 raise ValueError(f"Invalid construction_data: {value}. " 

200 f"Must be either a string or a ConstructionData enum value.") 

201 

202def check_construction_data_setter_tabula_de(value): 

203 """This function validates and sets the construction_data for buildings using the tabula_de construction_data.""" 

204 if value is None: 

205 return ConstructionData.tabula_de_standard 

206 if isinstance(value, str): 

207 return ConstructionData(value) 

208 if isinstance(value, ConstructionData): 

209 return value 

210 raise ValueError(f"Invalid construction_data: {value}. " 

211 f"Must be either a string or a ConstructionData enum value.") 

212 

213def check_construction_data_setter_tabula_dk(value): 

214 """This function validates and sets the construction_data for buildings using the tabula_dk construction_data.""" 

215 if value is None: 

216 return ConstructionData.tabula_dk_standard 

217 if isinstance(value, str): 

218 return ConstructionData(value) 

219 if isinstance(value, ConstructionData): 

220 return value 

221 raise ValueError(f"Invalid construction_data: {value}. " 

222 f"Must be either a string or a ConstructionData enum value.")