From 6ab3ee3dc3377428a5b5cd2b0bfd05c07e5dfde7 Mon Sep 17 00:00:00 2001 From: p_monsalvete Date: Thu, 13 Jul 2023 15:53:20 -0400 Subject: [PATCH] solved some issues on units in costs catalog --- .../data_models/cost/archetype.py | 4 ++-- .../data_models/cost/fuel.py | 6 +++--- .../data_models/cost/income.py | 8 ++++---- hub/data/construction/eilat_archetypes.json | 6 +++--- hub/data/costs/montreal_costs.xml | 4 ++-- ...function_to_eilat_construction_function.py | 6 +++--- .../helpers/construction_helper.py | 4 +++- tests/test_exports.py | 10 +++++++--- tests/test_results_import.py | 13 +++++++++---- tests/test_systems_factory.py | 19 +++++++++++-------- 10 files changed, 47 insertions(+), 33 deletions(-) diff --git a/hub/catalog_factories/data_models/cost/archetype.py b/hub/catalog_factories/data_models/cost/archetype.py index bcfbe800..1667c8ec 100644 --- a/hub/catalog_factories/data_models/cost/archetype.py +++ b/hub/catalog_factories/data_models/cost/archetype.py @@ -102,7 +102,7 @@ class Archetype: @property def end_of_life_cost(self): """ - Get end of life cost in given currency + Get end of life cost in given currency per m2 :return: float """ return self._end_of_life_cost @@ -125,7 +125,7 @@ class Archetype: 'function': self.function, 'capital cost': self.capital_cost.to_dictionary(), 'operational cost': self.operational_cost.to_dictionary(), - f'end of life cost [currency]': self.end_of_life_cost, + 'end of life cost [currency/m2]': self.end_of_life_cost, 'income': self.income.to_dictionary() } } diff --git a/hub/catalog_factories/data_models/cost/fuel.py b/hub/catalog_factories/data_models/cost/fuel.py index c8a52683..f4e75cca 100644 --- a/hub/catalog_factories/data_models/cost/fuel.py +++ b/hub/catalog_factories/data_models/cost/fuel.py @@ -43,10 +43,10 @@ class Fuel: @property def fixed_power(self) -> Union[None, float]: """ - Get fixed operational costs depending on the peak power consumed in currency per month per kW + Get fixed operational costs depending on the peak power consumed in currency per month per W :return: None or float """ - return self._fixed_power + return self._fixed_power/1000 @property def variable(self) -> Union[tuple[None, None], tuple[float, str]]: @@ -60,7 +60,7 @@ class Fuel: """Class content to dictionary""" content = {'Fuel': {'fuel type': self.type, 'fixed operational costs [currency/month]': self.fixed_monthly, - 'fixed operational costs depending on the peak power consumed [currency/month kW]': self.fixed_power, + 'fixed operational costs depending on the peak power consumed [currency/month W]': self.fixed_power, f'variable costs [{self.variable[1]}]': self.variable[0] } } diff --git a/hub/catalog_factories/data_models/cost/income.py b/hub/catalog_factories/data_models/cost/income.py index b9a4f008..a053512a 100644 --- a/hub/catalog_factories/data_models/cost/income.py +++ b/hub/catalog_factories/data_models/cost/income.py @@ -66,10 +66,10 @@ class Income: def to_dictionary(self): """Class content to dictionary""" - content = {'Income': {'construction subsidy': self.construction_subsidy, - 'hvac subsidy': self.hvac_subsidy, - 'photovoltaic subsidy': self.photovoltaic_subsidy, - 'electricity export': self.electricity_export, + content = {'Income': {'construction subsidy [%]': self.construction_subsidy, + 'hvac subsidy [%]': self.hvac_subsidy, + 'photovoltaic subsidy [%]': self.photovoltaic_subsidy, + 'electricity export [currency/J]': self.electricity_export, 'reductions tax': self.reductions_tax } } diff --git a/hub/data/construction/eilat_archetypes.json b/hub/data/construction/eilat_archetypes.json index 4a15e038..25748055 100644 --- a/hub/data/construction/eilat_archetypes.json +++ b/hub/data/construction/eilat_archetypes.json @@ -1,7 +1,7 @@ { "archetypes": [ { - "function": "Residential", + "function": "Residential_building", "period_of_construction": "1000_1980", "climate_zone": "BWh", "average_storey_height": 3, @@ -35,7 +35,7 @@ } }, { - "function": "Dormitory", + "function": "Residential_building", "period_of_construction": "2011_3000", "climate_zone": "BWh", "average_storey_height": 3, @@ -69,7 +69,7 @@ } }, { - "function": "Hotel_employees", + "function": "Residential_building", "period_of_construction": "1981_2010", "climate_zone": "BWh", "average_storey_height": 3, diff --git a/hub/data/costs/montreal_costs.xml b/hub/data/costs/montreal_costs.xml index aebffbc6..48bbfd85 100644 --- a/hub/data/costs/montreal_costs.xml +++ b/hub/data/costs/montreal_costs.xml @@ -96,7 +96,7 @@ 3.6 0.07 - 0.05 + 5 @@ -196,7 +196,7 @@ 3.6 0.05 - 0.05 + 5 \ No newline at end of file diff --git a/hub/helpers/data/hub_function_to_eilat_construction_function.py b/hub/helpers/data/hub_function_to_eilat_construction_function.py index e4ecfe87..2e8cebc6 100644 --- a/hub/helpers/data/hub_function_to_eilat_construction_function.py +++ b/hub/helpers/data/hub_function_to_eilat_construction_function.py @@ -14,9 +14,9 @@ class HubFunctionToEilatConstructionFunction: """ def __init__(self): self._dictionary = { - cte.RESIDENTIAL: 'Residential', - cte.HOTEL: 'Hotel_employees', - cte.DORMITORY: 'Dormitory' + cte.RESIDENTIAL: 'Residential_building', + cte.HOTEL: 'Residential_building', + cte.DORMITORY: 'Residential_building' } @property diff --git a/hub/imports/construction/helpers/construction_helper.py b/hub/imports/construction/helpers/construction_helper.py index 7f34e853..8814a108 100644 --- a/hub/imports/construction/helpers/construction_helper.py +++ b/hub/imports/construction/helpers/construction_helper.py @@ -50,7 +50,9 @@ class ConstructionHelper: _reference_city_to_nrcan_climate_zone = { 'Montreal': '6', 'Repentigny': '6', - 'Levis': '7A' + 'Levis': '7A', + 'Kelowna': '5', + 'Park Slope': '4' } _reference_city_to_israel_climate_zone = { diff --git a/tests/test_exports.py b/tests/test_exports.py index 7cf74c30..7607c964 100644 --- a/tests/test_exports.py +++ b/tests/test_exports.py @@ -105,11 +105,15 @@ class TestExports(TestCase): """ export to IDF """ - file = 'FZK_Haus_LoD_2.gml' + file = 'test.geojson' file_path = (self._example_path / file).resolve() - city = GeometryFactory('citygml', + city = GeometryFactory('geojson', path=file_path, - function_to_hub=Dictionaries().alkis_function_to_hub_function).city + height_field='citygml_me', + year_of_construction_field='ANNEE_CONS', + function_field='CODE_UTILI', + function_to_hub=Dictionaries().montreal_function_to_hub_function).city + self.assertIsNotNone(city, 'city is none') EnergyBuildingsExportsFactory('idf', city, self._output_path).export() ConstructionFactory('nrcan', city).enrich() diff --git a/tests/test_results_import.py b/tests/test_results_import.py index 3534e454..a9e0959c 100644 --- a/tests/test_results_import.py +++ b/tests/test_results_import.py @@ -30,11 +30,16 @@ class TestResultsImport(TestCase): :return: None """ self._example_path = (Path(__file__).parent / 'tests_data').resolve() - self._gml_path = (self._example_path / 'FZK_Haus_LoD_2.gml').resolve() self._output_path = (Path(__file__).parent / 'tests_outputs').resolve() - self._city = GeometryFactory('citygml', - self._gml_path, - function_to_hub=Dictionaries().alkis_function_to_hub_function).city + file = 'test.geojson' + file_path = (self._example_path / file).resolve() + self._city = GeometryFactory('geojson', + path=file_path, + height_field='citygml_me', + year_of_construction_field='ANNEE_CONS', + function_field='CODE_UTILI', + function_to_hub=Dictionaries().montreal_function_to_hub_function).city + ConstructionFactory('nrcan', self._city).enrich() UsageFactory('nrcan', self._city).enrich() diff --git a/tests/test_systems_factory.py b/tests/test_systems_factory.py index 20d7d336..46d07149 100644 --- a/tests/test_systems_factory.py +++ b/tests/test_systems_factory.py @@ -36,11 +36,15 @@ class TestSystemsFactory(TestCase): :return: None """ self._example_path = (Path(__file__).parent / 'tests_data').resolve() - self._gml_path = (self._example_path / 'FZK_Haus_LoD_2.gml').resolve() self._output_path = (Path(__file__).parent / 'tests_outputs').resolve() - self._city = GeometryFactory('citygml', - self._gml_path, - function_to_hub=Dictionaries().alkis_function_to_hub_function).city + file = 'test.geojson' + file_path = (self._example_path / file).resolve() + self._city = GeometryFactory('geojson', + path=file_path, + height_field='citygml_me', + year_of_construction_field='ANNEE_CONS', + function_field='CODE_UTILI', + function_to_hub=Dictionaries().montreal_function_to_hub_function).city def test_montreal_custom_system_factory(self): """ @@ -50,7 +54,7 @@ class TestSystemsFactory(TestCase): building.energy_systems_archetype_name = 'system 1 gas' EnergySystemsFactory('montreal_custom', self._city).enrich() - self.assertEqual(1, len(self._city.energy_systems_connection_table)) + self.assertEqual(17, len(self._city.energy_systems_connection_table)) def test_montreal_custom_system_results(self): """ @@ -76,9 +80,8 @@ class TestSystemsFactory(TestCase): energy_systems_connection = self._city.energy_systems_connection_table for building in self._city.buildings: _building_energy_systems = [] - energy_systems = energy_systems_connection['Energy System Type'].where( - energy_systems_connection['Building'] == building.name - ) + energy_systems = energy_systems_connection['Energy System Type'][ + energy_systems_connection['Building'] == building.name] for energy_system in energy_systems: _generic_building_energy_systems = self._city.generic_energy_systems[energy_system] for _generic_building_energy_system in _generic_building_energy_systems: