Skip to content

Commit 35eb1f9

Browse files
committed
fix(read wufi): Fix read WUFI Error
- handle case where there are no zones covered by Mech System (index error)
1 parent f7ec6ac commit 35eb1f9

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

PHX/from_WUFI_XML/phx_schemas.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ def _PhxVariant(_xml_variant_data: wufi_xml.WufiVariant, _phx_project_host: PhxP
414414
# -- Build the HVAC Systems, Devices, and Distribution
415415
phx_obj.clear_mechanical_collections()
416416
for xml_system_data in _xml_variant_data.HVAC.Systems:
417+
if len(xml_system_data.ZonesCoverage) == 0:
418+
continue
419+
417420
new_mechanical_collection = PhxMechanicalSystemCollection()
418421
new_mechanical_collection.display_name = xml_system_data.Name
419422
new_mechanical_collection.id_num = xml_system_data.IdentNr

PHX/from_WUFI_XML/wufi_file_schema.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ class WufiPH_ClimateLocation(BaseModel):
113113
Longitude: wufi_unit.CardinalDegrees
114114
dUTC: int
115115

116-
HeightNNWeatherStation: wufi_unit.M
117-
HeightNNBuilding: wufi_unit.M
116+
HeightNNWeatherStation: Optional[wufi_unit.M] = wufi_unit.M(0)
117+
HeightNNBuilding: Optional[wufi_unit.M] = wufi_unit.M(0)
118118

119119
ClimateZone: int
120120
GroundThermalConductivity: wufi_unit.Watts_per_MK

PHX/from_WUFI_XML/wufi_file_types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def validate(cls, v: Union[str, Dict[str, Any]]):
4949

5050
# -- Otherwise, pull the value out of the dict and convert the value to the right unit
5151
try:
52-
result = convert(v["value"], v["unit_type"], cls.__unit_type__)
53-
except Exception:
54-
msg = f"Error converting input for '{cls.__name__}' using inputs: {v}"
52+
result = convert(v["value"].strip(), v["unit_type"], cls.__unit_type__)
53+
except Exception as e:
54+
msg = f"Error converting to '{cls.__name__}' using the input of: [ {v} ]\n{e}"
5555
raise Exception(msg)
5656

5757
# -- If the conversion was unsuccessful, raise an exception

output.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2+
> Reading in data from XML-File: /Users/em/Desktop/test/test2.xml
3+
> Converting XML-data to a PHX-Model
4+
> Saving the XML file to: .//Users/em/Desktop/test/test2.xml
5+
> Successfully wrote to file.

0 commit comments

Comments
 (0)