Quality improvements
This commit is contained in:
parent
58066a45cc
commit
312a9c34be
|
@ -554,7 +554,7 @@ class Polygon:
|
||||||
def _order_points(edges_list):
|
def _order_points(edges_list):
|
||||||
# todo: not sure that this method works for any case -> RECHECK
|
# todo: not sure that this method works for any case -> RECHECK
|
||||||
points = edges_list[0]
|
points = edges_list[0]
|
||||||
for j in range(0, len(points)):
|
for _ in range(0, len(points)):
|
||||||
for i in range(1, len(edges_list)):
|
for i in range(1, len(edges_list)):
|
||||||
point_1 = edges_list[i][0]
|
point_1 = edges_list[i][0]
|
||||||
point_2 = points[len(points)-1]
|
point_2 = points[len(points)-1]
|
||||||
|
|
|
@ -5,14 +5,11 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from os.path import exists
|
|
||||||
|
|
||||||
from exports.formats.stl import Stl
|
|
||||||
from exports.formats.obj import Obj
|
|
||||||
from exports.formats.energy_ade import EnergyAde
|
from exports.formats.energy_ade import EnergyAde
|
||||||
from exports.formats.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
|
||||||
from exports.formats.idf import Idf
|
from exports.formats.idf import Idf
|
||||||
|
from exports.formats.obj import Obj
|
||||||
|
from exports.formats.simplified_radiosity_algorithm import SimplifiedRadiosityAlgorithm
|
||||||
|
from exports.formats.stl import Stl
|
||||||
|
|
||||||
|
|
||||||
class ExportsFactory:
|
class ExportsFactory:
|
||||||
|
@ -73,7 +70,7 @@ class ExportsFactory:
|
||||||
idf_data_path = (Path(__file__).parent / './formats/idf_files/').resolve()
|
idf_data_path = (Path(__file__).parent / './formats/idf_files/').resolve()
|
||||||
# todo: create a get epw file function based on the city
|
# todo: create a get epw file function based on the city
|
||||||
weather_path = (Path(__file__).parent / '../data/weather/epw/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve()
|
weather_path = (Path(__file__).parent / '../data/weather/epw/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve()
|
||||||
Idf(self._city, self._path, (idf_data_path / f'Minimal.idf'), (idf_data_path / f'Energy+.idd'), weather_path)
|
return Idf(self._city, self._path, (idf_data_path / 'Minimal.idf'), (idf_data_path / 'Energy+.idd'), weather_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _sra(self):
|
def _sra(self):
|
||||||
|
@ -85,10 +82,3 @@ class ExportsFactory:
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
return getattr(self, self._export_type, lambda: None)
|
return getattr(self, self._export_type, lambda: None)
|
||||||
|
|
||||||
def _debug_export(self):
|
|
||||||
"""
|
|
||||||
Export the city model structure to the given export type
|
|
||||||
:return: None
|
|
||||||
"""
|
|
||||||
self._idf()
|
|
||||||
|
|
|
@ -3,21 +3,24 @@ ExportsFactory export a city into several formats
|
||||||
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
|
||||||
"""
|
"""
|
||||||
import xmltodict
|
|
||||||
import uuid
|
import uuid
|
||||||
import datetime
|
import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import xmltodict
|
||||||
import helpers.constants as cte
|
import helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
class EnergyAde:
|
class EnergyAde:
|
||||||
|
"""
|
||||||
|
Export the city to citygml + energy ade
|
||||||
|
"""
|
||||||
def __init__(self, city, path):
|
def __init__(self, city, path):
|
||||||
self._city = city
|
self._city = city
|
||||||
self._path = path
|
self._path = path
|
||||||
self._surface_members = None
|
self._surface_members = None
|
||||||
self._export()
|
self._export()
|
||||||
|
|
||||||
|
|
||||||
def _export(self):
|
def _export(self):
|
||||||
energy_ade = {
|
energy_ade = {
|
||||||
'core:CityModel': {
|
'core:CityModel': {
|
||||||
|
@ -162,7 +165,6 @@ class EnergyAde:
|
||||||
}
|
}
|
||||||
return demand
|
return demand
|
||||||
|
|
||||||
|
|
||||||
def _building_geometry(self, building, building_dic, city):
|
def _building_geometry(self, building, building_dic, city):
|
||||||
|
|
||||||
building_dic['bldg:Building']['bldg:function'] = building.function
|
building_dic['bldg:Building']['bldg:function'] = building.function
|
||||||
|
@ -183,7 +185,6 @@ class EnergyAde:
|
||||||
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
||||||
return building_dic
|
return building_dic
|
||||||
|
|
||||||
|
|
||||||
def _lod1(self, building, building_dic, city):
|
def _lod1(self, building, building_dic, city):
|
||||||
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
raise NotImplementedError('Only lod 1 and 2 can be exported')
|
||||||
|
|
||||||
|
@ -373,8 +374,5 @@ class EnergyAde:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
thermal_boundaries.append(thermal_boundary_dic)
|
thermal_boundaries.append(thermal_boundary_dic)
|
||||||
return thermal_boundaries
|
return thermal_boundaries
|
|
@ -4,10 +4,12 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehabolhassani@mail.concordia.ca
|
Copyright © 2020 Project Author Soroush Samareh Abolhassani - soroush.samarehabolhassani@mail.concordia.ca
|
||||||
"""
|
"""
|
||||||
from geomeppy import IDF
|
from geomeppy import IDF
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
class Idf:
|
class Idf:
|
||||||
|
"""
|
||||||
|
Export city to IDF
|
||||||
|
"""
|
||||||
_THERMOSTAT = 'HVACTEMPLATE:THERMOSTAT'
|
_THERMOSTAT = 'HVACTEMPLATE:THERMOSTAT'
|
||||||
_IDEAL_LOAD_AIR_SYSTEM = 'HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM'
|
_IDEAL_LOAD_AIR_SYSTEM = 'HVACTEMPLATE:ZONE:IDEALLOADSAIRSYSTEM'
|
||||||
_SURFACE = 'BUILDINGSURFACE:DETAILED'
|
_SURFACE = 'BUILDINGSURFACE:DETAILED'
|
||||||
|
@ -269,10 +271,8 @@ class Idf:
|
||||||
for boundary in thermal_zone.thermal_boundaries:
|
for boundary in thermal_zone.thermal_boundaries:
|
||||||
idf_surface_type = self.idf_surfaces[boundary.surface.type]
|
idf_surface_type = self.idf_surfaces[boundary.surface.type]
|
||||||
for usage_zone in thermal_zone.usage_zones:
|
for usage_zone in thermal_zone.usage_zones:
|
||||||
|
|
||||||
surface = self._idf.newidfobject(self._SURFACE, Name=f'{boundary.surface.name}',
|
surface = self._idf.newidfobject(self._SURFACE, Name=f'{boundary.surface.name}',
|
||||||
Surface_Type=idf_surface_type, Zone_Name=usage_zone.id,
|
Surface_Type=idf_surface_type, Zone_Name=usage_zone.id,
|
||||||
Construction_Name=boundary.construction_name)
|
Construction_Name=boundary.construction_name)
|
||||||
coordinates = self._matrix_to_list(boundary.surface.solid_polygon.coordinates)
|
coordinates = self._matrix_to_list(boundary.surface.solid_polygon.coordinates)
|
||||||
surface.setcoords(coordinates)
|
surface.setcoords(coordinates)
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,23 @@ 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 exports.formats.triangular import Triangular
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from imports.geometry_factory import GeometryFactory
|
|
||||||
import trimesh.exchange.obj
|
import trimesh.exchange.obj
|
||||||
|
from exports.formats.triangular import Triangular
|
||||||
|
from imports.geometry_factory import GeometryFactory
|
||||||
|
|
||||||
|
|
||||||
class Obj(Triangular):
|
class Obj(Triangular):
|
||||||
|
"""
|
||||||
|
Export to obj format
|
||||||
|
"""
|
||||||
def __init__(self, city, path):
|
def __init__(self, city, path):
|
||||||
super().__init__(city, path, 'obj')
|
super().__init__(city, path, 'obj')
|
||||||
|
|
||||||
def to_ground_points(self):
|
def to_ground_points(self):
|
||||||
|
"""
|
||||||
|
Move closer to the origin
|
||||||
|
"""
|
||||||
file_name_in = self._city.name + '.' + self._triangular_format
|
file_name_in = self._city.name + '.' + self._triangular_format
|
||||||
file_name_out = self._city.name + '_ground.' + self._triangular_format
|
file_name_out = self._city.name + '_ground.' + self._triangular_format
|
||||||
file_path_in = (Path(self._path).resolve() / file_name_in).resolve()
|
file_path_in = (Path(self._path).resolve() / file_name_in).resolve()
|
||||||
|
|
|
@ -3,12 +3,13 @@ Simplified Radiosity Algorithm
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2020 Project Author Guillermo.GutierrezMorote@concordia.ca
|
Copyright © 2020 Project Author Guillermo.GutierrezMorote@concordia.ca
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
||||||
|
|
||||||
class SimplifiedRadiosityAlgorithm:
|
class SimplifiedRadiosityAlgorithm:
|
||||||
|
"""
|
||||||
|
Export to SRA format
|
||||||
|
"""
|
||||||
def __init__(self, city, file_name, begin_month=1, begin_day=1, end_month=12, end_day=31):
|
def __init__(self, city, file_name, begin_month=1, begin_day=1, end_month=12, end_day=31):
|
||||||
self._file_name = file_name
|
self._file_name = file_name
|
||||||
self._begin_month = begin_month
|
self._begin_month = begin_month
|
||||||
|
@ -83,7 +84,5 @@ class SimplifiedRadiosityAlgorithm:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with open(self._file_name, "w") as file:
|
with open(self._file_name, "w") as file:
|
||||||
file.write(xmltodict.unparse(sra, pretty=True, short_empty_elements=True))
|
file.write(xmltodict.unparse(sra, pretty=True, short_empty_elements=True))
|
||||||
return
|
|
||||||
|
|
|
@ -8,5 +8,8 @@ from exports.formats.triangular import Triangular
|
||||||
|
|
||||||
|
|
||||||
class Stl(Triangular):
|
class Stl(Triangular):
|
||||||
|
"""
|
||||||
|
Export to STL
|
||||||
|
"""
|
||||||
def __init__(self, city, path):
|
def __init__(self, city, path):
|
||||||
super().__init__(city, path, 'stl', write_mode='wb')
|
super().__init__(city, path, 'stl', write_mode='wb')
|
||||||
|
|
|
@ -8,6 +8,9 @@ from trimesh import Trimesh
|
||||||
|
|
||||||
|
|
||||||
class Triangular:
|
class Triangular:
|
||||||
|
"""
|
||||||
|
Superclass to export to triangular format (STL or OBJ)
|
||||||
|
"""
|
||||||
def __init__(self, city, path, triangular_format, write_mode='w'):
|
def __init__(self, city, path, triangular_format, write_mode='w'):
|
||||||
self._city = city
|
self._city = city
|
||||||
self._path = path
|
self._path = path
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
"""
|
||||||
|
Constant module
|
||||||
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
# universal constants
|
# universal constants
|
||||||
KELVIN = 273.15
|
KELVIN = 273.15
|
||||||
|
|
||||||
|
@ -48,4 +55,3 @@ RETAIL = 'retail'
|
||||||
HALL = 'hall'
|
HALL = 'hall'
|
||||||
RESTAURANT = 'restaurant'
|
RESTAURANT = 'restaurant'
|
||||||
EDUCATION = 'education'
|
EDUCATION = 'education'
|
||||||
|
|
||||||
|
|
|
@ -10,25 +10,50 @@ from imports.schedules_factory import SchedulesFactory
|
||||||
|
|
||||||
|
|
||||||
class EnrichCity:
|
class EnrichCity:
|
||||||
|
"""
|
||||||
|
Enrich city
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, city):
|
def __init__(self, city):
|
||||||
self._city = city
|
self._city = city
|
||||||
self._enriched_city = None
|
self._enriched_city = None
|
||||||
self._errors = []
|
self._errors = []
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def errors(self):
|
def errors(self) -> [str]:
|
||||||
|
"""
|
||||||
|
Error list
|
||||||
|
"""
|
||||||
return self._errors
|
return self._errors
|
||||||
|
|
||||||
def enriched_city(self, construction_format=None, usage_format=None, schedules_format=None):
|
def enriched_city(self, construction_format=None, usage_format=None, schedules_format=None):
|
||||||
|
"""
|
||||||
|
Enrich the city with the given formats
|
||||||
|
:return: City
|
||||||
|
"""
|
||||||
if self._enriched_city is None:
|
if self._enriched_city is None:
|
||||||
self._errors = []
|
self._errors = []
|
||||||
|
|
||||||
print('original:', len(self._city.buildings))
|
print('original:', len(self._city.buildings))
|
||||||
if construction_format is not None:
|
if construction_format is not None:
|
||||||
|
self._enriched_city = self._construction(construction_format)
|
||||||
|
if len(self._errors) != 0:
|
||||||
|
return self._enriched_city
|
||||||
|
if usage_format is not None:
|
||||||
|
self._enriched_city = self._usage(usage_format)
|
||||||
|
if len(self._errors) != 0:
|
||||||
|
return self._enriched_city
|
||||||
|
if schedules_format is not None:
|
||||||
|
self._enriched_city = self._schedules(schedules_format)
|
||||||
|
if len(self._errors) != 0:
|
||||||
|
return self._enriched_city
|
||||||
|
self._enriched_city = self._city
|
||||||
|
return self._enriched_city
|
||||||
|
|
||||||
|
def _construction(self, construction_format):
|
||||||
|
|
||||||
# todo: in construction factory, when adding the values to the thermal zones,
|
# todo: in construction factory, when adding the values to the thermal zones,
|
||||||
# these are created using the just read storeys_above_ground -> review where to assign this value!!
|
# these are created using the just read storeys_above_ground -> review where to assign this value!!
|
||||||
ConstructionFactory(construction_format, self._city).enrich()
|
ConstructionFactory(construction_format, self._city).enrich()
|
||||||
|
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
# infiltration_rate_system_off is a mandatory parameter.
|
# infiltration_rate_system_off is a mandatory parameter.
|
||||||
# If it is not returned, extract the building from the calculation list
|
# If it is not returned, extract the building from the calculation list
|
||||||
|
@ -39,8 +64,9 @@ class EnrichCity:
|
||||||
self._enriched_city = self._city
|
self._enriched_city = self._city
|
||||||
return self._enriched_city
|
return self._enriched_city
|
||||||
print('enriched with construction:', len(self._city.buildings))
|
print('enriched with construction:', len(self._city.buildings))
|
||||||
|
return self._city
|
||||||
|
|
||||||
if usage_format is not None:
|
def _usage(self, usage_format):
|
||||||
UsageFactory(usage_format, self._city).enrich()
|
UsageFactory(usage_format, self._city).enrich()
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
# At least one thermal zone must be created.
|
# At least one thermal zone must be created.
|
||||||
|
@ -52,8 +78,9 @@ class EnrichCity:
|
||||||
self._enriched_city = self._city
|
self._enriched_city = self._city
|
||||||
return self._enriched_city
|
return self._enriched_city
|
||||||
print('enriched with usage:', len(self._city.buildings))
|
print('enriched with usage:', len(self._city.buildings))
|
||||||
|
return self._city
|
||||||
|
|
||||||
if schedules_format is not None:
|
def _schedules(self, schedules_format):
|
||||||
SchedulesFactory(schedules_format, self._city).enrich()
|
SchedulesFactory(schedules_format, self._city).enrich()
|
||||||
for building in self._city.buildings:
|
for building in self._city.buildings:
|
||||||
counter_schedules = 0
|
counter_schedules = 0
|
||||||
|
@ -69,6 +96,4 @@ class EnrichCity:
|
||||||
self._enriched_city = self._city
|
self._enriched_city = self._city
|
||||||
return self._enriched_city
|
return self._enriched_city
|
||||||
print('enriched with occupancy:', len(self._city.buildings))
|
print('enriched with occupancy:', len(self._city.buildings))
|
||||||
|
return self._city
|
||||||
self._enriched_city = self._city
|
|
||||||
return self._enriched_city
|
|
||||||
|
|
|
@ -9,10 +9,10 @@ import numpy as np
|
||||||
import requests
|
import requests
|
||||||
from trimesh import Trimesh
|
from trimesh import Trimesh
|
||||||
from trimesh import intersections
|
from trimesh import intersections
|
||||||
from helpers.configuration_helper import ConfigurationHelper
|
|
||||||
from city_model_structure.attributes.polygon import Polygon
|
from city_model_structure.attributes.polygon import Polygon
|
||||||
from city_model_structure.attributes.polyhedron import Polyhedron
|
from city_model_structure.attributes.polyhedron import Polyhedron
|
||||||
from helpers.location import Location
|
from helpers.location import Location
|
||||||
|
from helpers.configuration_helper import ConfigurationHelper
|
||||||
|
|
||||||
|
|
||||||
class GeometryHelper:
|
class GeometryHelper:
|
||||||
|
@ -47,7 +47,6 @@ class GeometryHelper:
|
||||||
delta = math.fabs(a1 - a2)
|
delta = math.fabs(a1 - a2)
|
||||||
return delta <= self._area_delta
|
return delta <= self._area_delta
|
||||||
|
|
||||||
|
|
||||||
def is_almost_same_surface(self, s1, s2):
|
def is_almost_same_surface(self, s1, s2):
|
||||||
"""
|
"""
|
||||||
Compare two surfaces and decides if they are almost equal (quadratic error under delta)
|
Compare two surfaces and decides if they are almost equal (quadratic error under delta)
|
||||||
|
@ -82,11 +81,13 @@ class GeometryHelper:
|
||||||
|
|
||||||
if minimum_distance > self._delta or s1.intersect(s2) is None:
|
if minimum_distance > self._delta or s1.intersect(s2) is None:
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def segment_list_to_trimesh(lines) -> Trimesh:
|
def segment_list_to_trimesh(lines) -> Trimesh:
|
||||||
|
"""
|
||||||
|
Transform a list of segments into a Trimesh
|
||||||
|
"""
|
||||||
line_points = [lines[0][0], lines[0][1]]
|
line_points = [lines[0][0], lines[0][1]]
|
||||||
lines.remove(lines[0])
|
lines.remove(lines[0])
|
||||||
while len(lines) > 1:
|
while len(lines) > 1:
|
||||||
|
@ -97,7 +98,7 @@ class GeometryHelper:
|
||||||
line_points.append(line[1])
|
line_points.append(line[1])
|
||||||
lines.pop(i - 1)
|
lines.pop(i - 1)
|
||||||
break
|
break
|
||||||
elif GeometryHelper.distance_between_points(line[1], line_points[len(line_points) - 1]) < 1e-8:
|
if GeometryHelper.distance_between_points(line[1], line_points[len(line_points) - 1]) < 1e-8:
|
||||||
line_points.append(line[0])
|
line_points.append(line[0])
|
||||||
lines.pop(i - 1)
|
lines.pop(i - 1)
|
||||||
break
|
break
|
||||||
|
@ -161,17 +162,19 @@ class GeometryHelper:
|
||||||
return [trimesh_1, trimesh_2]
|
return [trimesh_1, trimesh_2]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_location(latitude, longitude):
|
def get_location(latitude, longitude) -> Location:
|
||||||
|
"""
|
||||||
|
Get Location from latitude and longitude
|
||||||
|
"""
|
||||||
url = 'https://nominatim.openstreetmap.org/reverse?lat={latitude}&lon={longitude}&format=json'
|
url = 'https://nominatim.openstreetmap.org/reverse?lat={latitude}&lon={longitude}&format=json'
|
||||||
response = requests.get(url.format(latitude=latitude, longitude=longitude))
|
response = requests.get(url.format(latitude=latitude, longitude=longitude))
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
# This means something went wrong.
|
# This means something went wrong.
|
||||||
raise Exception('GET /tasks/ {}'.format(response.status_code))
|
raise Exception('GET /tasks/ {}'.format(response.status_code))
|
||||||
else:
|
|
||||||
response = response.json()
|
response = response.json()
|
||||||
# todo: this is wrong, remove in the future
|
city = 'Unknown'
|
||||||
city = 'new_york_city'
|
country = 'ca'
|
||||||
country = 'us'
|
|
||||||
if 'city' in response['address']:
|
if 'city' in response['address']:
|
||||||
city = response['address']['city']
|
city = response['address']['city']
|
||||||
if 'country_code' in response['address']:
|
if 'country_code' in response['address']:
|
||||||
|
|
|
@ -1,12 +1,29 @@
|
||||||
|
"""
|
||||||
|
Location module
|
||||||
|
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
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Location:
|
class Location:
|
||||||
|
"""
|
||||||
|
Location
|
||||||
|
"""
|
||||||
def __init__(self, country, city):
|
def __init__(self, country, city):
|
||||||
self._country = country
|
self._country = country
|
||||||
self._city = city
|
self._city = city
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def city(self):
|
def city(self):
|
||||||
|
"""
|
||||||
|
City name
|
||||||
|
"""
|
||||||
return self._city
|
return self._city
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def country(self):
|
def country(self):
|
||||||
|
"""
|
||||||
|
Country code
|
||||||
|
"""
|
||||||
return self._country
|
return self._country
|
|
@ -3,9 +3,9 @@ monthly_to_hourly_demand module
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
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
|
||||||
"""
|
"""
|
||||||
|
import calendar as cal
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from city_model_structure.building_demand.occupants import Occupants
|
from city_model_structure.building_demand.occupants import Occupants
|
||||||
import calendar as cal
|
|
||||||
import helpers.constants as cte
|
import helpers.constants as cte
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class MonthlyToHourlyDemand:
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
temp_grad_month = 0
|
temp_grad_month = 0
|
||||||
month_range = cal.monthrange(2015, month)[1]
|
month_range = cal.monthrange(2015, month)[1]
|
||||||
for day in range(1, month_range+1):
|
for _ in range(1, month_range+1):
|
||||||
external_temp_med = 0
|
external_temp_med = 0
|
||||||
for hour in range(0, 24):
|
for hour in range(0, 24):
|
||||||
external_temp_med += external_temp[key][i]/24
|
external_temp_med += external_temp[key][i]/24
|
||||||
|
@ -66,10 +66,8 @@ class MonthlyToHourlyDemand:
|
||||||
temp_grad_month += temp_grad_day[i]
|
temp_grad_month += temp_grad_day[i]
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
for day in range(1, month_range + 1):
|
for _ in range(1, month_range + 1):
|
||||||
for hour in range(0, 24):
|
for hour in range(0, 24):
|
||||||
# monthly_demand = self._building.heating[cte.MONTH]['INSEL'][month-1] or maybe:
|
|
||||||
# monthly_demand = self._building.heating[cte.MONTH].INSEL[month-1]
|
|
||||||
monthly_demand = self._building.heating[cte.MONTH][month-1]
|
monthly_demand = self._building.heating[cte.MONTH][month-1]
|
||||||
if monthly_demand == 'NaN':
|
if monthly_demand == 'NaN':
|
||||||
monthly_demand = 0
|
monthly_demand = 0
|
||||||
|
@ -104,7 +102,7 @@ class MonthlyToHourlyDemand:
|
||||||
for month in range(1, 13):
|
for month in range(1, 13):
|
||||||
temp_grad_month = 0
|
temp_grad_month = 0
|
||||||
month_range = cal.monthrange(2015, month)[1]
|
month_range = cal.monthrange(2015, month)[1]
|
||||||
for day in range(1, month_range[1] + 1):
|
for _ in range(1, month_range[1] + 1):
|
||||||
for hour in range(0, 24):
|
for hour in range(0, 24):
|
||||||
if external_temp[key][i] > temp_set and cooling_schedule[month - 1] == 1:
|
if external_temp[key][i] > temp_set and cooling_schedule[month - 1] == 1:
|
||||||
if occupancy[hour] > 0:
|
if occupancy[hour] > 0:
|
||||||
|
@ -123,7 +121,7 @@ class MonthlyToHourlyDemand:
|
||||||
temp_grad_month += temp_grad_day[i]
|
temp_grad_month += temp_grad_day[i]
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
for day in range(1, month_range[1] + 1):
|
for _ in range(1, month_range[1] + 1):
|
||||||
for hour in range(0, 24):
|
for hour in range(0, 24):
|
||||||
# monthly_demand = self._building.heating[cte.MONTH]['INSEL'][month-1]
|
# monthly_demand = self._building.heating[cte.MONTH]['INSEL'][month-1]
|
||||||
monthly_demand = self._building.cooling[cte.MONTH][month - 1]
|
monthly_demand = self._building.cooling[cte.MONTH][month - 1]
|
||||||
|
|
|
@ -4,11 +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
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from imports.construction.nrel_physics_interface import NrelPhysicsInterface
|
|
||||||
from imports.construction.helpers.construction_helper import ConstructionHelper
|
from imports.construction.helpers.construction_helper import ConstructionHelper
|
||||||
from city_model_structure.building_demand.layer import Layer
|
from imports.construction.nrel_physics_interface import NrelPhysicsInterface
|
||||||
from city_model_structure.building_demand.material import Material
|
|
||||||
|
|
||||||
|
|
||||||
class CaPhysicsParameters(NrelPhysicsInterface):
|
class CaPhysicsParameters(NrelPhysicsInterface):
|
||||||
|
|
|
@ -8,6 +8,9 @@ from helpers import constants as cte
|
||||||
|
|
||||||
|
|
||||||
class ConstructionHelper:
|
class ConstructionHelper:
|
||||||
|
"""
|
||||||
|
Construction helper
|
||||||
|
"""
|
||||||
# NREL
|
# NREL
|
||||||
function_to_nrel = {
|
function_to_nrel = {
|
||||||
cte.RESIDENTIAL: 'residential',
|
cte.RESIDENTIAL: 'residential',
|
||||||
|
|
|
@ -16,6 +16,7 @@ class NrelPhysicsInterface:
|
||||||
"""
|
"""
|
||||||
NrelPhysicsInterface abstract class
|
NrelPhysicsInterface abstract class
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, base_path, constructions_file='us_constructions.xml',
|
def __init__(self, base_path, constructions_file='us_constructions.xml',
|
||||||
archetypes_file='us_archetypes.xml'):
|
archetypes_file='us_archetypes.xml'):
|
||||||
self._building_archetypes = []
|
self._building_archetypes = []
|
||||||
|
@ -177,4 +178,7 @@ class NrelPhysicsInterface:
|
||||||
raise Exception('Construction type not found')
|
raise Exception('Construction type not found')
|
||||||
|
|
||||||
def enrich_buildings(self):
|
def enrich_buildings(self):
|
||||||
|
"""
|
||||||
|
Raise not implemented error
|
||||||
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
|
@ -3,9 +3,9 @@ ConstructionFactory (before PhysicsFactory) retrieve the specific construction m
|
||||||
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 pathlib import Path
|
||||||
from imports.construction.us_physics_parameters import UsPhysicsParameters
|
from imports.construction.us_physics_parameters import UsPhysicsParameters
|
||||||
from imports.construction.ca_physics_parameters import CaPhysicsParameters
|
from imports.construction.ca_physics_parameters import CaPhysicsParameters
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
|
|
||||||
class ConstructionFactory:
|
class ConstructionFactory:
|
||||||
|
@ -23,9 +23,6 @@ class ConstructionFactory:
|
||||||
def _nrcan(self):
|
def _nrcan(self):
|
||||||
CaPhysicsParameters(self._city, self._base_path).enrich_buildings()
|
CaPhysicsParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
|
||||||
def _other_construction_library_format(self):
|
|
||||||
raise NotImplementedError
|
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
Enrich the city with the construction information
|
Enrich the city with the construction information
|
||||||
|
|
|
@ -20,13 +20,10 @@ class UsageFactory:
|
||||||
self._base_path = base_path
|
self._base_path = base_path
|
||||||
|
|
||||||
def _hft(self):
|
def _hft(self):
|
||||||
HftUsageParameters(self._city, self._base_path).enrich_buildings()
|
return HftUsageParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
|
||||||
def _ca(self):
|
def _ca(self):
|
||||||
CaUsageParameters(self._city, self._base_path).enrich_buildings()
|
return CaUsageParameters(self._city, self._base_path).enrich_buildings()
|
||||||
|
|
||||||
def _other_usage_library_format(self):
|
|
||||||
raise Exception('Not implemented')
|
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -19,23 +19,16 @@ class WeatherFactory:
|
||||||
self._base_path = base_path
|
self._base_path = base_path
|
||||||
self._file_name = file_name
|
self._file_name = file_name
|
||||||
|
|
||||||
def _tmy3(self):
|
|
||||||
raise Exception('Not implemented')
|
|
||||||
|
|
||||||
def _tm2(self):
|
|
||||||
# Meteonorm (https://meteonorm.com/en/product/typical-years)
|
|
||||||
raise Exception('Not implemented')
|
|
||||||
|
|
||||||
def _epw(self):
|
def _epw(self):
|
||||||
# EnergyPlus Weather
|
# EnergyPlus Weather
|
||||||
# to download files: https://energyplus.net/weather
|
# to download files: https://energyplus.net/weather
|
||||||
# description of the format: https://energyplus.net/sites/default/files/pdfs_v8.3.0/AuxiliaryPrograms.pdf
|
# description of the format: https://energyplus.net/sites/default/files/pdfs_v8.3.0/AuxiliaryPrograms.pdf
|
||||||
_path = Path(self._base_path / 'epw').resolve()
|
_path = Path(self._base_path / 'epw').resolve()
|
||||||
EpwWeatherParameters(self._city, _path, self._file_name)
|
return EpwWeatherParameters(self._city, _path, self._file_name)
|
||||||
|
|
||||||
def _xls(self):
|
def _xls(self):
|
||||||
name = 'ISO_52016_1_BESTEST_ClimData_2016.08.24'
|
name = 'ISO_52016_1_BESTEST_ClimData_2016.08.24'
|
||||||
XlsWeatherParameters(self._city, self._base_path, name)
|
return XlsWeatherParameters(self._city, self._base_path, name)
|
||||||
|
|
||||||
def enrich(self):
|
def enrich(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -52,3 +52,9 @@ class TestSchedulesFactory(TestCase):
|
||||||
city = self._get_citygml(file)
|
city = self._get_citygml(file)
|
||||||
occupancy_handler = 'doe_idf'
|
occupancy_handler = 'doe_idf'
|
||||||
SchedulesFactory(occupancy_handler, city).enrich()
|
SchedulesFactory(occupancy_handler, city).enrich()
|
||||||
|
for building in city.buildings:
|
||||||
|
for usage_zone in building.usage_zones:
|
||||||
|
for schedule in usage_zone.schedules:
|
||||||
|
print(schedule)
|
||||||
|
print(usage_zone.schedules[schedule])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user