Skip to content

Commit

Permalink
move constants to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mikivee committed Oct 3, 2024
1 parent 529bf88 commit 6c7df06
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 8 deletions.
32 changes: 32 additions & 0 deletions src/dmutils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,35 @@
"""
The number of kilograms in pound.
"""

SEER_TO_EER = 0.875
"""
Conversion of SEER (Seasonal Energy Efficiency Ratio) to EER (Energy Efficiency Ratio).
See https://energy-models.com/tools/how-convert-seer-eer-or-cop-kwton-hspf
"""

EER_TO_SEER = 1 / SEER_TO_EER
"""
Conversion of EER (Energy Efficiency Ratio) to SEER (Seasonal EER).
See https://energy-models.com/tools/how-convert-seer-eer-or-cop-kwton-hspf
"""

EER2_TO_EER = 1.04
"""
Conversion of SEER2 to SEER (Seasonal Energy Efficiency Ratio)
for Packaged Air Conditioner and Heat Pump.
The same conversion can be used for SEER2 to SEER.
See https://www.marathonhvac.com/seer-to-seer2
"""

EER_TO_EER2 = 1 / EER2_TO_EER
"""
Conversion of EER (Energy Efficiency Ratio) to SEER2
for Packaged Air Conditioner and Heat Pump.
The same conversion can be used for SEER to SEER2.
See https://www.marathonhvac.com/seer-to-seer2
"""
12 changes: 5 additions & 7 deletions src/dmutils/sumo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,18 @@

from databricks.sdk.runtime import spark, udf

from src.dmutils import data_cleaning
from src.dmutils import data_cleaning, constants

# -- constants -- #
# TODO: put this in some kind of shared config that can be used across repos
# TODO: pull from enums when they are ready
SUPPORTED_UPGRADES = [0.0, 1.0, 3.0, 4.0, 6.0, 9.0, 11.05, 13.01]

BTU_PER_WH = 3.413

EER_CONVERSION = {
"EER": 1.0,
"SEER": 0.875,
"SEER2": 0.91, # ~=SEER*1.04 (https://www.marathonhvac.com/seer-to-seer2/)
"EER2": 1.04,
"SEER": constants.SEER_TO_EER,
"EER2": constants.EER2_TO_EER,
"SEER2": constants.EER2_TO_EER*constants.SEER_TO_EER,
}

# mapping of window description to ufactor and shgc (solar heat gain coefficient) pulled from options.ts
Expand Down Expand Up @@ -275,7 +273,7 @@ def extract_heating_efficiency(heating_efficiency: str) -> int:
if efficiency.endswith("AFUE"):
return number / 100
if efficiency.endswith("HSPF"):
return round(number / BTU_PER_WH, 3)
return round(number / (constants.KILOWATT_HOUR_TO_BRITISH_THERMAL_UNIT / 1000), 3)

# 'Other' - e.g. wood stove - is not supported
return number / 100
Expand Down
35 changes: 34 additions & 1 deletion tests/test_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import unittest

from src import constants
from dmutils import constants


class ConstantTestCase(unittest.TestCase):
Expand Down Expand Up @@ -53,6 +53,39 @@ def test_lb_to_kg(self):
msg="Conversions between pounds and kilos should be recipricals.",
)

def test_seer_to_eer(self):
"""Test conversions between SEER and EER."""
self.assertLess(
constants.SEER_TO_EER, 1.0, "EER is lower than SEER."
)

self.assertGreater(
constants.EER_TO_SEER, 1.0, "SEER is greater than EER."
)

self.assertAlmostEqual(
1.0,
constants.SEER_TO_EER * constants.EER_TO_SEER,
places=10,
msg="Conversions between SEER and EER should be recipricals.",
)

def test_eer_to_eer2(self):
"""Test conversions between EER and EER2."""
self.assertGreater(
constants.EER2_TO_EER, 1.0, "EER is higher than EER2."
)

self.assertLess(
constants.EER_TO_EER2, 1.0, "EER2 is less than EER."
)

self.assertAlmostEqual(
1.0,
constants.EER_TO_EER2 * constants.EER2_TO_EER,
places=10,
msg="Conversions between EER and EER2 should be recipricals.",
)

if os.environ.get("DATABRICKS_RUNTIME_VERSION", None):
# If we are developing on databricks we have to manually
Expand Down

0 comments on commit 6c7df06

Please sign in to comment.