2022-06-09 15:40:43 -04:00
|
|
|
import glob
|
|
|
|
import os
|
2022-03-24 09:22:39 -04:00
|
|
|
import sys
|
|
|
|
from pathlib import Path
|
|
|
|
import csv
|
2022-06-07 13:18:07 -04:00
|
|
|
|
2023-03-21 14:27:37 -04:00
|
|
|
from hub.imports.geometry_factory import GeometryFactory
|
|
|
|
from hub.imports.construction_factory import ConstructionFactory
|
|
|
|
from hub.imports.usage_factory import UsageFactory
|
|
|
|
from hub.exports.exports_factory import ExportsFactory
|
|
|
|
from hub.exports.energy_building_exports_factory import EnergyBuildingsExportsFactory
|
|
|
|
from hub.helpers.dictionaries import Dictionaries
|
2022-12-16 09:39:09 -05:00
|
|
|
|
2023-03-21 14:27:37 -04:00
|
|
|
sys.path.append('./')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
#try:
|
2023-04-11 23:07:54 -04:00
|
|
|
file_path = (Path(__file__).parent.parent / 'input_files' / 'selected_building_2864.geojson')
|
2023-03-24 08:10:46 -04:00
|
|
|
out_path = (Path(__file__).parent.parent / 'out_files')
|
|
|
|
files = glob.glob(f'{out_path}/*')
|
|
|
|
for file in files:
|
|
|
|
if file != '.gitignore':
|
|
|
|
os.remove(file)
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
print('[simulation start]')
|
|
|
|
city = GeometryFactory('geojson',
|
|
|
|
path=file_path,
|
|
|
|
height_field='heightmax',
|
|
|
|
year_of_construction_field='ANNEE_CONS',
|
|
|
|
function_field='CODE_UTILI',
|
|
|
|
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
|
|
|
|
print(f'city created from {file_path}')
|
|
|
|
ConstructionFactory('nrcan', city).enrich()
|
|
|
|
print('enrich constructions... done')
|
|
|
|
UsageFactory('nrcan', city).enrich()
|
|
|
|
print('enrich usage... done')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
area = 0
|
|
|
|
volume = 0
|
|
|
|
for building in city.buildings:
|
|
|
|
volume = building.volume
|
|
|
|
for ground in building.grounds:
|
|
|
|
area += ground.perimeter_polygon.area
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
print('exporting:')
|
2022-06-09 15:40:43 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
_idf = EnergyBuildingsExportsFactory('idf', city, out_path).export()
|
|
|
|
print(' idf exported...')
|
|
|
|
_idf.run()
|
|
|
|
csv_file = str((out_path / f'{city.name}_out.csv').resolve())
|
|
|
|
eso_file = str((out_path / f'{city.name}_out.eso').resolve())
|
|
|
|
idf_file = str((out_path / f'{city.name}.idf').resolve())
|
|
|
|
obj_file = str((out_path / f'{city.name}.obj').resolve())
|
2023-04-04 17:59:19 -04:00
|
|
|
#todo: revision of results plotting, change with Koa. Minimal.idf changed
|
|
|
|
#with open((out_path / f'{city.name}_out.csv').resolve()) as f:
|
|
|
|
# reader = csv.reader(f, delimiter=',')
|
|
|
|
# for row in reader:
|
|
|
|
# if ':00:00' in row[0]:
|
|
|
|
# print(f'row: {row[0]}, {row[8]}, {row[9]}')
|
2022-03-24 09:22:39 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
print(f'info: {idf_file}, {csv_file}, {eso_file}, {area}, {volume}, {obj_file}')
|
|
|
|
print('[simulation end]')
|
2022-06-07 13:18:07 -04:00
|
|
|
|
2023-03-24 08:10:46 -04:00
|
|
|
#except Exception as ex:
|
2023-03-31 12:25:11 -04:00
|
|
|
# print(ex)
|
|
|
|
# print('error: ', ex)
|
|
|
|
#print('[simulation abort]')
|
2023-04-04 17:59:19 -04:00
|
|
|
#todo: revision of flushing data
|
|
|
|
#sys.stdout.flush()
|