Initial commit

This commit is contained in:
Koa Wells 2023-04-12 16:44:32 -04:00
parent f9bc6569b4
commit 0ac7f78196
3 changed files with 7235504 additions and 0 deletions

7235427
data/VMTrial_cleaned.geojson Normal file

File diff suppressed because it is too large Load Diff

76
energy_validation.py Normal file
View File

@ -0,0 +1,76 @@
import json
import random
import datetime
from hub.imports.geometry_factory import GeometryFactory
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.usage_factory import UsageFactory
from hub.helpers.data.montreal_function_to_hub_function import MontrealFunctionToHubFunction
class EnergyValidation:
def __init__(self):
pass
def _sort_buildings(self, buildings_to_simulate):
sorted_buildings = {}
for building in buildings_to_simulate:
code_utili = building['properties']['CODE_UTILI']
if not sorted_buildings.get(code_utili):
sorted_buildings[code_utili] = []
sorted_buildings[code_utili].append(building)
return sorted_buildings
def run(self, building_set, building_quantities):
sorted_buildings = self._sort_buildings(building_set)
buildings_to_simulate = []
for code_utili in building_quantities:
if code_utili in sorted_buildings:
for building in range(building_quantities[code_utili]):
buildings_to_simulate.append(sorted_buildings[code_utili]
[random.randrange(len(sorted_buildings[code_utili]))])
else:
print(f'{code_utili} is not found in the provided dataset.')
geojson = {
"type": "FeatureCollection",
"features": buildings_to_simulate
}
geojson_file_name = f'energy_validation{datetime.datetime.now().strftime("_%Y-%m-%d_%H-%M-%S")}.geojson'
geojson_file = open(geojson_file_name, 'w')
geojson_file.write(json.dumps(geojson, indent=2))
geojson_file.close()
city = GeometryFactory('geojson',
path=geojson_file_name,
height_field='building_height',
year_of_construction_field='ANNEE_CONS',
function_field='CODE_UTILI',
function_to_hub=MontrealFunctionToHubFunction().dictionary).city
ConstructionFactory('nrcan', city).enrich()
UsageFactory('nrcan', city).enrich(
# test_file = open('test.geojson', 'w')
# test_file.write(json.dumps(sorted_buildings, indent=2))
# test_file.close()
data_file = open('data/VMTrial_cleaned.geojson', 'r')
city = json.load(data_file)
buildings = city['features']
test_batch = {
'1000': 50,
'4413': 10,
'1921': 5
}
test = EnergyValidation()
test.run(building_set=buildings, building_quantities=test_batch)

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
cerc-hub