Skip to content

Commit

Permalink
fix(window): force product_type='shading' for .xml file
Browse files Browse the repository at this point in the history
  • Loading branch information
taoning committed Nov 22, 2024
1 parent 65e78f2 commit 3720e19
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions frads/window.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from dataclasses import asdict, dataclass, field
import json
import os
from pathlib import Path
import tempfile
from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import List, Optional, Tuple, Union

import pyradiance as pr
import pywincalc as pwc


AIR = pwc.PredefinedGasType.AIR
KRYPTON = pwc.PredefinedGasType.KRYPTON
XENON = pwc.PredefinedGasType.XENON
Expand Down Expand Up @@ -56,6 +55,7 @@ class Layer:
ir_transmittance: float
rgb: PaneRGB


@dataclass
class Gas:
"""Gas data object.
Expand Down Expand Up @@ -246,16 +246,12 @@ def get_layers(input: List[pwc.ProductData]) -> List[Layer]:
return layers



def create_pwc_gaps(gaps: List[Gap]):
"""Create a list of pwc gaps from a list of gaps."""
pwc_gaps = []
for gap in gaps:
_gas = pwc.create_gas(
[
[g.ratio, getattr(pwc.PredefinedGasType, g.gas.upper())]
for g in gap.gas
]
[[g.ratio, getattr(pwc.PredefinedGasType, g.gas.upper())] for g in gap.gas]
)
_gap = pwc.Layers.gap(gas=_gas, thickness=gap.thickness)
pwc_gaps.append(_gap)
Expand Down Expand Up @@ -304,6 +300,8 @@ def create_glazing_system(
product_data = pwc.parse_json_file(layer)
elif layer.endswith(".xml"):
product_data = pwc.parse_bsdf_xml_file(layer)
if product_data.product_type is None:
product_data.product_type = "shading"
else:
product_data = pwc.parse_optics_file(layer)
elif isinstance(layer, bytes):
Expand Down Expand Up @@ -340,12 +338,10 @@ def create_glazing_system(
layers=get_layers(layer_data),
gaps=gaps,
solar_front_absorptance=[
alpha.front.absorptance.angular_total
for alpha in solres.layer_results
alpha.front.absorptance.angular_total for alpha in solres.layer_results
],
solar_back_absorptance=[
alpha.back.absorptance.angular_total
for alpha in solres.layer_results
alpha.back.absorptance.angular_total for alpha in solres.layer_results
],
visible_back_reflectance=vissys.back.reflectance.matrix,
visible_front_reflectance=vissys.front.reflectance.matrix,
Expand Down

0 comments on commit 3720e19

Please sign in to comment.