From c38b025c2eb234d07b36d2f5adfed746693bba12 Mon Sep 17 00:00:00 2001 From: Guille Date: Wed, 2 Aug 2023 12:43:51 -0400 Subject: [PATCH] Correct bd test, add dictionary for custom fuel to hub fuel --- .../data/montreal_custom_fuel_to_hub_fuel.py | 28 +++++++++++++++++++ hub/helpers/dictionaries.py | 8 ++++++ .../helpers/construction_helper.py | 16 +---------- ...ontreal_custom_energy_system_parameters.py | 2 +- tests/test_db_factory.py | 2 +- 5 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 hub/helpers/data/montreal_custom_fuel_to_hub_fuel.py diff --git a/hub/helpers/data/montreal_custom_fuel_to_hub_fuel.py b/hub/helpers/data/montreal_custom_fuel_to_hub_fuel.py new file mode 100644 index 00000000..14fd0fef --- /dev/null +++ b/hub/helpers/data/montreal_custom_fuel_to_hub_fuel.py @@ -0,0 +1,28 @@ +""" +Dictionaries module for montreal custom fuel to hub fuel +SPDX - License - Identifier: LGPL - 3.0 - or -later +Copyright © 2022 Concordia CERC group +Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca +""" + +import hub.helpers.constants as cte + + +class MontrealCustomFuelToHubFuel: + """ + Montreal custom fuel to hub fuel class + """ + def __init__(self): + self._dictionary = { + 'gas': cte.GAS, + 'electricity': cte.ELECTRICITY, + 'renewable': cte.RENEWABLE + } + + @property + def dictionary(self) -> dict: + """ + Get the dictionary + :return: {} + """ + return self._dictionary diff --git a/hub/helpers/dictionaries.py b/hub/helpers/dictionaries.py index a6045975..3fa8125d 100644 --- a/hub/helpers/dictionaries.py +++ b/hub/helpers/dictionaries.py @@ -6,6 +6,7 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ from hub.helpers.data.hft_function_to_hub_function import HftFunctionToHubFunction +from hub.helpers.data.montreal_custom_fuel_to_hub_fuel import MontrealCustomFuelToHubFuel from hub.helpers.data.montreal_function_to_hub_function import MontrealFunctionToHubFunction from hub.helpers.data.eilat_function_to_hub_function import EilatFunctionToHubFunction from hub.helpers.data.alkis_function_to_hub_function import AlkisFunctionToHubFunction @@ -141,3 +142,10 @@ class Dictionaries: Get Eilat's function to hub function, transformation dictionary """ return EilatFunctionToHubFunction().dictionary + + @property + def montreal_custom_fuel_to_hub_fuel(self) -> dict: + """ + Get hub fuel from montreal_custom catalog fuel + """ + return MontrealCustomFuelToHubFuel().dictionary diff --git a/hub/imports/construction/helpers/construction_helper.py b/hub/imports/construction/helpers/construction_helper.py index 7f92111c..9ed66da2 100644 --- a/hub/imports/construction/helpers/construction_helper.py +++ b/hub/imports/construction/helpers/construction_helper.py @@ -13,10 +13,7 @@ class ConstructionHelper: Construction helper """ # NREL - _nrel_standards = { - 'ASHRAE Std189': 1, - 'ASHRAE 90.1_2004': 2 - } + _reference_city_to_nrel_climate_zone = { 'Miami': 'ASHRAE_2004:1A', 'Houston': 'ASHRAE_2004:2A', @@ -35,17 +32,6 @@ class ConstructionHelper: 'Duluth': 'ASHRAE_2004:7A', 'Fairbanks': 'ASHRAE_2004:8A' } - nrel_window_types = [cte.WINDOW, cte.DOOR, cte.SKYLIGHT] - - nrel_construction_types = { - cte.WALL: 'exterior wall', - cte.INTERIOR_WALL: 'interior wall', - cte.GROUND_WALL: 'ground wall', - cte.GROUND: 'exterior slab', - cte.ATTIC_FLOOR: 'attic floor', - cte.INTERIOR_SLAB: 'interior slab', - cte.ROOF: 'roof' - } _reference_city_to_nrcan_climate_zone = { 'Montreal': '6', diff --git a/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py b/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py index 443be2fa..42b5bf07 100644 --- a/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py +++ b/hub/imports/energy_systems/montreal_custom_energy_system_parameters.py @@ -91,7 +91,7 @@ class MontrealCustomEnergySystemParameters: _type = system.name _generation_system.type = Dictionaries().montreal_system_to_hub_energy_generation_system[ _type] - _fuel_type = EnergySystemsHelper().montreal_custom_fuel_to_hub_fuel(archetype_generation_equipment.fuel_type) + _fuel_type = Dictionaries().montreal_custom_fuel_to_hub_fuel[archetype_generation_equipment.fuel_type] _generation_system.fuel_type = _fuel_type _generation_system.source_types = archetype_generation_equipment.source_types _generation_system.heat_efficiency = archetype_generation_equipment.heat_efficiency diff --git a/tests/test_db_factory.py b/tests/test_db_factory.py index bf1dcab6..fb11fea8 100644 --- a/tests/test_db_factory.py +++ b/tests/test_db_factory.py @@ -283,7 +283,7 @@ TestDBFactory control.database.add_simulation_results( cte.INSEL_MEB, results, city_object_id=db_building_id) - self.assertEqual(1, len(city_objects_id), 'wrong number of results') + self.assertEqual(17, len(city_objects_id), 'wrong number of results') self.assertIsNotNone(city_objects_id[0], 'city_object_id is None') """ for _id in city_objects_id: