Repository: NREL/hescore-hpxml

Issue:
Window code mapping changes
 - Aluminum, double pane, low-e is currently mapping to `dcaa`.
 - Aluminum, thermal break is currently mapping to `dcab`

@lirainer What should these be mapping to?

Discussion:

Patch:
diff --git a/hescorehpxml/__init__.py b/hescorehpxml/__init__.py
index 306fcba0..b178e9fc 100644
--- a/hescorehpxml/__init__.py
+++ b/hescorehpxml/__init__.py
@@ -236,7 +236,7 @@ class HPXMLtoHEScoreTranslator(object):
                 if glass_layers in ('double-pane', 'single-paned with storms', 'single-paned with low-e storms'):
                     if glass_layers == 'double-pane' and glass_type == 'low-e' and gas_fill == 'argon':
                         window_code = 'dpeaab'
-                    elif glass_type is not None and glass_type == 'reflective':
+                    elif glass_type is not None and glass_type in ('reflective', 'low-e'):
                         # TODO: figure out if 'reflective' is close enough to 'solar-control' low-e
                         window_code = 'dseab'
                     elif glass_type is not None and glass_type.startswith('tinted'):
@@ -251,7 +251,7 @@ class HPXMLtoHEScoreTranslator(object):
                     else:
                         window_code = 'scna'
                 elif glass_layers in ('double-pane', 'single-paned with storms', 'single-paned with low-e storms'):
-                    if glass_type is not None and glass_type in ('reflective', 'tinted/reflective'):
+                    if glass_type is not None and glass_type in ('reflective', 'tinted/reflective', 'low-e'):
                         window_code = 'dseaa'
                     elif glass_type is not None and glass_type == 'tinted':
                         window_code = 'dtaa'


Test patch:
diff --git a/tests/tests.py b/tests/tests.py
index ccc81832..86a1f68b 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -6,7 +6,7 @@ from builtins import object
 import os
 import unittest
 import datetime as dt
-from lxml import etree
+from lxml import etree, objectify
 from hescorehpxml import HPXMLtoHEScoreTranslator, TranslationError, InputOutOfBounds
 import io
 import json
@@ -61,6 +61,15 @@ class ComparatorBase(object):
     def xpath(self, xpathexpr, *args, **kwargs):
         return self.translator.xpath(self.translator.hpxmldoc, xpathexpr, *args, **kwargs)
 
+    @property
+    def E(self):
+        E = objectify.ElementMaker(
+            annotate=False,
+            namespace=self.translator.ns['h'],
+            nsmap=self.translator.ns
+        )
+        return E
+
 
 class TestAPIHouses(unittest.TestCase, ComparatorBase):
     def test_house1(self):
@@ -1997,6 +2006,40 @@ class TestHEScore2019Updates(unittest.TestCase, ComparatorBase):
         roof_type = d['building']['zone']['zone_roof'][0]['roof_type']
         self.assertEqual(roof_type, 'vented_attic')
 
+    def test_window_code_mappings_aluminum(self):
+        tr = self._load_xmlfile('hescore_min')
+
+        window2_frametype = self.xpath('//h:Window[h:SystemIdentifier/@id="window2"]/h:FrameType')
+        window2_frametype.clear()
+        window2_frametype.append(self.E.Aluminum())
+        window2_frametype.getparent().append(self.E.GlassType('low-e'))
+
+        window3_frametype = self.xpath('//h:Window[h:SystemIdentifier/@id="window3"]/h:FrameType')
+        window3_frametype.clear()
+        window3_frametype.append(self.E.Aluminum(self.E.ThermalBreak(True)))
+
+        window4_frametype = self.xpath('//h:Window[h:SystemIdentifier/@id="window4"]/h:FrameType')
+        window4_frametype.clear()
+        window4_frametype.append(self.E.Aluminum(self.E.ThermalBreak(True)))
+        window4_frametype.getparent().append(self.E.GlassType('low-e'))
+
+        d = tr.hpxml_to_hescore_dict()
+        walls = {}
+        for wall in d['building']['zone']['zone_wall']:
+            walls[wall['side']] = wall
+        self.assertEqual(
+            walls['left']['zone_window']['window_code'],
+            'dseaa'
+        )
+        self.assertEqual(
+            walls['back']['zone_window']['window_code'],
+            'dcab'
+        )
+        self.assertEqual(
+            walls['right']['zone_window']['window_code'],
+            'dseab'
+        )
+
 
 if __name__ == "__main__":
     unittest.main()