From 1d4841df83b5a0930de4d12a37595788ae217dbc Mon Sep 17 00:00:00 2001 From: Pilar Date: Thu, 3 Jun 2021 15:56:59 -0400 Subject: [PATCH] city_objects_clusters are now city_objects test_sensors_factory.py passes --- .../attributes/thermal_zone.py | 4 +-- city_model_structure/attributes/usage_zone.py | 32 +++++++++---------- city_model_structure/building.py | 4 +-- city_model_structure/city.py | 19 +++++++++-- city_model_structure/city_objects_cluster.py | 5 ++- exports/formats/energy_ade.py | 2 +- exports/formats/idf.py | 2 +- .../ca_physics_parameters.py | 4 +-- .../data_classes/nrel_building_achetype.py | 2 +- .../data_classes/nrel_layer_archetype.py | 0 .../nrel_thermal_boundary_archetype.py | 4 +-- .../nrel_thermal_opening_archetype.py | 0 .../helpers/construction_helper.py | 0 .../nrel_physics_interface.py | 10 +++--- .../us_physics_parameters.py | 4 +-- imports/construction_factory.py | 4 +-- imports/geometry/helpers/geometry_helper.py | 4 +-- .../schedules/comnet_schedules_parameters.py | 2 +- imports/schedules/helpers/schedules_helper.py | 2 +- .../sensors/concordia_energy_consumption.py | 4 +-- imports/sensors/concordia_gas_flow.py | 32 ++++++++++--------- imports/sensors/concordia_temperature.py | 32 ++++++++++--------- imports/sensors_factory.py | 2 +- .../hft_internal_gains_archetype.py | 0 .../data_classes/hft_usage_zone_archetype.py | 20 ++++++------ .../{usages => usage}/helpers/usage_helper.py | 4 +-- .../{usages => usage}/hft_usage_interface.py | 6 ++-- .../{usages => usage}/hft_usage_parameters.py | 10 +++--- imports/usage_factory.py | 6 ++-- imports/weather_factory.py | 2 +- non_functional_tests/test_sensors_factory.py | 11 +++---- non_functional_tests/test_usage_factory.py | 26 +++++++-------- 32 files changed, 137 insertions(+), 122 deletions(-) rename imports/{constructions => construction}/ca_physics_parameters.py (95%) rename imports/{constructions => construction}/data_classes/nrel_building_achetype.py (96%) rename imports/{constructions => construction}/data_classes/nrel_layer_archetype.py (100%) rename imports/{constructions => construction}/data_classes/nrel_thermal_boundary_archetype.py (91%) rename imports/{constructions => construction}/data_classes/nrel_thermal_opening_archetype.py (100%) rename imports/{constructions => construction}/helpers/construction_helper.py (100%) rename imports/{constructions => construction}/nrel_physics_interface.py (95%) rename imports/{constructions => construction}/us_physics_parameters.py (97%) rename imports/{usages => usage}/data_classes/hft_internal_gains_archetype.py (100%) rename imports/{usages => usage}/data_classes/hft_usage_zone_archetype.py (85%) rename imports/{usages => usage}/helpers/usage_helper.py (90%) rename imports/{usages => usage}/hft_usage_interface.py (97%) rename imports/{usages => usage}/hft_usage_parameters.py (92%) diff --git a/city_model_structure/attributes/thermal_zone.py b/city_model_structure/attributes/thermal_zone.py index 633b03a1..e5cd3441 100644 --- a/city_model_structure/attributes/thermal_zone.py +++ b/city_model_structure/attributes/thermal_zone.py @@ -207,7 +207,7 @@ class ThermalZone: @property def usage_zones(self) -> List[UsageZone]: """ - Get thermal zone usages zones + Get thermal zone usage zones :return: [UsageZone] """ return self._usage_zones @@ -215,7 +215,7 @@ class ThermalZone: @usage_zones.setter def usage_zones(self, values): """ - Set thermal zone usages zones + Set thermal zone usage zones :param values: [UsageZone] :return: None """ diff --git a/city_model_structure/attributes/usage_zone.py b/city_model_structure/attributes/usage_zone.py index 085b40bb..43761bf5 100644 --- a/city_model_structure/attributes/usage_zone.py +++ b/city_model_structure/attributes/usage_zone.py @@ -52,7 +52,7 @@ class UsageZone: @property def internal_gains(self) -> List[InternalGains]: """ - Get usages zone internal gains + Get usage zone internal gains :return: [InternalGains] """ return self._internal_gains @@ -60,7 +60,7 @@ class UsageZone: @internal_gains.setter def internal_gains(self, value): """ - Set usages zone internal gains + Set usage zone internal gains :param value: [InternalGains] :return: None """ @@ -69,7 +69,7 @@ class UsageZone: @property def heating_setpoint(self): """ - Get usages zone heating set point in celsius grads + Get usage zone heating set point in celsius grads :return: float """ return self._heating_setpoint @@ -77,7 +77,7 @@ class UsageZone: @heating_setpoint.setter def heating_setpoint(self, value): """ - Set usages zone heating set point in celsius grads + Set usage zone heating set point in celsius grads :param value: float :return: None """ @@ -86,7 +86,7 @@ class UsageZone: @property def heating_setback(self): """ - Get usages zone heating setback in celsius grads + Get usage zone heating setback in celsius grads :return: float """ return self._heating_setback @@ -94,7 +94,7 @@ class UsageZone: @heating_setback.setter def heating_setback(self, value): """ - Set usages zone heating setback in celsius grads + Set usage zone heating setback in celsius grads :param value: float :return: None """ @@ -103,7 +103,7 @@ class UsageZone: @property def cooling_setpoint(self): """ - Get usages zone cooling setpoint in celsius grads + Get usage zone cooling setpoint in celsius grads :return: float """ return self._cooling_setpoint @@ -111,7 +111,7 @@ class UsageZone: @cooling_setpoint.setter def cooling_setpoint(self, value): """ - Set usages zone cooling setpoint in celsius grads + Set usage zone cooling setpoint in celsius grads :param value: float :return: None """ @@ -120,7 +120,7 @@ class UsageZone: @property def hours_day(self): """ - Get usages zone usages hours per day + Get usage zone usage hours per day :return: float """ return self._hours_day @@ -128,7 +128,7 @@ class UsageZone: @hours_day.setter def hours_day(self, value): """ - Set usages zone usages hours per day + Set usage zone usage hours per day :param value: float :return: float """ @@ -137,7 +137,7 @@ class UsageZone: @property def days_year(self): """ - Get usages zone usages days per year + Get usage zone usage days per year :return: float """ return self._days_year @@ -145,7 +145,7 @@ class UsageZone: @days_year.setter def days_year(self, value): """ - Set usages zone usages days per year + Set usage zone usage days per year :param value: float :return: None """ @@ -154,7 +154,7 @@ class UsageZone: @property def mechanical_air_change(self): """ - Set usages zone mechanical air change in air change per hour (ACH) + Set usage zone mechanical air change in air change per hour (ACH) :return: float """ return self._mechanical_air_change @@ -162,7 +162,7 @@ class UsageZone: @mechanical_air_change.setter def mechanical_air_change(self, value): """ - Get usages zone mechanical air change in air change per hour (ACH) + Get usage zone mechanical air change in air change per hour (ACH) :param value: float :return: None """ @@ -171,7 +171,7 @@ class UsageZone: @property def usage(self): """ - Get usages zone usages + Get usage zone usage :return: str """ return self._usage @@ -179,7 +179,7 @@ class UsageZone: @usage.setter def usage(self, value): """ - Get usages zone usages + Get usage zone usage :param value: str :return: None """ diff --git a/city_model_structure/building.py b/city_model_structure/building.py index 6add7de4..2cd9483c 100644 --- a/city_model_structure/building.py +++ b/city_model_structure/building.py @@ -120,7 +120,7 @@ class Building(CityObject): @property def usage_zones(self) -> List[UsageZone]: """ - Get city object usages zones + Get city object usage zones :return: [UsageZone] """ return self._usage_zones @@ -128,7 +128,7 @@ class Building(CityObject): @usage_zones.setter def usage_zones(self, values): """ - Set city objects usages zones + Set city objects usage zones :param values: [UsageZones] :return: None """ diff --git a/city_model_structure/city.py b/city_model_structure/city.py index 24f4376f..54d76deb 100644 --- a/city_model_structure/city.py +++ b/city_model_structure/city.py @@ -44,6 +44,7 @@ class City: self._buildings_clusters = None self._parts_consisting_buildings = None self._city_objects_clusters = None + self._city_objects = None def _get_location(self) -> Location: if self._location is None: @@ -97,7 +98,15 @@ class City: City objects belonging to the city :return: None or [CityObject] """ - return self.buildings + if self._city_objects is None: + if self.city_objects_clusters is None: + self._city_objects = [] + else: + self._city_objects = self.city_objects_clusters + if self.buildings is not None: + for building in self.buildings: + self._city_objects.append(building) + return self._city_objects @property def buildings(self) -> Union[List[Building], None]: @@ -171,7 +180,6 @@ class City: else: raise NotImplementedError(new_city_object.type) - def remove_city_object(self, city_object): """ Remove a CityObject from the city @@ -313,6 +321,12 @@ class City: City objects clusters belonging to the city :return: None or [CityObjectsCluster] """ + if self.buildings_clusters is None: + self._city_objects_clusters = [] + else: + self._city_objects_clusters = self.buildings_clusters + if self.parts_consisting_buildings is not None: + self._city_objects_clusters.append(self.parts_consisting_buildings) return self._city_objects_clusters def add_city_objects_cluster(self, new_city_objects_cluster): @@ -321,7 +335,6 @@ class City: :param new_city_objects_cluster:CityObjectsCluster :return: None """ - print(new_city_objects_cluster.type) if new_city_objects_cluster.type == 'buildings': if self._buildings_clusters is None: self._buildings_clusters = [] diff --git a/city_model_structure/city_objects_cluster.py b/city_model_structure/city_objects_cluster.py index 665d94b2..910c31da 100644 --- a/city_model_structure/city_objects_cluster.py +++ b/city_model_structure/city_objects_cluster.py @@ -7,9 +7,10 @@ Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons from abc import ABC from typing import List from city_model_structure.attributes.sensor import Sensor +from city_model_structure.city_object import CityObject -class CityObjectsCluster(ABC): +class CityObjectsCluster(ABC, CityObject): """ CityObjectsCluster(ABC) class """ @@ -18,6 +19,8 @@ class CityObjectsCluster(ABC): self._cluster_type = cluster_type self._city_objects = city_objects self._sensors = [] + self._lod = '' + super(ABC, self).__init__(name, self._lod, None, None) @property def name(self): diff --git a/exports/formats/energy_ade.py b/exports/formats/energy_ade.py index 2c54e32d..1c0f9bb8 100644 --- a/exports/formats/energy_ade.py +++ b/exports/formats/energy_ade.py @@ -166,7 +166,7 @@ class EnergyAde: def _building_geometry(self, building, building_dic, city): building_dic['bldg:Building']['bldg:function'] = building.function - building_dic['bldg:Building']['bldg:usages'] = ', '.join([u.usage for u in building.usage_zones]) + building_dic['bldg:Building']['bldg:usage'] = ', '.join([u.usage for u in building.usage_zones]) building_dic['bldg:Building']['bldg:yearOfConstruction'] = building.year_of_construction building_dic['bldg:Building']['bldg:roofType'] = building.roof_type building_dic['bldg:Building']['bldg:measuredHeight'] = { diff --git a/exports/formats/idf.py b/exports/formats/idf.py index fa3770e0..81b46ee8 100644 --- a/exports/formats/idf.py +++ b/exports/formats/idf.py @@ -116,7 +116,7 @@ class Idf: def _add_heating_system(self, building): for usage_zone in building.usage_zones: thermostat_name = f'Thermostat {building.name}' - # todo: this will fail for more than one usages zone + # todo: this will fail for more than one usage zone static_thermostat = self._idf.newidfobject(self._THERMOSTAT, Name=thermostat_name, Constant_Heating_Setpoint=usage_zone.heating_setpoint, diff --git a/imports/constructions/ca_physics_parameters.py b/imports/construction/ca_physics_parameters.py similarity index 95% rename from imports/constructions/ca_physics_parameters.py rename to imports/construction/ca_physics_parameters.py index afe4015a..a64054ee 100644 --- a/imports/constructions/ca_physics_parameters.py +++ b/imports/construction/ca_physics_parameters.py @@ -5,8 +5,8 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ import sys -from imports.constructions.nrel_physics_interface import NrelPhysicsInterface -from imports.constructions.helpers.construction_helper import ConstructionHelper +from imports.construction.nrel_physics_interface import NrelPhysicsInterface +from imports.construction.helpers.construction_helper import ConstructionHelper class CaPhysicsParameters(NrelPhysicsInterface): diff --git a/imports/constructions/data_classes/nrel_building_achetype.py b/imports/construction/data_classes/nrel_building_achetype.py similarity index 96% rename from imports/constructions/data_classes/nrel_building_achetype.py rename to imports/construction/data_classes/nrel_building_achetype.py index 1e7fa855..afa25c6e 100644 --- a/imports/constructions/data_classes/nrel_building_achetype.py +++ b/imports/construction/data_classes/nrel_building_achetype.py @@ -4,7 +4,7 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ from typing import List -from imports.constructions.data_classes.nrel_thermal_boundary_archetype import NrelThermalBoundaryArchetype +from imports.construction.data_classes.nrel_thermal_boundary_archetype import NrelThermalBoundaryArchetype class NrelBuildingArchetype: diff --git a/imports/constructions/data_classes/nrel_layer_archetype.py b/imports/construction/data_classes/nrel_layer_archetype.py similarity index 100% rename from imports/constructions/data_classes/nrel_layer_archetype.py rename to imports/construction/data_classes/nrel_layer_archetype.py diff --git a/imports/constructions/data_classes/nrel_thermal_boundary_archetype.py b/imports/construction/data_classes/nrel_thermal_boundary_archetype.py similarity index 91% rename from imports/constructions/data_classes/nrel_thermal_boundary_archetype.py rename to imports/construction/data_classes/nrel_thermal_boundary_archetype.py index c5452359..52d4b86e 100644 --- a/imports/constructions/data_classes/nrel_thermal_boundary_archetype.py +++ b/imports/construction/data_classes/nrel_thermal_boundary_archetype.py @@ -5,8 +5,8 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ from typing import List -from imports.constructions.data_classes.nrel_layer_archetype import NrelLayerArchetype -from imports.constructions.data_classes.nrel_thermal_opening_archetype import NrelThermalOpeningArchetype +from imports.construction.data_classes.nrel_layer_archetype import NrelLayerArchetype +from imports.construction.data_classes.nrel_thermal_opening_archetype import NrelThermalOpeningArchetype class NrelThermalBoundaryArchetype: diff --git a/imports/constructions/data_classes/nrel_thermal_opening_archetype.py b/imports/construction/data_classes/nrel_thermal_opening_archetype.py similarity index 100% rename from imports/constructions/data_classes/nrel_thermal_opening_archetype.py rename to imports/construction/data_classes/nrel_thermal_opening_archetype.py diff --git a/imports/constructions/helpers/construction_helper.py b/imports/construction/helpers/construction_helper.py similarity index 100% rename from imports/constructions/helpers/construction_helper.py rename to imports/construction/helpers/construction_helper.py diff --git a/imports/constructions/nrel_physics_interface.py b/imports/construction/nrel_physics_interface.py similarity index 95% rename from imports/constructions/nrel_physics_interface.py rename to imports/construction/nrel_physics_interface.py index 1003a8e1..1bd772eb 100644 --- a/imports/constructions/nrel_physics_interface.py +++ b/imports/construction/nrel_physics_interface.py @@ -6,10 +6,10 @@ Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ import xmltodict -from imports.constructions.data_classes.nrel_building_achetype import NrelBuildingArchetype as nba -from imports.constructions.data_classes.nrel_thermal_boundary_archetype import NrelThermalBoundaryArchetype as ntba -from imports.constructions.data_classes.nrel_thermal_opening_archetype import NrelThermalOpeningArchetype as ntoa -from imports.constructions.data_classes.nrel_layer_archetype import NrelLayerArchetype as nla +from imports.construction.data_classes.nrel_building_achetype import NrelBuildingArchetype as nba +from imports.construction.data_classes.nrel_thermal_boundary_archetype import NrelThermalBoundaryArchetype as ntba +from imports.construction.data_classes.nrel_thermal_opening_archetype import NrelThermalOpeningArchetype as ntoa +from imports.construction.data_classes.nrel_layer_archetype import NrelLayerArchetype as nla class NrelPhysicsInterface: @@ -59,7 +59,7 @@ class NrelPhysicsInterface: raise Exception(f'infiltration rate for ventilation when system on units = {units}, expected ACH') thermal_boundary_archetypes = [] - for construction in archetype['constructions']['construction']: + for construction in archetype['construction']['construction']: construction_type = construction['@type'] construction_id = construction['@id'] diff --git a/imports/constructions/us_physics_parameters.py b/imports/construction/us_physics_parameters.py similarity index 97% rename from imports/constructions/us_physics_parameters.py rename to imports/construction/us_physics_parameters.py index a924ece6..f5459c5f 100644 --- a/imports/constructions/us_physics_parameters.py +++ b/imports/construction/us_physics_parameters.py @@ -6,8 +6,8 @@ Contributors Pilar Monsalvete pilar_monsalvete@yahoo.es """ import sys -from imports.constructions.nrel_physics_interface import NrelPhysicsInterface -from imports.constructions.helpers.construction_helper import ConstructionHelper +from imports.construction.nrel_physics_interface import NrelPhysicsInterface +from imports.construction.helpers.construction_helper import ConstructionHelper from city_model_structure.attributes.layer import Layer from city_model_structure.attributes.material import Material diff --git a/imports/construction_factory.py b/imports/construction_factory.py index 2634bee5..33b769a7 100644 --- a/imports/construction_factory.py +++ b/imports/construction_factory.py @@ -3,8 +3,8 @@ ConstructionFactory (before PhysicsFactory) retrieve the specific construction m SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ -from imports.constructions.us_physics_parameters import UsPhysicsParameters -from imports.constructions.ca_physics_parameters import CaPhysicsParameters +from imports.construction.us_physics_parameters import UsPhysicsParameters +from imports.construction.ca_physics_parameters import CaPhysicsParameters from pathlib import Path diff --git a/imports/geometry/helpers/geometry_helper.py b/imports/geometry/helpers/geometry_helper.py index 42b0e6c0..f4d94faa 100644 --- a/imports/geometry/helpers/geometry_helper.py +++ b/imports/geometry/helpers/geometry_helper.py @@ -245,7 +245,7 @@ class GeometryHelper: 'large office': 'large office' } - # usages + # usage fuction_to_usage = { 'full service restaurant': 'restaurant', 'highrise apartment': 'residential', @@ -288,7 +288,7 @@ class GeometryHelper: @staticmethod def usage_from_function(building_function): """ - Get the internal usages for the given internal building function + Get the internal usage for the given internal building function :param building_function: str :return: str """ diff --git a/imports/schedules/comnet_schedules_parameters.py b/imports/schedules/comnet_schedules_parameters.py index 85eabd90..b4dbae41 100644 --- a/imports/schedules/comnet_schedules_parameters.py +++ b/imports/schedules/comnet_schedules_parameters.py @@ -1,5 +1,5 @@ """ -Schedules retrieve the specific usages schedules module for the given standard +Schedules retrieve the specific usage schedules module for the given standard SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca diff --git a/imports/schedules/helpers/schedules_helper.py b/imports/schedules/helpers/schedules_helper.py index 33011359..772ffb54 100644 --- a/imports/schedules/helpers/schedules_helper.py +++ b/imports/schedules/helpers/schedules_helper.py @@ -24,7 +24,7 @@ class SchedulesHelper: @staticmethod def comnet_from_usage(usage): """ - Get Comnet usages from the given internal usages key + Get Comnet usage from the given internal usage key :param usage: str :return: str """ diff --git a/imports/sensors/concordia_energy_consumption.py b/imports/sensors/concordia_energy_consumption.py index f60289f6..c9cefd6a 100644 --- a/imports/sensors/concordia_energy_consumption.py +++ b/imports/sensors/concordia_energy_consumption.py @@ -14,8 +14,6 @@ class ConcordiaEnergyConsumption(ConcordiaFileReport): super().__init__(city, end_point, base_path, 'concordia_energy_db.json') for city_object in city.city_objects: self._assign_sensor_to_object(city_object) - for city_object_cluster in city.city_objects_cluster: - self._assign_sensor_to_object(city_object_cluster) def _assign_sensor_to_object(self, obj): for i in range(len(self._city_object)): @@ -25,7 +23,7 @@ class ConcordiaEnergyConsumption(ConcordiaFileReport): building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1) sensor = ConcordiaEnergySensor(self._sensors[i]) sensor_exist = False - for j in range(len(object.sensors)): + for j in range(len(obj.sensors)): if obj.sensors[j].name is sensor.name: obj.sensors[j].add_period(building_energy_consumption) sensor_exist = True diff --git a/imports/sensors/concordia_gas_flow.py b/imports/sensors/concordia_gas_flow.py index affe4de1..48a22bf1 100644 --- a/imports/sensors/concordia_gas_flow.py +++ b/imports/sensors/concordia_gas_flow.py @@ -13,19 +13,21 @@ class ConcordiaGasFlow(ConcordiaFileReport): def __init__(self, city, end_point, base_path): super().__init__(city, end_point, base_path, 'concordia_gas_flow_db.json') for city_object in city.city_objects: - for i in range(len(self._city_object)): - if self._city_object[i] == city_object.name and self._sensors[i] in self._sensor_point: - building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]] - building_headers = ["Date time", "Gas Flow Cumulative Monthly"] - building_gas_flow = pd.concat(building_measures, keys=building_headers, axis=1) - sensor = ConcordiaGasFlowSensor(self._sensors[i]) - sensor_exist = False - for j in range(len(city_object.sensors)): - if city_object.sensors[j].name is sensor.name: - city_object.sensors[j].add_period(building_gas_flow) - sensor_exist = True - break - if not sensor_exist: - sensor.add_period(building_gas_flow) - city_object.sensors.append(sensor) + self._assign_sensor_to_object(city_object) + def _assign_sensor_to_object(self, obj): + for i in range(len(self._city_object)): + if self._city_object[i] == obj.name and self._sensors[i] in self._sensor_point: + building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]] + building_headers = ["Date time", "Gas Flow Cumulative Monthly"] + building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1) + sensor = ConcordiaGasFlowSensor(self._sensors[i]) + sensor_exist = False + for j in range(len(obj.sensors)): + if obj.sensors[j].name is sensor.name: + obj.sensors[j].add_period(building_energy_consumption) + sensor_exist = True + break + if not sensor_exist: + sensor.add_period(building_energy_consumption) + obj.sensors.append(sensor) diff --git a/imports/sensors/concordia_temperature.py b/imports/sensors/concordia_temperature.py index 8cc0c0e5..9f5ccc53 100644 --- a/imports/sensors/concordia_temperature.py +++ b/imports/sensors/concordia_temperature.py @@ -13,19 +13,21 @@ class ConcordiaTemperature(ConcordiaFileReport): def __init__(self, city, end_point, base_path): super().__init__(city, end_point, base_path, 'concordia_temperature_db.json') for city_object in city.city_objects: - for i in range(len(self._city_object)): - if self._city_object[i] == city_object.name and self._sensors[i] in self._sensor_point: - building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]] - building_headers = ["Date time", "Temperature"] - building_temperature = pd.concat(building_measures, keys=building_headers, axis=1) - sensor = ConcordiaTemperatureSensor(self._sensors[i]) - sensor_exist = False - for j in range(len(city_object.sensors)): - if city_object.sensors[j].name is sensor.name: - city_object.sensors[j].add_period(building_temperature) - sensor_exist = True - break - if not sensor_exist: - sensor.add_period(building_temperature) - city_object.sensors.append(sensor) + self._assign_sensor_to_object(city_object) + def _assign_sensor_to_object(self, obj): + for i in range(len(self._city_object)): + if self._city_object[i] == obj.name and self._sensors[i] in self._sensor_point: + building_measures = [self._measures["Date time"], self._measures[self._sensor_point[self._sensors[i]]]] + building_headers = ["Date time", "Temperature"] + building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1) + sensor = ConcordiaTemperatureSensor(self._sensors[i]) + sensor_exist = False + for j in range(len(obj.sensors)): + if obj.sensors[j].name is sensor.name: + obj.sensors[j].add_period(building_energy_consumption) + sensor_exist = True + break + if not sensor_exist: + sensor.add_period(building_energy_consumption) + obj.sensors.append(sensor) diff --git a/imports/sensors_factory.py b/imports/sensors_factory.py index c94d39b6..962b073b 100644 --- a/imports/sensors_factory.py +++ b/imports/sensors_factory.py @@ -31,7 +31,7 @@ class SensorsFactory: def enrich(self): """ - Enrich the city with the usages information + Enrich the city with the usage information :return: None """ getattr(self, self._handler, lambda: None)() diff --git a/imports/usages/data_classes/hft_internal_gains_archetype.py b/imports/usage/data_classes/hft_internal_gains_archetype.py similarity index 100% rename from imports/usages/data_classes/hft_internal_gains_archetype.py rename to imports/usage/data_classes/hft_internal_gains_archetype.py diff --git a/imports/usages/data_classes/hft_usage_zone_archetype.py b/imports/usage/data_classes/hft_usage_zone_archetype.py similarity index 85% rename from imports/usages/data_classes/hft_usage_zone_archetype.py rename to imports/usage/data_classes/hft_usage_zone_archetype.py index 1d13a84f..493e26ca 100644 --- a/imports/usages/data_classes/hft_usage_zone_archetype.py +++ b/imports/usage/data_classes/hft_usage_zone_archetype.py @@ -1,10 +1,10 @@ """ -HftUsageZoneArchetype stores usages information by building archetypes +HftUsageZoneArchetype stores usage information by building archetypes SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete pilar_monsalvete@yahoo.es """ from typing import List -from imports.usages.data_classes.hft_internal_gains_archetype import HftInternalGainsArchetype +from imports.usage.data_classes.hft_internal_gains_archetype import HftInternalGainsArchetype class HftUsageZoneArchetype: @@ -34,7 +34,7 @@ class HftUsageZoneArchetype: @property def internal_gains(self) -> List[HftInternalGainsArchetype]: """ - Get usages zone internal gains + Get usage zone internal gains :return: [InternalGains] """ return self._internal_gains @@ -42,7 +42,7 @@ class HftUsageZoneArchetype: @property def heating_setpoint(self): """ - Get usages zone heating set point in celsius grads + Get usage zone heating set point in celsius grads :return: float """ return self._heating_setpoint @@ -50,7 +50,7 @@ class HftUsageZoneArchetype: @property def heating_setback(self): """ - Get usages zone heating setback in celsius grads + Get usage zone heating setback in celsius grads :return: float """ return self._heating_setback @@ -58,7 +58,7 @@ class HftUsageZoneArchetype: @property def cooling_setpoint(self): """ - Get usages zone cooling setpoint in celsius grads + Get usage zone cooling setpoint in celsius grads :return: float """ return self._cooling_setpoint @@ -66,7 +66,7 @@ class HftUsageZoneArchetype: @property def hours_day(self): """ - Get usages zone usages hours per day + Get usage zone usage hours per day :return: float """ return self._hours_day @@ -74,7 +74,7 @@ class HftUsageZoneArchetype: @property def days_year(self): """ - Get usages zone usages days per year + Get usage zone usage days per year :return: float """ return self._days_year @@ -82,7 +82,7 @@ class HftUsageZoneArchetype: @property def mechanical_air_change(self): """ - Set usages zone mechanical air change in air change per hour (ACH) + Set usage zone mechanical air change in air change per hour (ACH) :return: float """ return self._mechanical_air_change @@ -90,7 +90,7 @@ class HftUsageZoneArchetype: @property def usage(self): """ - Get usages zone usages + Get usage zone usage :return: str """ return self._usage diff --git a/imports/usages/helpers/usage_helper.py b/imports/usage/helpers/usage_helper.py similarity index 90% rename from imports/usages/helpers/usage_helper.py rename to imports/usage/helpers/usage_helper.py index 43476b6e..e1f27e3a 100644 --- a/imports/usages/helpers/usage_helper.py +++ b/imports/usage/helpers/usage_helper.py @@ -23,12 +23,12 @@ class UsageHelper: @staticmethod def hft_from_usage(usage): """ - Get HfT usages from the given internal usages key + Get HfT usage from the given internal usage key :param usage: str :return: str """ try: return UsageHelper.usage_to_hft[usage] except KeyError: - sys.stderr.write('Error: keyword not found. Returned default HfT usages "residential"\n') + sys.stderr.write('Error: keyword not found. Returned default HfT usage "residential"\n') return UsageHelper.hft_default_value diff --git a/imports/usages/hft_usage_interface.py b/imports/usage/hft_usage_interface.py similarity index 97% rename from imports/usages/hft_usage_interface.py rename to imports/usage/hft_usage_interface.py index 2cd43efb..79a3d26f 100644 --- a/imports/usages/hft_usage_interface.py +++ b/imports/usage/hft_usage_interface.py @@ -1,12 +1,12 @@ """ Hft-based interface, it reads format defined within the CERC team based on that one used in SimStadt and developed by -the IAF team at hft-Stuttgart and enriches the city with usages parameters +the IAF team at hft-Stuttgart and enriches the city with usage parameters SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ import xmltodict -from imports.usages.data_classes.hft_usage_zone_archetype import HftUsageZoneArchetype as huza -from imports.usages.data_classes.hft_internal_gains_archetype import HftInternalGainsArchetype as higa +from imports.usage.data_classes.hft_usage_zone_archetype import HftUsageZoneArchetype as huza +from imports.usage.data_classes.hft_internal_gains_archetype import HftInternalGainsArchetype as higa class HftUsageInterface: diff --git a/imports/usages/hft_usage_parameters.py b/imports/usage/hft_usage_parameters.py similarity index 92% rename from imports/usages/hft_usage_parameters.py rename to imports/usage/hft_usage_parameters.py index f4dfb924..40b2883b 100644 --- a/imports/usages/hft_usage_parameters.py +++ b/imports/usage/hft_usage_parameters.py @@ -1,12 +1,12 @@ """ -HftUsageParameters model the usages properties +HftUsageParameters model the usage properties SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ import sys from imports.geometry.helpers.geometry_helper import GeometryHelper as gh -from imports.usages.hft_usage_interface import HftUsageInterface +from imports.usage.hft_usage_interface import HftUsageInterface from city_model_structure.attributes.usage_zone import UsageZone from city_model_structure.attributes.internal_gains import InternalGains @@ -25,7 +25,7 @@ class HftUsageParameters(HftUsageInterface): def enrich_buildings(self): """ - Returns the city with the usages parameters assigned to the buildings + Returns the city with the usage parameters assigned to the buildings :return: """ city = self._city @@ -33,10 +33,10 @@ class HftUsageParameters(HftUsageInterface): archetype = self._search_archetype(gh.usage_from_function(building.function)) if archetype is None: sys.stderr.write(f'Building {building.name} has unknown archetype for building function:' - f' {building.function}, that assigns building usages as ' + f' {building.function}, that assigns building usage as ' f'{gh.usage_from_function(building.function)}\n') continue - # todo: what to do with mix-usages usages from gml? + # todo: what to do with mix-usage usage from gml? mix_usage = False if not mix_usage: # just one usage_zone diff --git a/imports/usage_factory.py b/imports/usage_factory.py index 90e708b3..190d5bf3 100644 --- a/imports/usage_factory.py +++ b/imports/usage_factory.py @@ -1,10 +1,10 @@ """ -UsageFactory retrieve the specific usages module for the given region +UsageFactory retrieve the specific usage module for the given region SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ from pathlib import Path -from imports.usages.hft_usage_parameters import HftUsageParameters +from imports.usage.hft_usage_parameters import HftUsageParameters class UsageFactory: @@ -24,7 +24,7 @@ class UsageFactory: def enrich(self): """ - Enrich the city with the usages information + Enrich the city with the usage information :return: None """ getattr(self, self._handler, lambda: None)() diff --git a/imports/weather_factory.py b/imports/weather_factory.py index 91f30db9..b0f99e65 100644 --- a/imports/weather_factory.py +++ b/imports/weather_factory.py @@ -39,7 +39,7 @@ class WeatherFactory: def enrich(self): """ - Enrich the city with the usages information + Enrich the city with the usage information :return: None """ getattr(self, self._handler, lambda: None)() diff --git a/non_functional_tests/test_sensors_factory.py b/non_functional_tests/test_sensors_factory.py index 998d2504..cb5a08e3 100644 --- a/non_functional_tests/test_sensors_factory.py +++ b/non_functional_tests/test_sensors_factory.py @@ -8,7 +8,7 @@ from unittest import TestCase import pandas as pd from city_model_structure.city import City from city_model_structure.building import Building -from city_model_structure.parts_consisting_building import PartsConsistingBuilding +from city_model_structure.buildings_cluster import BuildingsCluster from imports.sensors_factory import SensorsFactory @@ -42,7 +42,7 @@ class TestSensorsFactory(TestCase): buildings.append(Building("MB", lod, surfaces, year_of_construction, function, lower_corner)) for building in buildings: city.add_city_object(building) - buildings_cluster = PartsConsistingBuilding("GM_MB_EV", buildings) + buildings_cluster = BuildingsCluster("GM_MB_EV", buildings) city.add_city_objects_cluster(buildings_cluster) return city @@ -51,9 +51,6 @@ class TestSensorsFactory(TestCase): SensorsFactory('cgf', self._city, self._end_point).enrich() SensorsFactory('ct', self._city, self._end_point).enrich() for city_object in self._city.city_objects: + print(city_object.name, len(city_object.sensors)) for sensor in city_object.sensors: - self.assertTrue(f'{row}' == '12345.0') - - for city_objects_cluster in self._city.city_objects_clusters: - for sensor in city_objects_cluster.sensors: - self.assertTrue(f'{row}' == '12345.0') + print(sensor.name) diff --git a/non_functional_tests/test_usage_factory.py b/non_functional_tests/test_usage_factory.py index e46cd50f..2d13d4e5 100644 --- a/non_functional_tests/test_usage_factory.py +++ b/non_functional_tests/test_usage_factory.py @@ -1,5 +1,5 @@ """ -TestUsageFactory test and validate the city model structure usages parameters +TestUsageFactory test and validate the city model structure usage parameters SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ @@ -31,7 +31,7 @@ class TestUsageFactory(TestCase): def test_city_with_usage(self): """ - Enrich the city with the usages information and verify it + Enrich the city with the usage information and verify it :return: None """ file = 'pluto_building.gml' @@ -44,14 +44,14 @@ class TestUsageFactory(TestCase): for building in city.buildings: self.assertIsNotNone(building.usage_zones, 'usage_zones not created') for usage_zone in building.usage_zones: - self.assertIsNotNone(usage_zone.usage, 'usages is none') - self.assertIsNotNone(usage_zone.internal_gains, 'usages is none') - self.assertIsNotNone(usage_zone.cooling_setpoint, 'usages is none') - self.assertIsNotNone(usage_zone.heating_setback, 'usages is none') - self.assertIsNotNone(usage_zone.heating_setpoint, 'usages is none') - self.assertIsNotNone(usage_zone.occupancy_density, 'usages is none') - self.assertIsNotNone(usage_zone.hours_day, 'usages is none') - self.assertIsNotNone(usage_zone.days_year, 'usages is none') - self.assertIsNotNone(usage_zone.dhw_average_volume_pers_day, 'usages is none') - self.assertIsNotNone(usage_zone.dhw_preparation_temperature, 'usages is none') - self.assertIsNotNone(usage_zone.electrical_app_average_consumption_sqm_year, 'usages is none') + self.assertIsNotNone(usage_zone.usage, 'usage is none') + self.assertIsNotNone(usage_zone.internal_gains, 'usage is none') + self.assertIsNotNone(usage_zone.cooling_setpoint, 'usage is none') + self.assertIsNotNone(usage_zone.heating_setback, 'usage is none') + self.assertIsNotNone(usage_zone.heating_setpoint, 'usage is none') + self.assertIsNotNone(usage_zone.occupancy_density, 'usage is none') + self.assertIsNotNone(usage_zone.hours_day, 'usage is none') + self.assertIsNotNone(usage_zone.days_year, 'usage is none') + self.assertIsNotNone(usage_zone.dhw_average_volume_pers_day, 'usage is none') + self.assertIsNotNone(usage_zone.dhw_preparation_temperature, 'usage is none') + self.assertIsNotNone(usage_zone.electrical_app_average_consumption_sqm_year, 'usage is none')