Forced types in attributes

This commit is contained in:
Pilar 2021-09-14 13:46:48 -04:00
parent f4d62bb505
commit 2780dd5b7e
21 changed files with 523 additions and 368 deletions

View File

@ -5,6 +5,7 @@ Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
""" """
import uuid import uuid
from typing import Union, List
class Schedule: class Schedule:
@ -31,10 +32,10 @@ class Schedule:
return self._id return self._id
@property @property
def type(self): def type(self) -> Union[None, str]:
""" """
Get schedule type Get schedule type
:return: str :return: None or str
""" """
return self._type return self._type
@ -44,13 +45,14 @@ class Schedule:
Set schedule type Set schedule type
:param: str :param: str
""" """
if value is not None:
self._type = str(value) self._type = str(value)
@property @property
def values(self): def values(self):
""" """
Get schedule values Get schedule values
:return: Union([float], [int]) :return: [Any]
""" """
return self._values return self._values
@ -58,16 +60,16 @@ class Schedule:
def values(self, value): def values(self, value):
""" """
Set schedule values Set schedule values
:param: Union([float], [int]) :param: [Any]
""" """
self._values = value self._values = value
@property @property
def data_type(self): def data_type(self) -> Union[None, str]:
""" """
Get schedule data type from: Get schedule data type from:
['any_number', 'fraction', 'on_off', 'temperature', 'humidity', 'control_type'] ['any_number', 'fraction', 'on_off', 'temperature', 'humidity', 'control_type']
:return: str :return: None or str
""" """
return self._data_type return self._data_type
@ -77,14 +79,15 @@ class Schedule:
Set schedule data type Set schedule data type
:param: str :param: str
""" """
if value is not None:
self._data_type = str(value) self._data_type = str(value)
@property @property
def time_step(self): def time_step(self) -> Union[None, str]:
""" """
Get schedule time step from: Get schedule time step from:
['second', 'minute', 'hour', 'day', 'week', 'month'] ['second', 'minute', 'hour', 'day', 'week', 'month']
:return: str :return: None or str
""" """
return self._time_step return self._time_step
@ -94,14 +97,15 @@ class Schedule:
Set schedule time step Set schedule time step
:param: str :param: str
""" """
if value is not None:
self._time_step = str(value) self._time_step = str(value)
@property @property
def time_range(self): def time_range(self) -> Union[None, str]:
""" """
Get schedule time range from: Get schedule time range from:
['minute', 'hour', 'day', 'week', 'month', 'year'] ['minute', 'hour', 'day', 'week', 'month', 'year']
:return: str :return: None or str
""" """
return self._time_range return self._time_range
@ -111,15 +115,16 @@ class Schedule:
Set schedule time range Set schedule time range
:param: str :param: str
""" """
if value is not None:
self._time_range = str(value) self._time_range = str(value)
@property @property
def day_types(self): def day_types(self) -> Union[None, List[str]]:
""" """
Get schedule day types, as many as needed from: Get schedule day types, as many as needed from:
['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'holiday', 'winter_design_day', ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'holiday', 'winter_design_day',
'summer_design_day'] 'summer_design_day']
:return: [str] :return: None or [str]
""" """
return self._day_types return self._day_types
@ -129,4 +134,5 @@ class Schedule:
Set schedule day types Set schedule day types
:param: [str] :param: [str]
""" """
if value is not None:
self._day_types = [str(i) for i in value] self._day_types = [str(i) for i in value]

View File

@ -5,7 +5,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca contributors: Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
from typing import List from typing import List, Union
import numpy as np import numpy as np
from city_model_structure.building_demand.surface import Surface from city_model_structure.building_demand.surface import Surface
from city_model_structure.building_demand.thermal_zone import ThermalZone from city_model_structure.building_demand.thermal_zone import ThermalZone
@ -124,10 +124,10 @@ class Building(CityObject):
return self._terrains return self._terrains
@property @property
def attic_heated(self): def attic_heated(self) -> Union[None, int]:
""" """
Get if the city object attic is heated Get if the city object attic is heated
:return: Boolean :return: None or int
""" """
return self._attic_heated return self._attic_heated
@ -135,15 +135,16 @@ class Building(CityObject):
def attic_heated(self, value): def attic_heated(self, value):
""" """
Set if the city object attic is heated Set if the city object attic is heated
:param value: Boolean :param value: int
""" """
self._attic_heated = bool(value) if value is not None:
self._attic_heated = int(value)
@property @property
def basement_heated(self): def basement_heated(self) -> Union[None, int]:
""" """
Get if the city object basement is heated Get if the city object basement is heated
:return: Boolean :return: None or int
""" """
return self._basement_heated return self._basement_heated
@ -151,9 +152,10 @@ class Building(CityObject):
def basement_heated(self, value): def basement_heated(self, value):
""" """
Set if the city object basement is heated Set if the city object basement is heated
:param value: Boolean :param value: int
""" """
self._basement_heated = bool(value) if value is not None:
self._basement_heated = int(value)
@property @property
def name(self): def name(self):
@ -191,10 +193,10 @@ class Building(CityObject):
return self._year_of_construction return self._year_of_construction
@property @property
def function(self): def function(self) -> Union[None, str]:
""" """
Get building function Get building function
:return: str :return: None or str
""" """
return self._function return self._function
@ -204,13 +206,14 @@ class Building(CityObject):
Set building function Set building function
:param value: str :param value: str
""" """
if value is not None:
self._function = str(value) self._function = str(value)
@property @property
def average_storey_height(self): def average_storey_height(self) -> Union[None, float]:
""" """
Get building average storey height in meters Get building average storey height in meters
:return: float :return: None or float
""" """
return self._average_storey_height return self._average_storey_height
@ -220,13 +223,14 @@ class Building(CityObject):
Set building average storey height in meters Set building average storey height in meters
:param value: float :param value: float
""" """
if value is not None:
self._average_storey_height = float(value) self._average_storey_height = float(value)
@property @property
def storeys_above_ground(self): def storeys_above_ground(self) -> Union[None, int]:
""" """
Get building storeys number above ground Get building storeys number above ground
:return: int :return: None or int
""" """
return self._storeys_above_ground return self._storeys_above_ground
@ -236,6 +240,7 @@ class Building(CityObject):
Set building storeys number above ground Set building storeys number above ground
:param value: int :param value: int
""" """
if value is not None:
self._storeys_above_ground = int(value) self._storeys_above_ground = int(value)
@staticmethod @staticmethod

View File

@ -4,6 +4,8 @@ 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 typing import Union
class InternalGains: class InternalGains:
""" """
@ -17,10 +19,10 @@ class InternalGains:
self._latent_fraction = None self._latent_fraction = None
@property @property
def average_internal_gain(self): def average_internal_gain(self) -> Union[None, float]:
""" """
Get internal gains average internal gain in W/m2 Get internal gains average internal gain in W/m2
:return: float :return: None or float
""" """
return self._average_internal_gain return self._average_internal_gain
@ -28,15 +30,16 @@ class InternalGains:
def average_internal_gain(self, value): def average_internal_gain(self, value):
""" """
Set internal gains average internal gain in W/m2 Set internal gains average internal gain in W/m2
:param value: float :param value:float
""" """
if value is not None:
self._average_internal_gain = float(value) self._average_internal_gain = float(value)
@property @property
def convective_fraction(self): def convective_fraction(self) -> Union[None, float]:
""" """
Get internal gains convective fraction Get internal gains convective fraction
:return: float :return: None or float
""" """
return self._convective_fraction return self._convective_fraction
@ -46,13 +49,14 @@ class InternalGains:
Set internal gains convective fraction Set internal gains convective fraction
:param value: float :param value: float
""" """
if value is not None:
self._convective_fraction = float(value) self._convective_fraction = float(value)
@property @property
def radiative_fraction(self): def radiative_fraction(self) -> Union[None, float]:
""" """
Get internal gains radiative fraction Get internal gains radiative fraction
:return: float :return: None or float
""" """
return self._radiative_fraction return self._radiative_fraction
@ -62,13 +66,14 @@ class InternalGains:
Set internal gains convective fraction Set internal gains convective fraction
:param value: float :param value: float
""" """
if value is not None:
self._radiative_fraction = float(value) self._radiative_fraction = float(value)
@property @property
def latent_fraction(self): def latent_fraction(self) -> Union[None, float]:
""" """
Get internal gains latent fraction Get internal gains latent fraction
:return: float :return: None or float
""" """
return self._latent_fraction return self._latent_fraction
@ -78,4 +83,5 @@ class InternalGains:
Set internal gains latent fraction Set internal gains latent fraction
:param value: float :param value: float
""" """
if value is not None:
self._latent_fraction = float(value) self._latent_fraction = float(value)

View File

@ -4,6 +4,7 @@ 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
""" """
import uuid import uuid
from typing import Union
from city_model_structure.building_demand.material import Material from city_model_structure.building_demand.material import Material
@ -43,10 +44,10 @@ class Layer:
self._material = value self._material = value
@property @property
def thickness(self): def thickness(self) -> Union[None, float]:
""" """
Get layer thickness in meters Get layer thickness in meters
:return: float :return: None or float
""" """
return self._thickness return self._thickness
@ -56,4 +57,5 @@ class Layer:
Get layer thickness in meters Get layer thickness in meters
:param value: float :param value: float
""" """
if value is not None:
self._thickness = float(value) self._thickness = float(value)

View File

@ -4,6 +4,9 @@ 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
""" """
import ast
from typing import Union
class Material: class Material:
""" """
@ -37,10 +40,10 @@ class Material:
self._name = str(value) self._name = str(value)
@property @property
def conductivity(self): def conductivity(self) -> Union[None, float]:
""" """
Get material conductivity in W/mK Get material conductivity in W/mK
:return: float :return: None or float
""" """
return self._conductivity return self._conductivity
@ -50,13 +53,14 @@ class Material:
Set material conductivity in W/mK Set material conductivity in W/mK
:param value: float :param value: float
""" """
if value is not None:
self._conductivity = float(value) self._conductivity = float(value)
@property @property
def specific_heat(self): def specific_heat(self) -> Union[None, float]:
""" """
Get material conductivity in J/kgK Get material conductivity in J/kgK
:return: float :return: None or float
""" """
return self._specific_heat return self._specific_heat
@ -66,13 +70,14 @@ class Material:
Get material conductivity in J/kgK Get material conductivity in J/kgK
:param value: float :param value: float
""" """
if value is not None:
self._specific_heat = float(value) self._specific_heat = float(value)
@property @property
def density(self): def density(self) -> Union[None, float]:
""" """
Get material density in kg/m3 Get material density in kg/m3
:return: float :return: None or float
""" """
return self._density return self._density
@ -82,13 +87,14 @@ class Material:
Set material density in kg/m3 Set material density in kg/m3
:param value: float :param value: float
""" """
if value is not None:
self._density = float(value) self._density = float(value)
@property @property
def solar_absorptance(self): def solar_absorptance(self) -> Union[None, float]:
""" """
Get material solar absorptance Get material solar absorptance
:return: float :return: None or float
""" """
return self._solar_absorptance return self._solar_absorptance
@ -98,13 +104,14 @@ class Material:
Set material solar absorptance Set material solar absorptance
:param value: float :param value: float
""" """
if value is not None:
self._solar_absorptance = float(value) self._solar_absorptance = float(value)
@property @property
def thermal_absorptance(self): def thermal_absorptance(self) -> Union[None, float]:
""" """
Get material thermal absorptance Get material thermal absorptance
:return: float :return: None or float
""" """
return self._thermal_absorptance return self._thermal_absorptance
@ -114,13 +121,14 @@ class Material:
Set material thermal absorptance Set material thermal absorptance
:param value: float :param value: float
""" """
if value is not None:
self._thermal_absorptance = float(value) self._thermal_absorptance = float(value)
@property @property
def visible_absorptance(self): def visible_absorptance(self) -> Union[None, float]:
""" """
Get material visible absorptance Get material visible absorptance
:return: float :return: None or float
""" """
return self._visible_absorptance return self._visible_absorptance
@ -130,13 +138,14 @@ class Material:
Set material visible absorptance Set material visible absorptance
:param value: float :param value: float
""" """
if value is not None:
self._visible_absorptance = float(value) self._visible_absorptance = float(value)
@property @property
def no_mass(self): def no_mass(self) -> Union[None, bool]:
""" """
Get material no mass flag Get material no mass flag
:return: Boolean :return: None or Boolean
""" """
return self._no_mass return self._no_mass
@ -146,13 +155,14 @@ class Material:
Set material no mass flag Set material no mass flag
:param value: Boolean :param value: Boolean
""" """
self._no_mass = bool(value) if value is not None:
self._no_mass = value
@property @property
def thermal_resistance(self): def thermal_resistance(self) -> Union[None, float]:
""" """
Get material thermal resistance in m2K/W Get material thermal resistance in m2K/W
:return: float :return: None or float
""" """
return self._thermal_resistance return self._thermal_resistance
@ -162,4 +172,5 @@ class Material:
Set material thermal resistance in m2K/W Set material thermal resistance in m2K/W
:param value: float :param value: float
""" """
if value is not None:
self._thermal_resistance = float(value) self._thermal_resistance = float(value)

View File

@ -62,6 +62,15 @@ class Surface:
raise ValueError('Undefined surface id') raise ValueError('Undefined surface id')
return self._id return self._id
@id.setter
def id(self, value):
"""
Set the surface id
:param value: str
"""
if value is not None:
self._id = str(value)
@property @property
def share_surfaces(self): def share_surfaces(self):
""" """
@ -69,19 +78,11 @@ class Surface:
""" """
raise NotImplementedError raise NotImplementedError
@id.setter
def id(self, value):
"""
Set the surface id
:param value: str
"""
self._id = str(value)
@property @property
def swr(self): def swr(self) -> Union[None, float]:
""" """
Get surface short wave reflectance Get surface short wave reflectance
:return: float :return: None or float
""" """
return self._swr return self._swr
@ -91,6 +92,7 @@ class Surface:
Set surface short wave reflectance Set surface short wave reflectance
:param value: float :param value: float
""" """
if value is not None:
self._swr = float(value) self._swr = float(value)
def _max_coord(self, axis): def _max_coord(self, axis):

View File

@ -129,10 +129,10 @@ class ThermalBoundary:
return self._thickness return self._thickness
@property @property
def outside_solar_absorptance(self): def outside_solar_absorptance(self) -> Union[None, float]:
""" """
Get thermal boundary outside solar absorptance Get thermal boundary outside solar absorptance
:return: float :return: None or float
""" """
return self._outside_solar_absorptance return self._outside_solar_absorptance
@ -142,11 +142,12 @@ class ThermalBoundary:
Set thermal boundary outside solar absorptance Set thermal boundary outside solar absorptance
:param value: float :param value: float
""" """
if value is not None:
self._outside_solar_absorptance = float(value) self._outside_solar_absorptance = float(value)
self._shortwave_reflectance = 1.0 - value self._shortwave_reflectance = 1.0 - float(value)
@property @property
def outside_thermal_absorptance(self): def outside_thermal_absorptance(self) -> Union[None, float]:
""" """
Get thermal boundary outside thermal absorptance Get thermal boundary outside thermal absorptance
:return: float :return: float
@ -159,13 +160,14 @@ class ThermalBoundary:
Set thermal boundary outside thermal absorptance Set thermal boundary outside thermal absorptance
:param value: float :param value: float
""" """
if value is not None:
self._outside_thermal_absorptance = float(value) self._outside_thermal_absorptance = float(value)
@property @property
def outside_visible_absorptance(self): def outside_visible_absorptance(self) -> Union[None, float]:
""" """
Get thermal boundary outside visible absorptance Get thermal boundary outside visible absorptance
:return: float :return: None or float
""" """
return self._outside_visible_absorptance return self._outside_visible_absorptance
@ -175,6 +177,7 @@ class ThermalBoundary:
Set thermal boundary outside visible absorptance Set thermal boundary outside visible absorptance
:param value: float :param value: float
""" """
if value is not None:
self._outside_visible_absorptance = float(value) self._outside_visible_absorptance = float(value)
@property @property
@ -203,10 +206,10 @@ class ThermalBoundary:
self._thermal_openings = value self._thermal_openings = value
@property @property
def construction_name(self): def construction_name(self) -> Union[None, str]:
""" """
Get construction name Get construction name
:return: str :return: None or str
""" """
return self._construction_name return self._construction_name
@ -216,6 +219,7 @@ class ThermalBoundary:
Set construction name Set construction name
:param value: str :param value: str
""" """
if value is not None:
self._construction_name = str(value) self._construction_name = str(value)
@property @property
@ -243,10 +247,10 @@ class ThermalBoundary:
return self._surface.type return self._surface.type
@property @property
def window_ratio(self): def window_ratio(self) -> Union[None, float]:
""" """
Get thermal boundary window ratio Get thermal boundary window ratio
:return: float :return: None or float
""" """
return self._window_ratio return self._window_ratio
@ -256,14 +260,15 @@ class ThermalBoundary:
Set thermal boundary window ratio Set thermal boundary window ratio
:param value: float :param value: float
""" """
if value is not None:
self._window_ratio = float(value) self._window_ratio = float(value)
@property @property
def u_value(self): def u_value(self) -> Union[None, float]:
""" """
Get thermal boundary U-value in W/m2K Get thermal boundary U-value in W/m2K
internal and external convective coefficient in W/m2K values, can be configured at configuration.ini internal and external convective coefficient in W/m2K values, can be configured at configuration.ini
:return: float :return: None or float
""" """
if self._u_value is None: if self._u_value is None:
h_i = self.hi h_i = self.hi
@ -286,13 +291,14 @@ class ThermalBoundary:
Set thermal boundary U-value in W/m2K Set thermal boundary U-value in W/m2K
:param value: float :param value: float
""" """
if value is not None:
self._u_value = float(value) self._u_value = float(value)
@property @property
def shortwave_reflectance(self): def shortwave_reflectance(self) -> Union[None, float]:
""" """
Get thermal boundary shortwave reflectance Get thermal boundary shortwave reflectance
:return: float :return: None or float
""" """
return self._shortwave_reflectance return self._shortwave_reflectance
@ -302,14 +308,15 @@ class ThermalBoundary:
Set thermal boundary shortwave reflectance Set thermal boundary shortwave reflectance
:param value: float :param value: float
""" """
if value is not None:
self._shortwave_reflectance = float(value) self._shortwave_reflectance = float(value)
self._outside_solar_absorptance = 1.0 - value self._outside_solar_absorptance = 1.0 - float(value)
@property @property
def hi(self): def hi(self) -> Union[None, float]:
""" """
Get internal convective heat transfer coefficient (W/m2K) Get internal convective heat transfer coefficient (W/m2K)
:return: float :return: None or float
""" """
return self._hi return self._hi
@ -319,13 +326,14 @@ class ThermalBoundary:
Set internal convective heat transfer coefficient (W/m2K) Set internal convective heat transfer coefficient (W/m2K)
:param value: float :param value: float
""" """
if value is not None:
self._hi = float(value) self._hi = float(value)
@property @property
def he(self): def he(self) -> Union[None, float]:
""" """
Get external convective heat transfer coefficient (W/m2K) Get external convective heat transfer coefficient (W/m2K)
:return: float :return: None or float
""" """
return self._he return self._he
@ -335,6 +343,7 @@ class ThermalBoundary:
Set external convective heat transfer coefficient (W/m2K) Set external convective heat transfer coefficient (W/m2K)
:param value: float :param value: float
""" """
if value is not None:
self._he = float(value) self._he = float(value)
@property @property
@ -356,10 +365,10 @@ class ThermalBoundary:
# todo: need extract information from construction library or assume them at the beginning of workflows # todo: need extract information from construction library or assume them at the beginning of workflows
@property @property
def inside_emissivity(self): def inside_emissivity(self) -> Union[None, float]:
""" """
Get the short wave emissivity factor of the thermal boundary's internal surface (-) Get the short wave emissivity factor of the thermal boundary's internal surface (-)
:return: float :return: None or float
""" """
return self._inside_emissivity return self._inside_emissivity
@ -369,13 +378,14 @@ class ThermalBoundary:
Set short wave emissivity factor of the thermal boundary's internal surface (-) Set short wave emissivity factor of the thermal boundary's internal surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._inside_emissivity = float(value) self._inside_emissivity = float(value)
@property @property
def alpha_coefficient(self): def alpha_coefficient(self) -> Union[None, float]:
""" """
Get the long wave emissivity factor of the thermal boundary's internal surface (-) Get the long wave emissivity factor of the thermal boundary's internal surface (-)
:return: float :return: None or float
""" """
return self._alpha_coefficient return self._alpha_coefficient
@ -385,13 +395,14 @@ class ThermalBoundary:
Set long wave emissivity factor of the thermal boundary's internal surface (-) Set long wave emissivity factor of the thermal boundary's internal surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._alpha_coefficient = float(value) self._alpha_coefficient = float(value)
@property @property
def radiative_coefficient(self): def radiative_coefficient(self) -> Union[None, float]:
""" """
Get the radiative coefficient of the thermal boundary's external surface (-) Get the radiative coefficient of the thermal boundary's external surface (-)
:return: float :return: None or float
""" """
return self._radiative_coefficient return self._radiative_coefficient
@ -401,4 +412,5 @@ class ThermalBoundary:
Set radiative coefficient of the thermal boundary's external surface (-) Set radiative coefficient of the thermal boundary's external surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._radiative_coefficient = float(value) self._radiative_coefficient = float(value)

View File

@ -5,7 +5,7 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
import uuid import uuid
from typing import TypeVar from typing import TypeVar, Union
Polygon = TypeVar('Polygon') Polygon = TypeVar('Polygon')
@ -43,10 +43,10 @@ class ThermalOpening:
return self._id return self._id
@property @property
def area(self): def area(self) -> Union[None, float]:
""" """
Get thermal opening area in square meters Get thermal opening area in square meters
:return: float :return: None or float
""" """
return self._area return self._area
@ -56,6 +56,7 @@ class ThermalOpening:
Set thermal opening area in square meters Set thermal opening area in square meters
:param value: float :param value: float
""" """
if value is not None:
self._area = float(value) self._area = float(value)
@property @property
@ -73,10 +74,10 @@ class ThermalOpening:
raise NotImplementedError raise NotImplementedError
@property @property
def conductivity(self): def conductivity(self) -> Union[None, float]:
""" """
Get thermal opening conductivity in W/mK Get thermal opening conductivity in W/mK
:return: float :return: None or float
""" """
return self._conductivity return self._conductivity
@ -88,18 +89,19 @@ class ThermalOpening:
""" """
# The code to calculate overall_u_value is duplicated here and in thickness_m. # The code to calculate overall_u_value is duplicated here and in thickness_m.
# This ensures a more robust code that returns the overall_u_value regardless the order the parameters are read. # This ensures a more robust code that returns the overall_u_value regardless the order the parameters are read.
if value is not None:
self._conductivity = float(value) self._conductivity = float(value)
if self._overall_u_value is None and self.thickness is not None: if self._overall_u_value is None and self.thickness is not None:
h_i = self.hi h_i = self.hi
h_e = self.he h_e = self.he
r_value = 1 / h_i + 1 / h_e + float(self.conductivity) / float(self.thickness) r_value = 1 / h_i + 1 / h_e + float(self._conductivity) / float(self.thickness)
self._overall_u_value = 1 / r_value self._overall_u_value = 1 / r_value
@property @property
def frame_ratio(self): def frame_ratio(self) -> Union[None, float]:
""" """
Get thermal opening frame ratio Get thermal opening frame ratio
:return: float :return: None or float
""" """
return self._frame_ratio return self._frame_ratio
@ -109,13 +111,14 @@ class ThermalOpening:
Set thermal opening frame ratio Set thermal opening frame ratio
:param value: float :param value: float
""" """
if value is not None:
self._frame_ratio = float(value) self._frame_ratio = float(value)
@property @property
def g_value(self): def g_value(self) -> Union[None, float]:
""" """
Get thermal opening g-value Get thermal opening g-value
:return: float :return: None or float
""" """
return self._g_value return self._g_value
@ -125,13 +128,14 @@ class ThermalOpening:
Set thermal opening g-value Set thermal opening g-value
:param value: float :param value: float
""" """
if value is not None:
self._g_value = float(value) self._g_value = float(value)
@property @property
def thickness(self): def thickness(self) -> Union[None, float]:
""" """
Get thermal opening thickness in meters Get thermal opening thickness in meters
:return: float :return: None or float
""" """
return self._thickness return self._thickness
@ -143,18 +147,19 @@ class ThermalOpening:
""" """
# The code to calculate overall_u_value is duplicated here and in conductivity. # The code to calculate overall_u_value is duplicated here and in conductivity.
# This ensures a more robust code that returns the overall_u_value regardless the order the parameters are read. # This ensures a more robust code that returns the overall_u_value regardless the order the parameters are read.
if value is not None:
self._thickness = float(value) self._thickness = float(value)
if self._overall_u_value is None and self.conductivity is not None: if self._overall_u_value is None and self.conductivity is not None:
h_i = self.hi h_i = self.hi
h_e = self.he h_e = self.he
r_value = 1 / h_i + 1 / h_e + float(self.conductivity) / float(self.thickness) r_value = 1 / h_i + 1 / h_e + float(self.conductivity) / float(self._thickness)
self._overall_u_value = 1 / r_value self._overall_u_value = 1 / r_value
@property @property
def front_side_solar_transmittance_at_normal_incidence(self): def front_side_solar_transmittance_at_normal_incidence(self) -> Union[None, float]:
""" """
Get thermal opening front side solar transmittance at normal incidence Get thermal opening front side solar transmittance at normal incidence
:return: float :return: None or float
""" """
return self._front_side_solar_transmittance_at_normal_incidence return self._front_side_solar_transmittance_at_normal_incidence
@ -164,13 +169,14 @@ class ThermalOpening:
Set thermal opening front side solar transmittance at normal incidence Set thermal opening front side solar transmittance at normal incidence
:param value: float :param value: float
""" """
if value is not None:
self._front_side_solar_transmittance_at_normal_incidence = float(value) self._front_side_solar_transmittance_at_normal_incidence = float(value)
@property @property
def back_side_solar_transmittance_at_normal_incidence(self): def back_side_solar_transmittance_at_normal_incidence(self) -> Union[None, float]:
""" """
Get thermal opening back side solar transmittance at normal incidence Get thermal opening back side solar transmittance at normal incidence
:return: float :return: None or float
""" """
return self._back_side_solar_transmittance_at_normal_incidence return self._back_side_solar_transmittance_at_normal_incidence
@ -180,13 +186,14 @@ class ThermalOpening:
Set thermal opening back side solar transmittance at normal incidence Set thermal opening back side solar transmittance at normal incidence
:param value: float :param value: float
""" """
if value is not None:
self._back_side_solar_transmittance_at_normal_incidence = float(value) self._back_side_solar_transmittance_at_normal_incidence = float(value)
@property @property
def overall_u_value(self): def overall_u_value(self) -> Union[None, float]:
""" """
Get thermal opening overall U-value in W/m2K Get thermal opening overall U-value in W/m2K
:return: float :return: None or float
""" """
return self._overall_u_value return self._overall_u_value
@ -196,13 +203,14 @@ class ThermalOpening:
Set thermal opening overall U-value in W/m2K Set thermal opening overall U-value in W/m2K
:param value: float :param value: float
""" """
if value is not None:
self._overall_u_value = float(value) self._overall_u_value = float(value)
@property @property
def hi(self): def hi(self) -> Union[None, float]:
""" """
Get internal convective heat transfer coefficient (W/m2K) Get internal convective heat transfer coefficient (W/m2K)
:return: float :return: None or float
""" """
return self._hi return self._hi
@ -212,13 +220,14 @@ class ThermalOpening:
Set internal convective heat transfer coefficient (W/m2K) Set internal convective heat transfer coefficient (W/m2K)
:param value: float :param value: float
""" """
if value is not None:
self._hi = float(value) self._hi = float(value)
@property @property
def he(self): def he(self) -> Union[None, float]:
""" """
Get external convective heat transfer coefficient (W/m2K) Get external convective heat transfer coefficient (W/m2K)
:return: float :return: None or float
""" """
return self._he return self._he
@ -228,6 +237,7 @@ class ThermalOpening:
Set external convective heat transfer coefficient (W/m2K) Set external convective heat transfer coefficient (W/m2K)
:param value: float :param value: float
""" """
if value is not None:
self._he = float(value) self._he = float(value)
@property @property
@ -240,10 +250,10 @@ class ThermalOpening:
# todo: need extract information from construction library or assume them at the beginning of workflows # todo: need extract information from construction library or assume them at the beginning of workflows
@property @property
def inside_emissivity(self): def inside_emissivity(self) -> Union[None, float]:
""" """
Get the short wave emissivity factor of the thermal opening's internal surface (-) Get the short wave emissivity factor of the thermal opening's internal surface (-)
:return: float :return: None or float
""" """
return self._inside_emissivity return self._inside_emissivity
@ -253,13 +263,14 @@ class ThermalOpening:
Set short wave emissivity factor of the thermal opening's internal surface (-) Set short wave emissivity factor of the thermal opening's internal surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._inside_emissivity = float(value) self._inside_emissivity = float(value)
@property @property
def alpha_coefficient(self): def alpha_coefficient(self) -> Union[None, float]:
""" """
Get the long wave emissivity factor of the thermal opening's internal surface (-) Get the long wave emissivity factor of the thermal opening's internal surface (-)
:return: float :return: None or float
""" """
return self._alpha_coefficient return self._alpha_coefficient
@ -269,13 +280,14 @@ class ThermalOpening:
Set long wave emissivity factor of the thermal opening's internal surface (-) Set long wave emissivity factor of the thermal opening's internal surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._alpha_coefficient = float(value) self._alpha_coefficient = float(value)
@property @property
def radiative_coefficient(self): def radiative_coefficient(self) -> Union[None, float]:
""" """
Get the radiative coefficient of the thermal opening's external surface (-) Get the radiative coefficient of the thermal opening's external surface (-)
:return: float :return: None or float
""" """
return self._radiative_coefficient return self._radiative_coefficient
@ -285,4 +297,5 @@ class ThermalOpening:
Set radiative coefficient of the thermal opening's external surface (-) Set radiative coefficient of the thermal opening's external surface (-)
:param value: float :param value: float
""" """
if value is not None:
self._radiative_coefficient = float(value) self._radiative_coefficient = float(value)

View File

@ -5,8 +5,9 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
import uuid import uuid
from typing import List, TypeVar from typing import List, TypeVar, Union
from city_model_structure.building_demand.usage_zone import UsageZone from city_model_structure.building_demand.usage_zone import UsageZone
import ast
ThermalBoundary = TypeVar('ThermalBoundary') ThermalBoundary = TypeVar('ThermalBoundary')
Polyhedron = TypeVar('Polyhedron') Polyhedron = TypeVar('Polyhedron')
@ -42,13 +43,22 @@ class ThermalZone:
return self._id return self._id
@property @property
def is_mechanically_ventilated(self): def is_mechanically_ventilated(self) -> Union[None, bool]:
""" """
Get thermal zone mechanical ventilation flag Get thermal zone mechanical ventilation flag
:return: Boolean :return: None or Boolean
""" """
return self._is_mechanically_ventilated return self._is_mechanically_ventilated
@is_mechanically_ventilated.setter
def is_mechanically_ventilated(self, value):
"""
Set thermal zone mechanical ventilation flag
:param value: Boolean
"""
if value is not None:
self._is_mechanically_ventilated = ast.literal_eval(value)
@property @property
def floor_area(self): def floor_area(self):
""" """
@ -72,10 +82,10 @@ class ThermalZone:
return self._thermal_boundaries return self._thermal_boundaries
@property @property
def additional_thermal_bridge_u_value(self): def additional_thermal_bridge_u_value(self) -> Union[None, float]:
""" """
Get thermal zone additional thermal bridge u value W/m2K Get thermal zone additional thermal bridge u value W/m2K
:return: float :return: None or float
""" """
return self._additional_thermal_bridge_u_value return self._additional_thermal_bridge_u_value
@ -85,13 +95,14 @@ class ThermalZone:
Set thermal zone additional thermal bridge u value W/m2K Set thermal zone additional thermal bridge u value W/m2K
:param value: float :param value: float
""" """
if value is not None:
self._additional_thermal_bridge_u_value = float(value) self._additional_thermal_bridge_u_value = float(value)
@property @property
def effective_thermal_capacity(self): def effective_thermal_capacity(self) -> Union[None, float]:
""" """
Get thermal zone effective thermal capacity in J/m2K Get thermal zone effective thermal capacity in J/m2K
:return: float :return: None or float
""" """
return self._effective_thermal_capacity return self._effective_thermal_capacity
@ -101,13 +112,14 @@ class ThermalZone:
Set thermal zone effective thermal capacity in J/m2K Set thermal zone effective thermal capacity in J/m2K
:param value: float :param value: float
""" """
if value is not None:
self._effective_thermal_capacity = float(value) self._effective_thermal_capacity = float(value)
@property @property
def indirectly_heated_area_ratio(self): def indirectly_heated_area_ratio(self) -> Union[None, float]:
""" """
Get thermal zone indirectly heated area ratio Get thermal zone indirectly heated area ratio
:return: float :return: None or float
""" """
return self._indirectly_heated_area_ratio return self._indirectly_heated_area_ratio
@ -117,13 +129,14 @@ class ThermalZone:
Set thermal zone indirectly heated area ratio Set thermal zone indirectly heated area ratio
:param value: float :param value: float
""" """
if value is not None:
self._indirectly_heated_area_ratio = float(value) self._indirectly_heated_area_ratio = float(value)
@property @property
def infiltration_rate_system_on(self): def infiltration_rate_system_on(self) -> Union[None, float]:
""" """
Get thermal zone infiltration rate system on in air changes per hour (ACH) Get thermal zone infiltration rate system on in air changes per hour (ACH)
:return: float :return: None or float
""" """
return self._infiltration_rate_system_on return self._infiltration_rate_system_on
@ -133,13 +146,14 @@ class ThermalZone:
Set thermal zone infiltration rate system on in air changes per hour (ACH) Set thermal zone infiltration rate system on in air changes per hour (ACH)
:param value: float :param value: float
""" """
if value is not None:
self._infiltration_rate_system_on = float(value) self._infiltration_rate_system_on = float(value)
@property @property
def infiltration_rate_system_off(self): def infiltration_rate_system_off(self) -> Union[None, float]:
""" """
Get thermal zone infiltration rate system off in air changes per hour (ACH) Get thermal zone infiltration rate system off in air changes per hour (ACH)
:return: float :return: None or float
""" """
return self._infiltration_rate_system_off return self._infiltration_rate_system_off
@ -149,6 +163,7 @@ class ThermalZone:
Set thermal zone infiltration rate system on in air changes per hour (ACH) Set thermal zone infiltration rate system on in air changes per hour (ACH)
:param value: float :param value: float
""" """
if value is not None:
self._infiltration_rate_system_off = float(value) self._infiltration_rate_system_off = float(value)
@property @property
@ -184,10 +199,10 @@ class ThermalZone:
return self._volume_geometry return self._volume_geometry
@property @property
def ordinate_number(self): def ordinate_number(self) -> Union[None, int]:
""" """
Get the order in which the thermal_zones need to be enumerated Get the order in which the thermal_zones need to be enumerated
:return: int :return: None or int
""" """
return self._ordinate_number return self._ordinate_number
@ -197,4 +212,5 @@ class ThermalZone:
Set a specific order of the zones to be called Set a specific order of the zones to be called
:param value: int :param value: int
""" """
if value is not None:
self._ordinate_number = int(value) self._ordinate_number = int(value)

View File

@ -5,7 +5,8 @@ Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
Contributors Guille Gutierrez guillermo.gutierrezmorote@concordia.ca Contributors Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
""" """
import uuid import uuid
from typing import List, TypeVar from typing import List, TypeVar, Union
import ast
InternalGains = TypeVar('InternalGains') InternalGains = TypeVar('InternalGains')
Occupants = TypeVar('Occupants') Occupants = TypeVar('Occupants')
@ -24,6 +25,7 @@ class UsageZone:
self._heating_setpoint = None self._heating_setpoint = None
self._heating_setback = None self._heating_setback = None
self._cooling_setpoint = None self._cooling_setpoint = None
self._occupancy_density = None
self._hours_day = None self._hours_day = None
self._days_year = None self._days_year = None
self._dhw_average_volume_pers_day = None self._dhw_average_volume_pers_day = None
@ -64,10 +66,10 @@ class UsageZone:
self._internal_gains = value self._internal_gains = value
@property @property
def heating_setpoint(self): def heating_setpoint(self) -> Union[None, float]:
""" """
Get usage zone heating set point in Celsius Get usage zone heating set point in Celsius
:return: float :return: None or float
""" """
return self._heating_setpoint return self._heating_setpoint
@ -77,13 +79,14 @@ class UsageZone:
Set usage zone heating set point in Celsius Set usage zone heating set point in Celsius
:param value: float :param value: float
""" """
if value is not None:
self._heating_setpoint = float(value) self._heating_setpoint = float(value)
@property @property
def heating_setback(self): def heating_setback(self) -> Union[None, float]:
""" """
Get usage zone heating setback in Celsius Get usage zone heating setback in Celsius
:return: float :return: None or float
""" """
return self._heating_setback return self._heating_setback
@ -93,13 +96,14 @@ class UsageZone:
Set usage zone heating setback in Celsius Set usage zone heating setback in Celsius
:param value: float :param value: float
""" """
if value is not None:
self._heating_setback = float(value) self._heating_setback = float(value)
@property @property
def cooling_setpoint(self): def cooling_setpoint(self) -> Union[None, float]:
""" """
Get usage zone cooling setpoint in Celsius Get usage zone cooling setpoint in Celsius
:return: float :return: None or float
""" """
return self._cooling_setpoint return self._cooling_setpoint
@ -109,13 +113,14 @@ class UsageZone:
Set usage zone cooling setpoint in Celsius Set usage zone cooling setpoint in Celsius
:param value: float :param value: float
""" """
if value is not None:
self._cooling_setpoint = float(value) self._cooling_setpoint = float(value)
@property @property
def hours_day(self): def hours_day(self) -> Union[None, float]:
""" """
Get usage zone usage hours per day Get usage zone usage hours per day
:return: float :return: None or float
""" """
return self._hours_day return self._hours_day
@ -125,13 +130,14 @@ class UsageZone:
Set usage zone usage hours per day Set usage zone usage hours per day
:param value: float :param value: float
""" """
if value is not None:
self._hours_day = float(value) self._hours_day = float(value)
@property @property
def days_year(self): def days_year(self) -> Union[None, float]:
""" """
Get usage zone usage days per year Get usage zone usage days per year
:return: float :return: None or float
""" """
return self._days_year return self._days_year
@ -141,13 +147,14 @@ class UsageZone:
Set usage zone usage days per year Set usage zone usage days per year
:param value: float :param value: float
""" """
if value is not None:
self._days_year = float(value) self._days_year = float(value)
@property @property
def mechanical_air_change(self): def mechanical_air_change(self) -> Union[None, float]:
""" """
Get usage zone mechanical air change in air change per hour (ACH) Get usage zone mechanical air change in air change per hour (ACH)
:return: float :return: None or float
""" """
return self._mechanical_air_change return self._mechanical_air_change
@ -157,13 +164,14 @@ class UsageZone:
Set usage zone mechanical air change in air change per hour (ACH) Set usage zone mechanical air change in air change per hour (ACH)
:param value: float :param value: float
""" """
if value is not None:
self._mechanical_air_change = float(value) self._mechanical_air_change = float(value)
@property @property
def usage(self): def usage(self) -> Union[None, str]:
""" """
Get usage zone usage Get usage zone usage
:return: str :return: None or str
""" """
return self._usage return self._usage
@ -173,6 +181,7 @@ class UsageZone:
Set usage zone usage Set usage zone usage
:param value: str :param value: str
""" """
if value is not None:
self._usage = str(value) self._usage = str(value)
@property @property
@ -208,26 +217,44 @@ class UsageZone:
self._schedules = values self._schedules = values
@property @property
def dhw_average_volume_pers_day(self): def occupancy_density(self) -> Union[None, float]:
"""
Get density in persons per m2
:return: None or float
"""
return self._occupancy_density
@occupancy_density.setter
def occupancy_density(self, value):
"""
Set density in persons per m2
:param value: float
"""
if value is not None:
self._occupancy_density = float(value)
@property
def dhw_average_volume_pers_day(self) -> Union[None, float]:
""" """
Get average DHW consumption in cubic meters per person per day Get average DHW consumption in cubic meters per person per day
:return: float :return: None or float
""" """
return self._dhw_average_volume_pers_day return self._dhw_average_volume_pers_day
@dhw_average_volume_pers_day.setter @dhw_average_volume_pers_day.setter
def dhw_average_volume_pers_day(self, values): def dhw_average_volume_pers_day(self, value):
""" """
Set average DHW consumption in cubic meters per person per day Set average DHW consumption in cubic meters per person per day
:param values: float :param value: float
""" """
self._dhw_average_volume_pers_day = float(values) if value is not None:
self._dhw_average_volume_pers_day = float(value)
@property @property
def dhw_preparation_temperature(self): def dhw_preparation_temperature(self) -> Union[None, float]:
""" """
Get preparation temperature of the DHW in Celsius Get preparation temperature of the DHW in Celsius
:return: float :return: None or float
""" """
return self._dhw_preparation_temperature return self._dhw_preparation_temperature
@ -237,13 +264,14 @@ class UsageZone:
Set preparation temperature of the DHW in Celsius Set preparation temperature of the DHW in Celsius
:param value: float :param value: float
""" """
if value is not None:
self._dhw_preparation_temperature = float(value) self._dhw_preparation_temperature = float(value)
@property @property
def electrical_app_average_consumption_sqm_year(self): def electrical_app_average_consumption_sqm_year(self) -> Union[None, float]:
""" """
Get average consumption of electrical appliances in Joules hour per square meter and year (J/m2yr) Get average consumption of electrical appliances in Joules hour per square meter and year (J/m2yr)
:return: float :return: None or float
""" """
return self._electrical_app_average_consumption_sqm_year return self._electrical_app_average_consumption_sqm_year
@ -253,6 +281,7 @@ class UsageZone:
Set average consumption of electrical appliances in Joules per square meter and year (J/m2yr) Set average consumption of electrical appliances in Joules per square meter and year (J/m2yr)
:param value: float :param value: float
""" """
if value is not None:
self._electrical_app_average_consumption_sqm_year = float(value) self._electrical_app_average_consumption_sqm_year = float(value)
@property @property
@ -264,10 +293,10 @@ class UsageZone:
return self._volume_geometry return self._volume_geometry
@property @property
def volume(self): def volume(self) -> Union[None, float]:
""" """
Get the volume in cubic meters Get the volume in cubic meters
:return: float :return: None or float
""" """
return self._volume return self._volume
@ -277,13 +306,14 @@ class UsageZone:
Set volume in cubic meters Set volume in cubic meters
:param value: float :param value: float
""" """
if value is not None:
self._volume = float(value) self._volume = float(value)
@property @property
def is_heated(self): def is_heated(self) -> Union[None, bool]:
""" """
Get thermal zone heated flag Get thermal zone heated flag
:return: Boolean :return: None or Boolean
""" """
return self._is_heated return self._is_heated
@ -293,13 +323,14 @@ class UsageZone:
Set thermal zone heated flag Set thermal zone heated flag
:param value: Boolean :param value: Boolean
""" """
self._is_heated = bool(value) if value is not None:
self._is_heated = ast.literal_eval(value)
@property @property
def is_cooled(self): def is_cooled(self) -> Union[None, bool]:
""" """
Get thermal zone cooled flag Get thermal zone cooled flag
:return: Boolean :return: None or Boolean
""" """
return self._is_cooled return self._is_cooled
@ -309,4 +340,5 @@ class UsageZone:
Set thermal zone cooled flag Set thermal zone cooled flag
:param value: Boolean :param value: Boolean
""" """
self._is_cooled = bool(value) if value is not None:
self._is_cooled = ast.literal_eval(value)

View File

@ -7,10 +7,10 @@ from __future__ import annotations
import sys import sys
import pickle import pickle
import math import math
from typing import List, Union, TypeVar from typing import List, Union
import pyproj import pyproj
from pyproj import Transformer from pyproj import Transformer
from pathlib import Path
from city_model_structure.building import Building from city_model_structure.building import Building
from city_model_structure.city_object import CityObject from city_model_structure.city_object import CityObject
@ -21,9 +21,6 @@ from helpers.geometry_helper import GeometryHelper
from helpers.location import Location from helpers.location import Location
Path = TypeVar('Path')
class City: class City:
""" """
City class City class
@ -80,10 +77,10 @@ class City:
return self._get_location().city return self._get_location().city
@property @property
def climate_reference_city(self): def climate_reference_city(self) -> Union[None, str]:
""" """
Get the name for the climatic information reference city Get the name for the climatic information reference city
:return: str :return: None or str
""" """
return self._climate_reference_city return self._climate_reference_city
@ -93,13 +90,14 @@ class City:
Set the name for the climatic information reference city Set the name for the climatic information reference city
:param value: str :param value: str
""" """
if value is not None:
self._climate_reference_city = str(value) self._climate_reference_city = str(value)
@property @property
def climate_file(self) -> Path: def climate_file(self) -> Union[None, Path]:
""" """
Get the climate file full path Get the climate file full path
:return: Path :return: None or Path
""" """
return self._climate_file return self._climate_file
@ -109,6 +107,7 @@ class City:
Set the climate file full path Set the climate file full path
:param value: Path :param value: Path
""" """
if value is not None:
self._climate_file = Path(value) self._climate_file = Path(value)
@property @property
@ -211,10 +210,10 @@ class City:
self._buildings.remove(city_object) self._buildings.remove(city_object)
@property @property
def srs_name(self): def srs_name(self) -> Union[None, str]:
""" """
Get city srs name Get city srs name
:return: str :return: None or str
""" """
return self._srs_name return self._srs_name
@ -224,6 +223,7 @@ class City:
Set city name Set city name
:param value:str :param value:str
""" """
if value is not None:
self._name = str(value) self._name = str(value)
@staticmethod @staticmethod
@ -267,10 +267,10 @@ class City:
return selected_region_city return selected_region_city
@property @property
def latitude(self): def latitude(self) -> Union[None, float]:
""" """
Get city latitude in degrees Get city latitude in degrees
:return: float :return: None or float
""" """
return self._latitude return self._latitude
@ -280,13 +280,14 @@ class City:
Set city latitude in degrees Set city latitude in degrees
:parameter value: float :parameter value: float
""" """
if value is not None:
self._latitude = float(value) self._latitude = float(value)
@property @property
def longitude(self): def longitude(self) -> Union[None, float]:
""" """
Get city longitude in degrees Get city longitude in degrees
:return: float :return: None or float
""" """
return self._longitude return self._longitude
@ -296,13 +297,14 @@ class City:
Set city longitude in degrees Set city longitude in degrees
:parameter value: float :parameter value: float
""" """
if value is not None:
self._longitude = float(value) self._longitude = float(value)
@property @property
def time_zone(self): def time_zone(self) -> Union[None, float]:
""" """
Get city time_zone Get city time_zone
:return: float :return: None or float
""" """
return self._time_zone return self._time_zone
@ -312,6 +314,7 @@ class City:
Set city time_zone Set city time_zone
:parameter value: float :parameter value: float
""" """
if value is not None:
self._time_zone = float(value) self._time_zone = float(value)
@property @property

View File

@ -4,6 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
from typing import Union
class HeatPump: class HeatPump:
""" """
@ -14,10 +16,10 @@ class HeatPump:
self._seasonal_mean_coverage_factor = None self._seasonal_mean_coverage_factor = None
@property @property
def seasonal_mean_cop(self): def seasonal_mean_cop(self) -> Union[None, float]:
""" """
Get seasonal mean COP (-) Get seasonal mean COP (-)
:return: float :return: None or float
""" """
return self._seasonal_mean_cop return self._seasonal_mean_cop
@ -27,13 +29,14 @@ class HeatPump:
Set seasonal mean COP (-) Set seasonal mean COP (-)
:param value: float :param value: float
""" """
if value is not None:
self._seasonal_mean_cop = float(value) self._seasonal_mean_cop = float(value)
@property @property
def seasonal_mean_coverage_factor(self): def seasonal_mean_coverage_factor(self) -> Union[None, float]:
""" """
Get percentage of demand covered by the hp (-) Get percentage of demand covered by the hp (-)
:return: float :return: None or float
""" """
return self._seasonal_mean_coverage_factor return self._seasonal_mean_coverage_factor
@ -43,4 +46,5 @@ class HeatPump:
Set percentage of demand covered by the hp (-) Set percentage of demand covered by the hp (-)
:return: float :return: float
""" """
if value is not None:
self._seasonal_mean_coverage_factor = float(value) self._seasonal_mean_coverage_factor = float(value)

View File

@ -4,6 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
""" """
from typing import Union
class PvSystem: class PvSystem:
""" """
@ -18,10 +20,10 @@ class PvSystem:
self._electricity_generation = None self._electricity_generation = None
@property @property
def modules_mean_seasonal_efficiency(self): def modules_mean_seasonal_efficiency(self) -> Union[None, float]:
""" """
Get mean modules efficiency (-) Get mean modules efficiency (-)
:return: float :return: None or float
""" """
return self._modules_mean_seasonal_efficiency return self._modules_mean_seasonal_efficiency
@ -31,13 +33,14 @@ class PvSystem:
Set mean modules efficiency (-) Set mean modules efficiency (-)
:param value: float :param value: float
""" """
if value is not None:
self._modules_mean_seasonal_efficiency = float(value) self._modules_mean_seasonal_efficiency = float(value)
@property @property
def total_area(self): def total_area(self) -> Union[None, float]:
""" """
Get total modules area in square meters Get total modules area in square meters
:return: float :return: None or float
""" """
return self._total_area return self._total_area
@ -47,13 +50,14 @@ class PvSystem:
Set total modules area in square meters Set total modules area in square meters
:param value: float :param value: float
""" """
if value is not None:
self._total_area = float(value) self._total_area = float(value)
@property @property
def module_area(self): def module_area(self) -> Union[None, float]:
""" """
Get module area in square meters Get module area in square meters
:return: float :return: None or float
""" """
return self._module_area return self._module_area
@ -63,13 +67,14 @@ class PvSystem:
Set module area in square meters Set module area in square meters
:param value: float :param value: float
""" """
if value is not None:
self._module_area = float(value) self._module_area = float(value)
@property @property
def number_of_modules(self): def number_of_modules(self) -> Union[None, int]:
""" """
Get number of modules Get number of modules
:return: int :return: None or int
""" """
return self._number_of_modules return self._number_of_modules
@ -79,13 +84,14 @@ class PvSystem:
Set number of modules Set number of modules
:param value: int :param value: int
""" """
if value is not None:
self._number_of_modules = int(value) self._number_of_modules = int(value)
@property @property
def overall_system_performance_ratio(self): def overall_system_performance_ratio(self) -> Union[None, float]:
""" """
Get overall system performance ratio (-) Get overall system performance ratio (-)
:return: float :return: None or float
""" """
return self._overall_system_performance_ratio return self._overall_system_performance_ratio
@ -95,13 +101,14 @@ class PvSystem:
Set overall system performance ratio (-) Set overall system performance ratio (-)
:param value: float :param value: float
""" """
if value is not None:
self._overall_system_performance_ratio = float(value) self._overall_system_performance_ratio = float(value)
@property @property
def electricity_generation(self): def electricity_generation(self) -> Union[None, float]:
""" """
Get electricity generation in J Get electricity generation in J
:return: float :return: None or float
""" """
return self._electricity_generation return self._electricity_generation
@ -111,4 +118,5 @@ class PvSystem:
Set electricity generation in J Set electricity generation in J
:param value: float :param value: float
""" """
if value is not None:
self._electricity_generation = float(value) self._electricity_generation = float(value)

View File

@ -23,6 +23,8 @@ class Sensor:
Get sensor name Get sensor name
:return: str :return: str
""" """
if self._name is None:
raise ValueError('Undefined sensor name')
return self._name return self._name
@name.setter @name.setter
@ -31,6 +33,7 @@ class Sensor:
Set sensor name Set sensor name
:param value: str :param value: str
""" """
if value is not None:
self._name = str(value) self._name = str(value)
@property @property

View File

@ -5,6 +5,10 @@ Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
Contributor Milad milad.aghamohamadnia@concordia.ca Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca Contributor Guille guille.gutierrezmorote@concordia.ca
""" """
import ast
from typing import Union
from city_model_structure.attributes.edge import Edge from city_model_structure.attributes.edge import Edge
from city_model_structure.transport.lane import Lane from city_model_structure.transport.lane import Lane
@ -87,10 +91,10 @@ class Connection:
self._to_lane = value self._to_lane = value
@property @property
def pass_not_wait(self): def pass_not_wait(self) -> Union[None, bool]:
""" """
Get if the vehicles which pass this (lane to lane) connection will not wait Get if the vehicles which pass this (lane to lane) connection will not wait
:return: Boolean :return: None or Boolean
""" """
return self._pass return self._pass
@ -100,13 +104,14 @@ class Connection:
Set if the vehicles which pass this (lane to lane) connection will not wait Set if the vehicles which pass this (lane to lane) connection will not wait
:param value: Boolean :param value: Boolean
""" """
self._pass = bool(value) if value is not None:
self._pass = ast.literal_eval(value)
@property @property
def keep_clear(self): def keep_clear(self) -> Union[None, bool]:
""" """
Get if vehicles which pass this (lane to lane) connection should keep the intersection clear Get if vehicles which pass this (lane to lane) connection should keep the intersection clear
:return: Boolean :return: None or Boolean
""" """
return self._keep_clear return self._keep_clear
@ -116,4 +121,5 @@ class Connection:
Set if vehicles which pass this (lane to lane) connection should keep the intersection clear Set if vehicles which pass this (lane to lane) connection should keep the intersection clear
:param value: Boolean :param value: Boolean
""" """
self._keep_clear = bool(value) if value is not None:
self._keep_clear = ast.literal_eval(value)

View File

@ -6,7 +6,8 @@ Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca Contributor Guille guille.gutierrezmorote@concordia.ca
""" """
from typing import List import ast
from typing import List, Union
from city_model_structure.transport.traffic_node import TrafficNode from city_model_structure.transport.traffic_node import TrafficNode
@ -22,10 +23,10 @@ class Crossing(TrafficNode):
self._shape = shape self._shape = shape
@property @property
def priority(self): def priority(self) -> Union[None, bool]:
""" """
Get whether the pedestrians have priority over the vehicles Get whether the pedestrians have priority over the vehicles
:return: bool :return: None or bool
""" """
return self._priority return self._priority
@ -35,13 +36,14 @@ class Crossing(TrafficNode):
Set whether the pedestrians have priority over the vehicles Set whether the pedestrians have priority over the vehicles
:param value: bool :param value: bool
""" """
self._priority = bool(value) if value is not None:
self._priority = ast.literal_eval(value)
@property @property
def width(self): def width(self) -> Union[None, float]:
""" """
Get crossing width in meters Get crossing width in meters
:return: float :return: None or float
""" """
return self._width return self._width
@ -51,13 +53,14 @@ class Crossing(TrafficNode):
Set crossing width in meters Set crossing width in meters
:param value: float :param value: float
""" """
if value is not None:
self._width = float(value) self._width = float(value)
@property @property
def shape(self) -> List[List[float]]: def shape(self) -> Union[None, List[List[float]]]:
""" """
Get the list of positions Get the list of positions
:return: [[x, y, (z)]] :return: None or [[x, y, (z)]]
""" """
return self._shape return self._shape
@ -67,4 +70,5 @@ class Crossing(TrafficNode):
Set the list of positions Set the list of positions
:param value: [[x, y, (z)]] :param value: [[x, y, (z)]]
""" """
if value is not None:
self._shape = [[float(i) for i in value]] self._shape = [[float(i) for i in value]]

View File

@ -5,7 +5,7 @@ Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
Contributor Milad milad.aghamohamadnia@concordia.ca Contributor Milad milad.aghamohamadnia@concordia.ca
""" """
from typing import List from typing import List, Union
class Lane: class Lane:
@ -23,11 +23,11 @@ class Lane:
self._width = None self._width = None
@property @property
def index(self): def index(self) -> Union[None, int]:
""" """
Get lane index Get lane index
The enumeration index of the lane (0 is the rightmost lane, <NUMBER_LANES>-1 is the leftmost one) The enumeration index of the lane (0 is the rightmost lane, <NUMBER_LANES>-1 is the leftmost one)
:return: int :return: None or int
""" """
return self._index return self._index
@ -38,13 +38,14 @@ class Lane:
The enumeration index of the lane (0 is the rightmost lane, <NUMBER_LANES>-1 is the leftmost one) The enumeration index of the lane (0 is the rightmost lane, <NUMBER_LANES>-1 is the leftmost one)
:param value: int :param value: int
""" """
if value is not None:
self._index = int(value) self._index = int(value)
@property @property
def allow(self) -> List[str]: def allow(self) -> Union[None, List[str]]:
""" """
Get the list of allowed vehicle classes Get the list of allowed vehicle classes
:return: [str] :return: None or [str]
""" """
return self._allow return self._allow
@ -54,13 +55,14 @@ class Lane:
Set the list of allowed vehicle classes setter Set the list of allowed vehicle classes setter
:param value: [str] :param value: [str]
""" """
if value is not None:
self._allow = [str(i) for i in value] self._allow = [str(i) for i in value]
@property @property
def disallow(self) -> List[str]: def disallow(self) -> Union[None, List[str]]:
""" """
Get the list of not allowed vehicle classes Get the list of not allowed vehicle classes
:return: [str] :return: None or [str]
""" """
return self._disallow return self._disallow
@ -70,13 +72,14 @@ class Lane:
Get the list of not allowed vehicle classes setter Get the list of not allowed vehicle classes setter
:param value: [str] :param value: [str]
""" """
if value is not None:
self._disallow = [str(i) for i in value] self._disallow = [str(i) for i in value]
@property @property
def change_left(self) -> List[str]: def change_left(self) -> Union[None, List[str]]:
""" """
Get the list of vehicle classes that may change left from this lane Get the list of vehicle classes that may change left from this lane
:return: [str] :return: None or [str]
""" """
return self._change_left return self._change_left
@ -86,13 +89,14 @@ class Lane:
Set the list of vehicle classes that may change left from this lane Set the list of vehicle classes that may change left from this lane
:param value: [str] :param value: [str]
""" """
if value is not None:
self._change_left = [str(i) for i in value] self._change_left = [str(i) for i in value]
@property @property
def change_right(self) -> List[str]: def change_right(self) -> Union[None, List[str]]:
""" """
Get the list of vehicle classes that may change right from this lane Get the list of vehicle classes that may change right from this lane
:return: [str] :return: None or [str]
""" """
return self._change_right return self._change_right
@ -102,13 +106,14 @@ class Lane:
Set the list of vehicle classes that may change right from this lane Set the list of vehicle classes that may change right from this lane
:param value: [str] :param value: [str]
""" """
if value is not None:
self._change_right = [str(i) for i in value] self._change_right = [str(i) for i in value]
@property @property
def speed(self): def speed(self) -> Union[None, float]:
""" """
Get the lane speed in m/s Get the lane speed in m/s
:return: float :return: None or float
""" """
return self._speed return self._speed
@ -118,13 +123,14 @@ class Lane:
Set the lane speed in m/s Set the lane speed in m/s
:param value: float :param value: float
""" """
if value is not None:
self._speed = float(value) self._speed = float(value)
@property @property
def width(self): def width(self) -> Union[None, float]:
""" """
Get the lane width in meters Get the lane width in meters
:return: float :return: None or float
""" """
return self._width return self._width
@ -134,4 +140,5 @@ class Lane:
Set the lane width in meters Set the lane width in meters
:param value: float :param value: float
""" """
if value is not None:
self._width = float(value) self._width = float(value)

View File

@ -5,7 +5,7 @@ Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.mons
Contributor Milad milad.aghamohamadnia@concordia.ca Contributor Milad milad.aghamohamadnia@concordia.ca
""" """
from typing import List from typing import List, Union
class Phase: class Phase:
@ -22,10 +22,10 @@ class Phase:
self._next = None self._next = None
@property @property
def duration(self): def duration(self) -> Union[None, int]:
""" """
Get phase duration in seconds Get phase duration in seconds
:return: int :return: None or int
""" """
return self._duration return self._duration
@ -35,13 +35,14 @@ class Phase:
Set phase duration in seconds Set phase duration in seconds
:param value: int :param value: int
""" """
if value is not None:
self._duration = int(value) self._duration = int(value)
@property @property
def state(self): def state(self) -> Union[None, List[str]]:
""" """
Get the list of signal states Get the list of signal states
:return: [str] :return: None or [str]
""" """
return self._state return self._state
@ -51,13 +52,14 @@ class Phase:
Set the list of signal states Set the list of signal states
:param value: [str] :param value: [str]
""" """
if value is not None:
self._state = [str(i) for i in value] self._state = [str(i) for i in value]
@property @property
def min_duration(self): def min_duration(self) -> Union[None, int]:
""" """
Get phase minimum duration in seconds Get phase minimum duration in seconds
:return: int :return: None or int
""" """
if self._min_duration is None: if self._min_duration is None:
self._min_duration = self._duration self._min_duration = self._duration
@ -69,13 +71,14 @@ class Phase:
Set phase minimum duration in seconds Set phase minimum duration in seconds
:param value: int :param value: int
""" """
if value is not None:
self._min_duration = int(value) self._min_duration = int(value)
@property @property
def max_duration(self): def max_duration(self) -> Union[None, int]:
""" """
Get phase maximum duration in seconds Get phase maximum duration in seconds
:return: int :return: None or int
""" """
if self._max_duration is None: if self._max_duration is None:
self._max_duration = self._duration self._max_duration = self._duration
@ -87,13 +90,14 @@ class Phase:
Set phase maximum duration in seconds Set phase maximum duration in seconds
:param value: int :param value: int
""" """
if value is not None:
self._max_duration = int(value) self._max_duration = int(value)
@property @property
def name(self): def name(self) -> Union[None, str]:
""" """
Get phase name Get phase name
:return: str :return: None or str
""" """
return self._name return self._name
@ -103,16 +107,17 @@ class Phase:
Set phase name Set phase name
:param value: str :param value: str
""" """
if value is not None:
self._name = str(value) self._name = str(value)
@property @property
def next(self) -> List[int]: def next(self) -> Union[None, List[int]]:
""" """
Get the next phase in the cycle after the current. Get the next phase in the cycle after the current.
This is useful when adding extra transition phases to a traffic light plan which are not part of every cycle. This is useful when adding extra transition phases to a traffic light plan which are not part of every cycle.
Traffic lights of type 'actuated' can make use of a list of indices for selecting among alternative Traffic lights of type 'actuated' can make use of a list of indices for selecting among alternative
successor phases. successor phases.
:return: [int] :return: None or [int]
""" """
return self._next return self._next
@ -125,4 +130,5 @@ class Phase:
successor phases. successor phases.
:param value: [int] :param value: [int]
""" """
if value is not None:
self._next = [int(i) for i in value] self._next = [int(i) for i in value]

View File

@ -6,7 +6,7 @@ Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca Contributor Guille guille.gutierrezmorote@concordia.ca
""" """
from typing import List from typing import List, Union
from city_model_structure.attributes.edge import Edge from city_model_structure.attributes.edge import Edge
from city_model_structure.transport.lane import Lane from city_model_structure.transport.lane import Lane
@ -54,11 +54,11 @@ class TrafficEdge(Edge):
self._lanes = value self._lanes = value
@property @property
def priority(self): def priority(self) -> Union[None, int]:
""" """
Get the priority between different road types. Get the priority between different road types.
It starts with one; higher numbers represent more important roads. It starts with one; higher numbers represent more important roads.
:return: int :return: None or int
""" """
return self._priority return self._priority
@ -69,13 +69,14 @@ class TrafficEdge(Edge):
It starts with one; higher numbers represent more important roads. It starts with one; higher numbers represent more important roads.
:param value: int :param value: int
""" """
if value is not None:
self._priority = int(value) self._priority = int(value)
@property @property
def speed(self): def speed(self) -> Union[None, float]:
""" """
Get he speed limit in m/s Get he speed limit in m/s
:return: float :return: None or float
""" """
return self._speed return self._speed
@ -85,13 +86,14 @@ class TrafficEdge(Edge):
Set the speed limit in m/s Set the speed limit in m/s
:param value: float :param value: float
""" """
if value is not None:
self._speed = float(value) self._speed = float(value)
@property @property
def length(self): def length(self) -> Union[None, float]:
""" """
Get the lane length in meters Get the lane length in meters
:return: float :return: None or float
""" """
return self._length return self._length
@ -101,13 +103,14 @@ class TrafficEdge(Edge):
Set the lane length in meters Set the lane length in meters
:param value: float :param value: float
""" """
if value is not None:
self._length = float(value) self._length = float(value)
@property @property
def allows(self) -> List[str]: def allows(self) -> Union[None, List[str]]:
""" """
Get the list of allowed vehicle classes Get the list of allowed vehicle classes
:return: [str] :return: None or [str]
""" """
return self._allows return self._allows
@ -117,13 +120,14 @@ class TrafficEdge(Edge):
Set the list of allowed vehicle classes Set the list of allowed vehicle classes
:param value: [str] :param value: [str]
""" """
if value is not None:
self._allows = [str(i) for i in value] self._allows = [str(i) for i in value]
@property @property
def disallows(self) -> List[str]: def disallows(self) -> Union[None, List[str]]:
""" """
Get the list of not allowed vehicle classes Get the list of not allowed vehicle classes
:return: [str] :return: None or [str]
""" """
return self._disallows return self._disallows
@ -133,4 +137,5 @@ class TrafficEdge(Edge):
Set the list of not allowed vehicle classes Set the list of not allowed vehicle classes
:param value: [str] :param value: [str]
""" """
if value is not None:
self._disallows = [str(i) for i in value] self._disallows = [str(i) for i in value]

View File

@ -6,7 +6,8 @@ Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca Contributor Guille guille.gutierrezmorote@concordia.ca
""" """
from typing import List import ast
from typing import List, Union
from city_model_structure.transport.phase import Phase from city_model_structure.transport.phase import Phase
from city_model_structure.transport.traffic_node import TrafficNode from city_model_structure.transport.traffic_node import TrafficNode
@ -24,10 +25,10 @@ class TrafficLight(TrafficNode):
self._phases = phases self._phases = phases
@property @property
def right_on_red(self): def right_on_red(self) -> Union[None, bool]:
""" """
Get if is possible to turn right when the traffic light is red Get if is possible to turn right when the traffic light is red
:return: Boolean :return: None or Boolean
""" """
return self._right_on_red return self._right_on_red
@ -37,13 +38,14 @@ class TrafficLight(TrafficNode):
Get if is possible to turn right when the traffic light is red Get if is possible to turn right when the traffic light is red
:param value: Boolean :param value: Boolean
""" """
self._right_on_red = bool(value) if value is not None:
self._right_on_red = ast.literal_eval(value)
@property @property
def offset(self): def offset(self) -> Union[None, int]:
""" """
Get program initial time offset Get program initial time offset
:return: int :return: None or int
""" """
return self._offset return self._offset
@ -53,6 +55,7 @@ class TrafficLight(TrafficNode):
Set program initial time offset Set program initial time offset
:param value: int :param value: int
""" """
if value is not None:
self._offset = int(value) self._offset = int(value)
@property @property

View File

@ -6,7 +6,7 @@ Contributor Milad milad.aghamohamadnia@concordia.ca
Contributor Guille guille.gutierrezmorote@concordia.ca Contributor Guille guille.gutierrezmorote@concordia.ca
""" """
from typing import List from typing import List, Union
from city_model_structure.transport.traffic_node import TrafficNode from city_model_structure.transport.traffic_node import TrafficNode
@ -20,10 +20,10 @@ class WalkwayNode(TrafficNode):
self._shape = shape self._shape = shape
@property @property
def shape(self) -> List[List[float]]: def shape(self) -> Union[None, List[List[float]]]:
""" """
Get the list of positions Get the list of positions
:return: [[x, y, (z)]] :return: None or [[x, y, (z)]]
""" """
return self._shape return self._shape
@ -33,4 +33,5 @@ class WalkwayNode(TrafficNode):
Set the list of positions Set the list of positions
:param value: [[x, y, (z)]] :param value: [[x, y, (z)]]
""" """
if value is not None:
self._shape = [[float(i) for i in value]] self._shape = [[float(i) for i in value]]