Skip to content

Commit

Permalink
fix(read wufi): Fix read WUFI Error
Browse files Browse the repository at this point in the history
- handle case where there are no zones covered by Mech System (index error)
  • Loading branch information
ed-p-may committed Oct 15, 2024
1 parent f7ec6ac commit 35eb1f9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 3 additions & 0 deletions PHX/from_WUFI_XML/phx_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ def _PhxVariant(_xml_variant_data: wufi_xml.WufiVariant, _phx_project_host: PhxP
# -- Build the HVAC Systems, Devices, and Distribution
phx_obj.clear_mechanical_collections()
for xml_system_data in _xml_variant_data.HVAC.Systems:
if len(xml_system_data.ZonesCoverage) == 0:
continue

new_mechanical_collection = PhxMechanicalSystemCollection()
new_mechanical_collection.display_name = xml_system_data.Name
new_mechanical_collection.id_num = xml_system_data.IdentNr
Expand Down
4 changes: 2 additions & 2 deletions PHX/from_WUFI_XML/wufi_file_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ class WufiPH_ClimateLocation(BaseModel):
Longitude: wufi_unit.CardinalDegrees
dUTC: int

HeightNNWeatherStation: wufi_unit.M
HeightNNBuilding: wufi_unit.M
HeightNNWeatherStation: Optional[wufi_unit.M] = wufi_unit.M(0)
HeightNNBuilding: Optional[wufi_unit.M] = wufi_unit.M(0)

ClimateZone: int
GroundThermalConductivity: wufi_unit.Watts_per_MK
Expand Down
6 changes: 3 additions & 3 deletions PHX/from_WUFI_XML/wufi_file_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def validate(cls, v: Union[str, Dict[str, Any]]):

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

# -- If the conversion was unsuccessful, raise an exception
Expand Down
5 changes: 5 additions & 0 deletions output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Reading in data from XML-File: /Users/em/Desktop/test/test2.xml
> Converting XML-data to a PHX-Model
> Saving the XML file to: .//Users/em/Desktop/test/test2.xml
> Successfully wrote to file.

0 comments on commit 35eb1f9

Please sign in to comment.