Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
40a52e3966
|
@ -13,22 +13,32 @@ class ConcordiaEnergySensor(Sensor):
|
||||||
Concordia energy sensor.
|
Concordia energy sensor.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name, measures):
|
def __init__(self, name):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self._name = name
|
self._name = name
|
||||||
self._interval = 5
|
self._interval = 5
|
||||||
self._interval_units = 'minutes'
|
self._interval_units = 'minutes'
|
||||||
self._type = 'ConcordiaEnergySensor'
|
self._type = 'ConcordiaEnergySensor'
|
||||||
self._units = 'kW/h'
|
self._units = 'kWh'
|
||||||
self._measures = measures
|
self._measures = pd.DataFrame(columns=["Date time", "Energy consumption"])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def measures(self) -> pd.DataFrame:
|
def measures(self) -> pd.DataFrame:
|
||||||
|
"""
|
||||||
|
Sensor measures [yyyy-mm-dd, hh:mm:ss kWh]
|
||||||
|
:return: DataFrame["Date time", "Energy consumption"]
|
||||||
|
"""
|
||||||
return self._measures
|
return self._measures
|
||||||
|
|
||||||
@measures.deleter
|
@measures.deleter
|
||||||
def measures(self):
|
def measures(self):
|
||||||
self._measures.drop = None
|
self._measures.drop = None
|
||||||
|
|
||||||
def add_period(self, period):
|
|
||||||
self._measures.append(period)
|
def add_period(self, measures):
|
||||||
|
"""
|
||||||
|
Add or update a period measures to the dataframe
|
||||||
|
"""
|
||||||
|
measures = self._measures.append(measures, ignore_index=True)
|
||||||
|
self._measures = measures.drop_duplicates('Date time', keep='last')
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
|
||||||
|
|
||||||
|
|
||||||
class Sensor:
|
class Sensor:
|
||||||
|
"""
|
||||||
|
Sensor abstract class
|
||||||
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._name = None
|
self._name = None
|
||||||
self._type = None
|
self._type = None
|
||||||
|
|
|
@ -10,8 +10,6 @@ import sys
|
||||||
from typing import List
|
from typing import List
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import math
|
import math
|
||||||
|
|
||||||
from city_model_structure.attributes.sensor import Sensor
|
|
||||||
from city_model_structure.attributes.surface import Surface
|
from city_model_structure.attributes.surface import Surface
|
||||||
from city_model_structure.attributes.thermal_boundary import ThermalBoundary
|
from city_model_structure.attributes.thermal_boundary import ThermalBoundary
|
||||||
from city_model_structure.attributes.thermal_zone import ThermalZone
|
from city_model_structure.attributes.thermal_zone import ThermalZone
|
||||||
|
@ -47,7 +45,6 @@ class Building(CityObject):
|
||||||
self._roofs = []
|
self._roofs = []
|
||||||
self._walls = []
|
self._walls = []
|
||||||
self._internal_walls = []
|
self._internal_walls = []
|
||||||
self._sensors = []
|
|
||||||
|
|
||||||
self._thermal_zones = []
|
self._thermal_zones = []
|
||||||
zone_surfaces = None
|
zone_surfaces = None
|
||||||
|
@ -382,11 +379,3 @@ class Building(CityObject):
|
||||||
@pv_plus_hp_installation.setter
|
@pv_plus_hp_installation.setter
|
||||||
def pv_plus_hp_installation(self, value):
|
def pv_plus_hp_installation(self, value):
|
||||||
self._pv_plus_hp_installation = value
|
self._pv_plus_hp_installation = value
|
||||||
|
|
||||||
@property
|
|
||||||
def sensors(self) -> List[Sensor]:
|
|
||||||
return self._sensors
|
|
||||||
|
|
||||||
@sensors.setter
|
|
||||||
def sensors(self, value):
|
|
||||||
self._sensors = value
|
|
|
@ -3,6 +3,7 @@ CityObject module
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
|
from city_model_structure.attributes.sensor import Sensor
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
from city_model_structure.attributes.surface import Surface
|
from city_model_structure.attributes.surface import Surface
|
||||||
from city_model_structure.attributes.polyhedron import Polyhedron
|
from city_model_structure.attributes.polyhedron import Polyhedron
|
||||||
|
@ -32,6 +33,7 @@ class CityObject:
|
||||||
self._global_horizontal = dict()
|
self._global_horizontal = dict()
|
||||||
self._diffuse = dict()
|
self._diffuse = dict()
|
||||||
self._beam = dict()
|
self._beam = dict()
|
||||||
|
self._sensors = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lod(self):
|
def lod(self):
|
||||||
|
@ -201,6 +203,25 @@ class CityObject:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def city_object_lower_corner(self):
|
def city_object_lower_corner(self):
|
||||||
|
"""
|
||||||
|
City object lower corner coordinates [x, y, z]
|
||||||
|
"""
|
||||||
if self._city_object_lower_corner is None:
|
if self._city_object_lower_corner is None:
|
||||||
self._city_object_lower_corner = [self._min_x, self._min_y, self._min_z]
|
self._city_object_lower_corner = [self._min_x, self._min_y, self._min_z]
|
||||||
return self._city_object_lower_corner
|
return self._city_object_lower_corner
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sensors(self) -> List[Sensor]:
|
||||||
|
"""
|
||||||
|
Sensor list belonging to the city object
|
||||||
|
:return: [Sensor]
|
||||||
|
"""
|
||||||
|
return self._sensors
|
||||||
|
|
||||||
|
@sensors.setter
|
||||||
|
def sensors(self, value):
|
||||||
|
"""
|
||||||
|
Sensor list belonging to the city object
|
||||||
|
:param value: [Sensor]
|
||||||
|
"""
|
||||||
|
self._sensors = value
|
|
@ -60,7 +60,17 @@ class ConcordiaEnergyConsumption:
|
||||||
building_measures = [measures["Date time"], measures[self._sensor_point[self._sensors[i]]]]
|
building_measures = [measures["Date time"], measures[self._sensor_point[self._sensors[i]]]]
|
||||||
building_headers = ["Date time", "Energy consumption"]
|
building_headers = ["Date time", "Energy consumption"]
|
||||||
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
building_energy_consumption = pd.concat(building_measures, keys=building_headers, axis=1)
|
||||||
building.sensors.append(ConcordiaEnergySensor( self._sensors[i], building_energy_consumption))
|
sensor = ConcordiaEnergySensor(self._sensors[i])
|
||||||
|
sensor_exist = False
|
||||||
|
for j in range(len(building.sensors)):
|
||||||
|
if building.sensors[j].name is sensor.name:
|
||||||
|
building.sensors[j].add_period(building_energy_consumption)
|
||||||
|
sensor_exist = True
|
||||||
|
break
|
||||||
|
if not sensor_exist:
|
||||||
|
sensor.add_period(building_energy_consumption)
|
||||||
|
building.sensors.append(sensor)
|
||||||
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def clean_line(line):
|
def clean_line(line):
|
||||||
|
|
|
@ -5,11 +5,13 @@ Copyright © 2021 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
import pandas as pd
|
||||||
from city_model_structure.city import City
|
from city_model_structure.city import City
|
||||||
from city_model_structure.building import Building
|
from city_model_structure.building import Building
|
||||||
from imports.sensors_factory import SensorsFactory
|
from imports.sensors_factory import SensorsFactory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestSensorsFactory(TestCase):
|
class TestSensorsFactory(TestCase):
|
||||||
"""
|
"""
|
||||||
TestSchedulesFactory TestCase
|
TestSchedulesFactory TestCase
|
||||||
|
@ -34,7 +36,7 @@ class TestSensorsFactory(TestCase):
|
||||||
year_of_construction = 2021
|
year_of_construction = 2021
|
||||||
function = "office"
|
function = "office"
|
||||||
buildings.append(Building("EV", lod, surfaces, year_of_construction, function, lower_corner))
|
buildings.append(Building("EV", lod, surfaces, year_of_construction, function, lower_corner))
|
||||||
buildings.append(Building("GM_2", lod, surfaces, year_of_construction, function, lower_corner))
|
buildings.append(Building("GM", lod, surfaces, year_of_construction, function, lower_corner))
|
||||||
return City(lower_corner, upper_corner, srs_name, buildings)
|
return City(lower_corner, upper_corner, srs_name, buildings)
|
||||||
|
|
||||||
def test_city_with_sensors(self):
|
def test_city_with_sensors(self):
|
||||||
|
@ -42,5 +44,9 @@ class TestSensorsFactory(TestCase):
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
for sensor in building.sensors:
|
for sensor in building.sensors:
|
||||||
self.assertTrue(sensor.type is 'ConcordiaEnergySensor')
|
self.assertTrue(sensor.type is 'ConcordiaEnergySensor')
|
||||||
print(f'{building.name} {sensor.name} {sensor.type}')
|
# force update last row
|
||||||
print(sensor.measures)
|
update = pd.DataFrame([['2020-01-19 23:55:00', '12345.0']], columns=["Date time", "Energy consumption"])
|
||||||
|
update = update.astype({"Date time": 'datetime64', "Energy consumption":'float64'})
|
||||||
|
sensor.add_period(update)
|
||||||
|
row = sensor.measures.loc[sensor.measures["Date time"] == '2020-01-19 23:55:00']['Energy consumption'].iloc[0]
|
||||||
|
self.assertTrue(f'{row}' == '12345.0')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user