From d728ba796d7582e4142ebc2615d67cdc161a2344 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 6 Jan 2024 13:46:21 +0100 Subject: [PATCH 1/3] updated climate zone weightings and read from csv --- thermostat/climate_zone.py | 19 ++++++------------- .../NationalAverageClimateZoneWeightings.csv | 10 +++++----- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/thermostat/climate_zone.py b/thermostat/climate_zone.py index ffaf2c5d..8739a755 100644 --- a/thermostat/climate_zone.py +++ b/thermostat/climate_zone.py @@ -5,6 +5,7 @@ from eeweather.geo import get_lat_long_climate_zones import numpy as np import logging +from pathlib import Path logger = logging.getLogger('epathermostat') @@ -38,20 +39,12 @@ 'Mixed-Dry': 'Mixed-Dry/Hot-Dry', } +WEIGHTS = pd.read_csv( + Path("Resources") / "NationalAverageClimateZoneWeightings.csv" + ).set_index('climate_zone') +HEATING_CLIMATE_ZONE_WEIGHTS = WEIGHTS["heating_weight"].to_dict() -HEATING_CLIMATE_ZONE_WEIGHTS = { - 'very-cold_cold': 0.549, - 'mixed-humid': 0.312, - 'mixed-dry_hot-dry': 0.054, - 'hot-humid': 0.049, - 'marine': 0.036} - -COOLING_CLIMATE_ZONE_WEIGHTS = { - 'very-cold_cold': 0.096, - 'mixed-humid': 0.34, - 'mixed-dry_hot-dry': 0.144, - 'hot-humid': 0.42, - 'marine': 0.0} +COOLING_CLIMATE_ZONE_WEIGHTS = WEIGHTS["cooling_weight"].to_dict() def retrieve_climate_zone(zipcode): diff --git a/thermostat/resources/NationalAverageClimateZoneWeightings.csv b/thermostat/resources/NationalAverageClimateZoneWeightings.csv index 7de2f267..3cf36910 100644 --- a/thermostat/resources/NationalAverageClimateZoneWeightings.csv +++ b/thermostat/resources/NationalAverageClimateZoneWeightings.csv @@ -1,6 +1,6 @@ climate_zone,heating_weight,cooling_weight -Very-Cold/Cold,0.549,0.096 -Mixed-Humid,0.312,0.340 -Mixed-Dry/Hot-Dry,0.054,0.144 -Hot-Humid,0.049,0.420 -Marine,0.036,0.000 +very-cold/cold,0.564,0.194 +mixed-humid,0.294,0.311 +mixed-dry/hot-Dry,0.051,0.137 +hot-humid,0.054,0.345 +marine,0.037,0.013 From b43a23dbdde1d045aec71839e5bc873f25c544b9 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 6 Jan 2024 13:52:33 +0100 Subject: [PATCH 2/3] fixed the path --- thermostat/climate_zone.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thermostat/climate_zone.py b/thermostat/climate_zone.py index 8739a755..806eec90 100644 --- a/thermostat/climate_zone.py +++ b/thermostat/climate_zone.py @@ -40,7 +40,7 @@ } WEIGHTS = pd.read_csv( - Path("Resources") / "NationalAverageClimateZoneWeightings.csv" + Path(__file__).parents[0] / "resources" / "NationalAverageClimateZoneWeightings.csv" ).set_index('climate_zone') HEATING_CLIMATE_ZONE_WEIGHTS = WEIGHTS["heating_weight"].to_dict() From 97da25b77947c5a1d4b728330a608726179e90e6 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 6 Jan 2024 14:17:05 +0100 Subject: [PATCH 3/3] updated spelling to more accurately match previous dictionary --- thermostat/resources/NationalAverageClimateZoneWeightings.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/thermostat/resources/NationalAverageClimateZoneWeightings.csv b/thermostat/resources/NationalAverageClimateZoneWeightings.csv index 3cf36910..6d8661cc 100644 --- a/thermostat/resources/NationalAverageClimateZoneWeightings.csv +++ b/thermostat/resources/NationalAverageClimateZoneWeightings.csv @@ -1,6 +1,6 @@ climate_zone,heating_weight,cooling_weight -very-cold/cold,0.564,0.194 +very-cold_cold,0.564,0.194 mixed-humid,0.294,0.311 -mixed-dry/hot-Dry,0.051,0.137 +mixed-dry_hot-dry,0.051,0.137 hot-humid,0.054,0.345 marine,0.037,0.013