Compare commits

...

2 Commits

Author SHA1 Message Date
Andrea Gabaldon Moreno
0ce76bef13 20240722 changes 2024-07-22 18:14:54 -04:00
Andrea Gabaldon Moreno
76a6f5f930 2024-07-17_course_update
Lachine data model is assessed for several building types and U-values
2024-07-17 18:39:52 -04:00
13 changed files with 1046 additions and 11871 deletions

16
.gitignore vendored
View File

@ -11,3 +11,19 @@
**/.idea/
cerc_hub.egg-info
/out_files
hub/data/construction/nrcan_constructions.json
hub/helpers/data/hub_function_to_nrcan_construction_function.py
hub/imports/construction/nrcan_physics_parameters.py
input_files/Lachine_moved_2019.geojson
input_files/Lachine_moved_2024.geojson
input_files/Lachine_moved_existing_year.geojson
input_files/Lachine_moved_existing_year_type_2.geojson
input_files/Lachine_moved_existing_year_type_3.geojson
input_files/district_demand.csv
input_files/Lachine_moved_2024_type.geojson
input_files/Lachine_moved_2024_type_2.geojson
input_files/Lachine_moved_2024_type_3.geojson
input_files/new_demands_existing_year.xlsx
input_files/updated_buildings_with_all_data_2024.geojson
input_files/updated_buildings_with_all_data_baseline.geojson
.spyproject

215
comparing.py Normal file
View File

@ -0,0 +1,215 @@
import json
from pathlib import Path
import matplotlib.pyplot as plt
# Specify the GeoJSON file path
input_files_path = (Path(__file__).parent / 'input_files')
# Load the updated GeoJSON file cotaining the results
baseline_scenario_path =input_files_path / 'updated_buildings_with_all_data_baseline.geojson'
energy_efficient_scenario_path = input_files_path / 'updated_buildings_with_all_data_2024.geojson'
with open(baseline_scenario_path , 'r') as f:
baseline_scenario = json.load(f)
with open(energy_efficient_scenario_path, 'r') as f:
energy_efficient_scenario=json.load(f)
percentage_data = {
1646: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2672.550473, "total_floor_area": 26725.50473},
1647: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2653.626087, "total_floor_area": 26536.26087},
1648: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1056.787496, "total_floor_area": 10567.87496},
1649: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1906.620746, "total_floor_area": 19066.20746},
1650: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 659.1119416, "total_floor_area": 5272.895533},
1651: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1167.208109, "total_floor_area": 9337.664871},
1652: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1193.251653, "total_floor_area": 9546.013222},
1653: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1491.722543, "total_floor_area": 11933.78035},
1654: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1168.005028, "total_floor_area": 9344.040224},
1655: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1264.906961, "total_floor_area": 10119.25569},
1656: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1281.768818, "total_floor_area": 10254.15054},
1657: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 290.3886018, "total_floor_area": 2323.108814},
1658: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 847.5095193, "total_floor_area": 6780.076155},
1659: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1115.319153, "total_floor_area": 8922.553224},
1660: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 469.2918062, "total_floor_area": 3754.33445},
1661: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1292.298346, "total_floor_area": 10338.38677},
1662: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 625.7828863, "total_floor_area": 5006.263091},
1663: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1876.02897, "total_floor_area": 15008.23176},
1664: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1118.224781, "total_floor_area": 22364.49562},
1665: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1502.787808, "total_floor_area": 30055.75617},
1666: {"type1_%": 0.891045711, "type2_%": 0.108954289, "type3_%": 0, "roof_area": 3038.486076, "total_floor_area": 30384.86076},
1667: {"type1_%": 0.8, "type2_%": 0.2, "type3_%": 0, "roof_area": 1343.832818, "total_floor_area": 13438.32818},
1668: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 961.0996956, "total_floor_area": 4805.498478},
1669: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 489.1282111, "total_floor_area": 1956.512845},
1673: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1693.141465, "total_floor_area": 5079.424396},
1674: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 3248.827576, "total_floor_area": 9746.482729},
1675: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 4086.842191, "total_floor_area": 12260.52657},
1676: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2786.114146, "total_floor_area": 11144.45658},
1677: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 5142.784184, "total_floor_area": 15428.35255},
1678: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 6068.664574, "total_floor_area": 18205.99372},
1679: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 5646.751407, "total_floor_area": 16940.25422},
1680: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1601.765953, "total_floor_area": 4805.297859},
1681: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 9728.221797, "total_floor_area": 29184.66539},
1687: {"type1_%": 0.606611029, "type2_%": 0.28211422, "type3_%": 0.11127475, "roof_area": 4268.608743, "total_floor_area": 59760.52241},
1688: {"type1_%": 0.92, "type2_%": 0.08, "type3_%": 0, "roof_area": 2146.654828, "total_floor_area": 38639.7869},
1689: {"type1_%": 0.96, "type2_%": 0.04, "type3_%": 0, "roof_area": 2860.270711, "total_floor_area": 57205.41421},
1690: {"type1_%": 0.94, "type2_%": 0.06, "type3_%": 0, "roof_area": 2189.732519, "total_floor_area": 28466.52275},
1691: {"type1_%": 0.75, "type2_%": 0.25, "type3_%": 0, "roof_area": 3159.077523, "total_floor_area": 31590.77523},
}
# Define the demand types to be plotted
demand_types = [
'heating_demand_kWh',
'cooling_demand_kWh',
'domestic_hot_water_heat_demand_kWh',
'appliances_electrical_demand_kWh',
'lighting_electrical_demand_kWh'
]
# # Function to extract demand data from the GeoJSON
# def extract_demand_data(geojson_data, demand_type, period_start, period_end):
# demand_data = {}
# for feature in geojson_data['features']:
# building_id = int(feature['properties']['id'])
# if demand_type in feature['properties']:
# demand_series = feature['properties'][demand_type][period_start:period_end]
# demand_data[building_id] = demand_series
# return demand_data
#
# # Define time periods
# period_start_january = 0
# period_end_january = 168 # First week of January (0-168h)
# period_start_summer = 3360
# period_end_summer = 3528 # One week in summer
#
# # Function to plot data for all buildings
# def plot_all_buildings(data, period, title):
# plt.figure(figsize=(15, 8))
# for building_id, values in data.items():
# plt.plot(range(len(values)), values, label=f'Building {building_id}')
# plt.xlabel('Hour')
# plt.ylabel('Energy Consumption (kWh)')
# plt.title(title)
# plt.legend(loc='upper right', bbox_to_anchor=(1.15, 1))
# plt.show()
#
# # Function to compare baseline and efficient scenarios for selected buildings
# def plot_comparison(selected_buildings, baseline_data, efficient_data, period, title):
# plt.figure(figsize=(15, 8))
# for building_id in selected_buildings:
# baseline = baseline_data.get(building_id, [])
# efficient = efficient_data.get(building_id, [])
# plt.plot(range(len(baseline)), baseline, label=f'Baseline Building {building_id}')
# plt.plot(range(len(efficient)), efficient, linestyle='--', label=f'Efficient Building {building_id}')
# plt.xlabel('Hour')
# plt.ylabel('Energy Consumption (kWh)')
# plt.title(title)
# plt.legend(loc='upper right', bbox_to_anchor=(1.15, 1))
# plt.show()
#
# # Loop through each demand type and extract data, then plot
# for demand_type in demand_types:
# # Extract demand data for the specified periods
# baseline_january = extract_demand_data(baseline_scenario, demand_type, period_start_january, period_end_january)
# baseline_summer = extract_demand_data(baseline_scenario, demand_type, period_start_summer, period_end_summer)
# efficient_january = extract_demand_data(energy_efficient_scenario, demand_type, period_start_january, period_end_january)
# efficient_summer = extract_demand_data(energy_efficient_scenario, demand_type, period_start_summer, period_end_summer)
#
# # Plot all buildings for the first week of January and one week in summer
# plot_all_buildings(baseline_january, range(period_start_january, period_end_january), f'First Week of January - Baseline Scenario - {demand_type}')
# plot_all_buildings(baseline_summer, range(period_start_summer, period_end_summer), f'One Week in Summer - Baseline Scenario - {demand_type}')
#
# # Selected buildings for comparison
# selected_buildings = [1646, 1691, 1687]
#
# # Plot comparison for the first week of January and one week in summer
# plot_comparison(selected_buildings, baseline_january, efficient_january, range(period_start_january, period_end_january), f'First Week of January - Comparison - {demand_type}')
# plot_comparison(selected_buildings, baseline_summer, efficient_summer, range(period_start_summer, period_end_summer), f'One Week in Summer - Comparison - {demand_type}')
#
# Function to extract and sum demand data from the GeoJSON
def extract_and_sum_demand_data(geojson_data, demand_type, period_start, period_end):
district_demand = [0] * (period_end - period_start)
for feature in geojson_data['features']:
if demand_type in feature['properties']:
demand_series = feature['properties'][demand_type][period_start:period_end]
district_demand = [sum(x) for x in zip(district_demand, demand_series)]
# Convert kWh to MWh
district_demand_mwh = [value / 1000 for value in district_demand]
return district_demand_mwh
# Define time periods
period_start_january = 0
period_end_january = 168 # First week of January (0-168h)
period_start_summer = 3360
period_end_summer = 3528 # One week in summer
# Function to plot district demand
def plot_district_demand(district_demand, title):
plt.figure(figsize=(15, 8))
plt.plot(range(len(district_demand)), district_demand, label='District Demand')
plt.xlabel('Hour')
plt.ylabel('Energy Consumption (MWh)')
plt.title(title)
plt.legend(loc='upper right')
plt.show()
# Function to compare district demands between baseline and efficient scenarios
def plot_district_comparison(district_demand_baseline, district_demand_efficient, title):
plt.figure(figsize=(15, 8))
plt.plot(range(len(district_demand_baseline)), district_demand_baseline, label='Baseline District Demand')
plt.plot(range(len(district_demand_efficient)), district_demand_efficient, linestyle='--', label='Efficient District Demand')
plt.xlabel('Hour')
plt.ylabel('Energy Consumption (MWh)')
plt.title(title)
plt.legend(loc='upper right')
plt.show()
# # Loop through each demand type, extract and sum data, then plot
# for demand_type in demand_types:
# # Extract and sum demand data for the specified periods
# district_demand_january_baseline = extract_and_sum_demand_data(baseline_scenario, demand_type, period_start_january, period_end_january)
# district_demand_summer_baseline = extract_and_sum_demand_data(baseline_scenario, demand_type, period_start_summer, period_end_summer)
# district_demand_january_efficient = extract_and_sum_demand_data(energy_efficient_scenario, demand_type, period_start_january, period_end_january)
# district_demand_summer_efficient = extract_and_sum_demand_data(energy_efficient_scenario, demand_type, period_start_summer, period_end_summer)
#
# # Plot district demand for the first week of January and one week in summer for baseline scenario
# plot_district_demand(district_demand_january_baseline, f'District Demand - First Week of January - Baseline Scenario - {demand_type}')
# plot_district_demand(district_demand_summer_baseline, f'District Demand - One Week in Summer - Baseline Scenario - {demand_type}')
#
# # Plot district demand for the first week of January and one week in summer for energy-efficient scenario
# plot_district_demand(district_demand_january_efficient, f'District Demand - First Week of January - Energy Efficient Scenario - {demand_type}')
# plot_district_demand(district_demand_summer_efficient, f'District Demand - One Week in Summer - Energy Efficient Scenario - {demand_type}')
#
# # Plot comparison of district demand between baseline and energy-efficient scenarios
# plot_district_comparison(district_demand_january_baseline, district_demand_january_efficient, f'District Demand Comparison - First Week of January - {demand_type}')
# plot_district_comparison(district_demand_summer_baseline, district_demand_summer_efficient, f'District Demand Comparison - One Week in Summer - {demand_type}')
# Function to extract and sum demand data from the GeoJSON
# Define time period for a year
period_start = 0
period_end = 8760 # Full year (0-8760h)
# Dictionary to store the district demand data for export
district_demand_data = {'hour': list(range(period_start, period_end))}
import pandas as pd
# Loop through each demand type, extract and sum data, then store in dictionary
for demand_type in demand_types:
# Extract and sum demand data for the full year
district_demand_mwh_baseline = extract_and_sum_demand_data(baseline_scenario, demand_type, period_start, period_end)
district_demand_mwh_efficient = extract_and_sum_demand_data(energy_efficient_scenario, demand_type, period_start,
period_end)
# Store data in the dictionary
district_demand_data[f'{demand_type}_baseline'] = district_demand_mwh_baseline
district_demand_data[f'{demand_type}_efficient'] = district_demand_mwh_efficient
# Calculate total district demand values for the year
total_district_baseline = sum(district_demand_mwh_baseline)
total_district_efficient = sum(district_demand_mwh_efficient)
# Print total district demand values
print(f'Total District Demand for {demand_type} (Baseline): {total_district_baseline:.2f} MWh')
print(f'Total District Demand for {demand_type} (Efficient): {total_district_efficient:.2f} MWh')
# Convert dictionary to DataFrame and export to CSV
district_demand_df = pd.DataFrame(district_demand_data)
output_csv_path = input_files_path / 'district_demand.csv'
district_demand_df.to_csv(output_csv_path, index=False)
print(f'District demand data exported to {output_csv_path}')

View File

@ -415,8 +415,8 @@ class Building(CityObject):
peak = max(schedule.values) * lighting.density * thermal_zone.total_floor_area
if peak > peak_lighting:
peak_lighting = peak
results[cte.MONTH] = [peak for _ in range(0, 12)]
results[cte.YEAR] = [peak]
results[cte.MONTH] = [float(peak) for _ in range(0, 12)]
results[cte.YEAR] = [float(peak)]
return results
@property
@ -434,8 +434,8 @@ class Building(CityObject):
peak = max(schedule.values) * appliances.density * thermal_zone.total_floor_area
if peak > peak_appliances:
peak_appliances = peak
results[cte.MONTH] = [peak for _ in range(0, 12)]
results[cte.YEAR] = [peak]
results[cte.MONTH] = [float(peak) for _ in range(0, 12)]
results[cte.YEAR] = [float(peak)]
return results
@property

File diff suppressed because it is too large Load Diff

View File

@ -1,86 +0,0 @@
"""
Dictionaries module for hub function to nrcan construction function
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Guille Gutierrez Guillermo.GutierrezMorote@concordia.ca
"""
import hub.helpers.constants as cte
class HubFunctionToNrcanConstructionFunction:
"""
Hub function to nrcan construction function class
"""
def __init__(self):
self._dictionary = {
cte.RESIDENTIAL: 'MidriseApartment',
cte.SINGLE_FAMILY_HOUSE: 'MidriseApartment',
cte.MULTI_FAMILY_HOUSE: 'HighriseApartment',
cte.ROW_HOUSE: 'MidriseApartment',
cte.MID_RISE_APARTMENT: 'MidriseApartment',
cte.HIGH_RISE_APARTMENT: 'HighriseApartment',
cte.OFFICE_AND_ADMINISTRATION: 'MediumOffice',
cte.SMALL_OFFICE: 'SmallOffice',
cte.MEDIUM_OFFICE: 'MediumOffice',
cte.LARGE_OFFICE: 'LargeOffice',
cte.COURTHOUSE: 'MediumOffice',
cte.FIRE_STATION: 'n/a',
cte.PENITENTIARY: 'LargeHotel',
cte.POLICE_STATION: 'n/a',
cte.POST_OFFICE: 'MediumOffice',
cte.LIBRARY: 'MediumOffice',
cte.EDUCATION: 'SecondarySchool',
cte.PRIMARY_SCHOOL: 'PrimarySchool',
cte.PRIMARY_SCHOOL_WITH_SHOWER: 'PrimarySchool',
cte.SECONDARY_SCHOOL: 'SecondarySchool',
cte.UNIVERSITY: 'SecondarySchool',
cte.LABORATORY_AND_RESEARCH_CENTER: 'SecondarySchool',
cte.STAND_ALONE_RETAIL: 'RetailStandalone',
cte.HOSPITAL: 'Hospital',
cte.OUT_PATIENT_HEALTH_CARE: 'Outpatient',
cte.HEALTH_CARE: 'Outpatient',
cte.RETIREMENT_HOME_OR_ORPHANAGE: 'SmallHotel',
cte.COMMERCIAL: 'RetailStripmall',
cte.STRIP_MALL: 'RetailStripmall',
cte.SUPERMARKET: 'RetailStripmall',
cte.RETAIL_SHOP_WITHOUT_REFRIGERATED_FOOD: 'RetailStandalone',
cte.RETAIL_SHOP_WITH_REFRIGERATED_FOOD: 'RetailStandalone',
cte.RESTAURANT: 'FullServiceRestaurant',
cte.QUICK_SERVICE_RESTAURANT: 'QuickServiceRestaurant',
cte.FULL_SERVICE_RESTAURANT: 'FullServiceRestaurant',
cte.HOTEL: 'SmallHotel',
cte.HOTEL_MEDIUM_CLASS: 'SmallHotel',
cte.SMALL_HOTEL: 'SmallHotel',
cte.LARGE_HOTEL: 'LargeHotel',
cte.DORMITORY: 'SmallHotel',
cte.EVENT_LOCATION: 'n/a',
cte.CONVENTION_CENTER: 'n/a',
cte.HALL: 'n/a',
cte.GREEN_HOUSE: 'n/a',
cte.INDUSTRY: 'n/a',
cte.WORKSHOP: 'n/a',
cte.WAREHOUSE: 'Warehouse',
cte.WAREHOUSE_REFRIGERATED: 'Warehouse',
cte.SPORTS_LOCATION: 'n/a',
cte.SPORTS_ARENA: 'n/a',
cte.GYMNASIUM: 'n/a',
cte.MOTION_PICTURE_THEATRE: 'n/a',
cte.MUSEUM: 'n/a',
cte.PERFORMING_ARTS_THEATRE: 'n/a',
cte.TRANSPORTATION: 'n/a',
cte.AUTOMOTIVE_FACILITY: 'n/a',
cte.PARKING_GARAGE: 'n/a',
cte.RELIGIOUS: 'n/a',
cte.NON_HEATED: 'n/a',
cte.DATACENTER: 'n/a',
cte.FARM: 'n/a'
}
@property
def dictionary(self) -> dict:
"""
Get the dictionary
:return: {}
"""
return self._dictionary

View File

@ -1,105 +0,0 @@
"""
NrcanPhysicsParameters import the construction and material information defined by NRCAN
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2022 Concordia CERC group
Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import logging
from hub.catalog_factories.construction_catalog_factory import ConstructionCatalogFactory
from hub.city_model_structure.building_demand.thermal_archetype import ThermalArchetype
from hub.city_model_structure.building_demand.construction import Construction
from hub.city_model_structure.building_demand.layer import Layer
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction.helpers.construction_helper import ConstructionHelper
class NrcanPhysicsParameters:
"""
NrcanPhysicsParameters class
"""
def __init__(self, city, divide_in_storeys=False):
self._city = city
self._divide_in_storeys = divide_in_storeys
self._climate_zone = ConstructionHelper.city_to_nrcan_climate_zone(city.climate_reference_city)
def enrich_buildings(self):
"""
Returns the city with the construction parameters assigned to the buildings
"""
city = self._city
nrcan_catalog = ConstructionCatalogFactory('nrcan').catalog
for building in city.buildings:
if building.function not in Dictionaries().hub_function_to_nrcan_construction_function:
logging.error('Building %s has an unknown building function %s', building.name, building.function)
continue
function = Dictionaries().hub_function_to_nrcan_construction_function[building.function]
try:
archetype = self._search_archetype(nrcan_catalog, function, building.year_of_construction, self._climate_zone)
except KeyError:
logging.error('Building %s has unknown construction archetype for building function: %s '
'[%s], building year of construction: %s and climate zone %s', building.name, function,
building.function, building.year_of_construction, self._climate_zone)
continue
thermal_archetype = ThermalArchetype()
self._assign_values(thermal_archetype, archetype)
for internal_zone in building.internal_zones:
internal_zone.thermal_archetype = thermal_archetype
@staticmethod
def _search_archetype(nrcan_catalog, function, year_of_construction, climate_zone):
nrcan_archetypes = nrcan_catalog.entries('archetypes')
for building_archetype in nrcan_archetypes:
construction_period_limits = building_archetype.construction_period.split('_')
if int(construction_period_limits[0]) <= int(year_of_construction) <= int(construction_period_limits[1]):
if str(function) == str(building_archetype.function) and climate_zone == str(building_archetype.climate_zone):
return building_archetype
raise KeyError('archetype not found')
@staticmethod
def _assign_values(thermal_archetype, catalog_archetype):
thermal_archetype.average_storey_height = catalog_archetype.average_storey_height
thermal_archetype.extra_loses_due_to_thermal_bridges = catalog_archetype.extra_loses_due_to_thermal_bridges
thermal_archetype.thermal_capacity = catalog_archetype.thermal_capacity
thermal_archetype.indirect_heated_ratio = 0
thermal_archetype.infiltration_rate_for_ventilation_system_on = catalog_archetype.infiltration_rate_for_ventilation_system_on
thermal_archetype.infiltration_rate_for_ventilation_system_off = catalog_archetype.infiltration_rate_for_ventilation_system_off
_constructions = []
for catalog_construction in catalog_archetype.constructions:
construction = Construction()
construction.type = catalog_construction.type
construction.name = catalog_construction.name
if catalog_construction.window_ratio is not None:
for _orientation in catalog_construction.window_ratio:
if catalog_construction.window_ratio[_orientation] is None:
catalog_construction.window_ratio[_orientation] = 0
construction.window_ratio = catalog_construction.window_ratio
_layers = []
for layer_archetype in catalog_construction.layers:
layer = Layer()
layer.thickness = layer_archetype.thickness
archetype_material = layer_archetype.material
layer.material_name = archetype_material.name
layer.no_mass = archetype_material.no_mass
if archetype_material.no_mass:
layer.thermal_resistance = archetype_material.thermal_resistance
else:
layer.density = archetype_material.density
layer.conductivity = archetype_material.conductivity
layer.specific_heat = archetype_material.specific_heat
layer.solar_absorptance = archetype_material.solar_absorptance
layer.thermal_absorptance = archetype_material.thermal_absorptance
layer.visible_absorptance = archetype_material.visible_absorptance
_layers.append(layer)
construction.layers = _layers
if catalog_construction.window is not None:
window_archetype = catalog_construction.window
construction.window_frame_ratio = window_archetype.frame_ratio
construction.window_g_value = window_archetype.g_value
construction.window_overall_u_value = window_archetype.overall_u_value
_constructions.append(construction)
thermal_archetype.constructions = _constructions

View File

@ -135,6 +135,8 @@ class Geojson:
building_aliases = []
if 'id' in feature:
building_name = feature['id']
elif 'id' in feature['properties']:
building_name = feature['properties']['id']
else:
building_name = uuid.uuid4()
if self._aliases_field is not None:

View File

@ -0,0 +1,45 @@
{
"type": "FeatureCollection",
"name": "Lachine_moved_existing_year_type",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": "1673", "footprint_area": 1294.9983604130321, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1673_bf6023ad.json", "type": "Building", "building_type": "6000", "number_of_stories": 3, "name": "Building_1673", "number_of_stories_above_ground": 3, "floor_area": 3884.9950812390962, "maximum_roof_height": 12.0, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667372756629021, 45.435676695791244 ], [ -73.667372756629021, 45.435369020278436 ], [ -73.666888584086863, 45.435363806039966 ], [ -73.666884389888097, 45.435671430856793 ], [ -73.667372756629021, 45.435676695791244 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1646", "footprint_area": 2044.068283611894, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1646_18838a5f.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1646", "number_of_stories_above_ground": 8, "floor_area": 16352.546268895137, "maximum_roof_height": 31.999999999999996, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.66455280450829, 45.435744913502532 ], [ -73.664552546221131, 45.435924884126429 ], [ -73.665143168622009, 45.435925291049998 ], [ -73.665143472602168, 45.435897888505529 ], [ -73.665271574391269, 45.435897888505529 ], [ -73.665271574391269, 45.43592397028798 ], [ -73.665554021737009, 45.43592541402861 ], [ -73.665558234480898, 45.435520460988293 ], [ -73.665274864731245, 45.435519575077379 ], [ -73.665273254390414, 45.435772607121798 ], [ -73.665145133767908, 45.435771908941341 ], [ -73.665145133767908, 45.435748141341286 ], [ -73.66455280450829, 45.435744913502532 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1647", "footprint_area": 2029.5591847320029, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1647_e842fa1c.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1647", "number_of_stories_above_ground": 8, "floor_area": 16236.473477856023, "maximum_roof_height": 31.999999999999996, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.66859722812778, 45.433658926667157 ], [ -73.668234175867511, 45.433673504539236 ], [ -73.66768744812434, 45.43401734227502 ], [ -73.668062079648976, 45.434307927076063 ], [ -73.668251686386938, 45.434187844642544 ], [ -73.668051314516219, 45.434031417950692 ], [ -73.668339905517598, 45.433849641065429 ], [ -73.668597133592854, 45.433839414337072 ], [ -73.66859722812778, 45.433658926667157 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1648", "footprint_area": 808.28076254848929, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1648_1baa7890.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1648", "number_of_stories_above_ground": 8, "floor_area": 6466.2461003879143, "maximum_roof_height": 31.999999999999996, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668743078788893, 45.434565837770023 ], [ -73.668578717259948, 45.43467261555972 ], [ -73.668774017167109, 45.434819733874662 ], [ -73.66918929609129, 45.434819866014372 ], [ -73.66918952072686, 45.434666890634482 ], [ -73.668872628011471, 45.434666890634482 ], [ -73.668743078788893, 45.434565837770023 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1649", "footprint_area": 1458.239197322313, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1649_57bc7dc1.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1649", "number_of_stories_above_ground": 8, "floor_area": 11665.913578578504, "maximum_roof_height": 31.999999999999996, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667010971728686, 45.434441574739452 ], [ -73.667114430089001, 45.434521723434102 ], [ -73.667260434022793, 45.434433564446572 ], [ -73.667326169895276, 45.434485171461255 ], [ -73.667520068466175, 45.434363261684247 ], [ -73.667721505074852, 45.434520773703198 ], [ -73.667912637656173, 45.434400698393027 ], [ -73.667539746318226, 45.434109118486703 ], [ -73.667010971728686, 45.434441574739452 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1650", "footprint_area": 504.15104012840311, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1650_287dcb62.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1650", "number_of_stories_above_ground": 6, "floor_area": 3024.9062407704187, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668126468300898, 45.437361574191002 ], [ -73.668126416777696, 45.437235594637158 ], [ -73.667664100454218, 45.437235597612165 ], [ -73.667664102091791, 45.43736157422493 ], [ -73.668126468300898, 45.437361574191002 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1651", "footprint_area": 892.77340679971894, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1651_63dc1f59.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1651", "number_of_stories_above_ground": 6, "floor_area": 5356.6404407983136, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668615557687048, 45.436113978949173 ], [ -73.668616133543296, 45.436293949755125 ], [ -73.66918885562572, 45.436293949755125 ], [ -73.669189050813969, 45.436113978949173 ], [ -73.668615557687048, 45.436113978949173 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1652", "footprint_area": 912.70544410405819, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1652_22bfc82c.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1652", "number_of_stories_above_ground": 6, "floor_area": 5476.2326646243491, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.669189050709747, 45.43629395377809 ], [ -73.669009112223776, 45.436293969856393 ], [ -73.66900930741204, 45.436880654582609 ], [ -73.669188834870596, 45.436880625241663 ], [ -73.669189050709747, 45.43629395377809 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1653", "footprint_area": 1140.9999999757201, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1653_dfeb9d5d.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1653", "number_of_stories_above_ground": 6, "floor_area": 6845.9999998543208, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668795301088977, 45.436293949755118 ], [ -73.668615557687062, 45.436293949755125 ], [ -73.66861555768709, 45.437027330789462 ], [ -73.66879530108902, 45.437027330789462 ], [ -73.668795301088977, 45.436293949755118 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1654", "footprint_area": 893.37365266692359, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1654_eead46db.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1654", "number_of_stories_above_ground": 6, "floor_area": 5360.2419160015415, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.669189050813955, 45.435925387121237 ], [ -73.66918905041392, 45.435745416315257 ], [ -73.668615557687104, 45.435745416315257 ], [ -73.668615557687104, 45.435925387121237 ], [ -73.669189050813955, 45.435925387121237 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1655", "footprint_area": 967.48230638653331, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1655_c71416fb.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1655", "number_of_stories_above_ground": 6, "floor_area": 5804.8938383191999, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.669163920747337, 45.435147559851927 ], [ -73.669164209534003, 45.435101917201926 ], [ -73.669078996777614, 45.435101652349225 ], [ -73.669078863681321, 45.435147559536063 ], [ -73.669008467435376, 45.435147559384667 ], [ -73.669008467484616, 45.435745416315257 ], [ -73.669188214507741, 45.435745416315257 ], [ -73.669189598629131, 45.435147559777384 ], [ -73.669163920747337, 45.435147559851927 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1656", "footprint_area": 980.37490820664607, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1656_75f94a0d.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1656", "number_of_stories_above_ground": 6, "floor_area": 5882.2494492398764, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668640406248173, 45.435101024674736 ], [ -73.668640926617968, 45.435147558060443 ], [ -73.668615250676694, 45.435147558111886 ], [ -73.668614717759652, 45.435745416315257 ], [ -73.668794461161582, 45.435745416315257 ], [ -73.668794461130858, 45.435147557752828 ], [ -73.668768783501889, 45.435147559606158 ], [ -73.668768786127728, 45.435101028381446 ], [ -73.668640406248173, 45.435101024674736 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1657", "footprint_area": 222.09817462227147, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1657_4ca8f080.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1657", "number_of_stories_above_ground": 6, "floor_area": 1332.5890477336288, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.669189548238336, 45.433835907779731 ], [ -73.668957951796472, 45.433835907779731 ], [ -73.66895767313865, 45.433946700211251 ], [ -73.6691892695805, 45.433946700211251 ], [ -73.669189548238336, 45.433835907779731 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1658", "footprint_area": 648.19765522326634, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1658_424b2df8.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1658", "number_of_stories_above_ground": 6, "floor_area": 3889.185931339598, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668938469265626, 45.433656662069488 ], [ -73.668938469265626, 45.433674658743001 ], [ -73.668861436379089, 45.433674596130288 ], [ -73.668861436379089, 45.433656535919432 ], [ -73.668763842635698, 45.433656376098661 ], [ -73.668763842635698, 45.4338357829904 ], [ -73.669189548238336, 45.433835907779731 ], [ -73.6691898026356, 45.433657073656256 ], [ -73.668938469265626, 45.433656662069488 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1659", "footprint_area": 853.04053182815187, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1659_52a1d774.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1659", "number_of_stories_above_ground": 6, "floor_area": 5118.2431909689112, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.669189018377537, 45.434570084215956 ], [ -73.669189048414026, 45.434021717112955 ], [ -73.669009305012082, 45.434021717112955 ], [ -73.669009274983594, 45.434569938524483 ], [ -73.669189018377537, 45.434570084215956 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1660", "footprint_area": 358.93166192741774, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1660_90dba68e.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1660", "number_of_stories_above_ground": 6, "floor_area": 2153.5899715645064, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667969959666152, 45.434745444652918 ], [ -73.668107054384933, 45.434659255252576 ], [ -73.668106768269212, 45.434658992214736 ], [ -73.667892012804259, 45.434491065605087 ], [ -73.667755753028672, 45.434576673682074 ], [ -73.667969959666152, 45.434745444652918 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1661", "footprint_area": 988.39325611376989, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1661_5b6bbc63.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1661", "number_of_stories_above_ground": 6, "floor_area": 5930.3595366826194, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667753152960088, 45.434647875115395 ], [ -73.667725464958153, 45.434626158405926 ], [ -73.66760410247791, 45.434703366952746 ], [ -73.667260434022793, 45.434433564446572 ], [ -73.667114430089001, 45.434521723434102 ], [ -73.667509950599225, 45.434832222062724 ], [ -73.667584379668355, 45.434785648257488 ], [ -73.667673053917611, 45.434856243925609 ], [ -73.66785765431095, 45.43474233866327 ], [ -73.667810874668859, 45.434706056731812 ], [ -73.667816274334456, 45.43470263672323 ], [ -73.667777231499798, 45.434672356635119 ], [ -73.66783197144278, 45.434637965632071 ], [ -73.667804946747651, 45.434615432853164 ], [ -73.667753152960088, 45.434647875115395 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1662", "footprint_area": 478.6204031245943, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1662_97193100.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1662", "number_of_stories_above_ground": 6, "floor_area": 2871.7224187475658, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668720451301567, 45.434274053461046 ], [ -73.668555411303828, 45.434144372382654 ], [ -73.668316591688495, 45.434291144713121 ], [ -73.668479184564703, 45.4344214325316 ], [ -73.668720451301567, 45.434274053461046 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1663", "footprint_area": 1434.9411493013613, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1663_d66f6249.json", "type": "Building", "building_type": "1000", "number_of_stories": 6, "name": "Building_1663", "number_of_stories_above_ground": 6, "floor_area": 8609.6468958081678, "maximum_roof_height": 24.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.665928391134017, 45.437627214568224 ], [ -73.666185188484576, 45.437627275871236 ], [ -73.666189864381366, 45.437389159450817 ], [ -73.666515593195911, 45.437388569873107 ], [ -73.666515956213601, 45.437208599039842 ], [ -73.665936570484675, 45.437209167458711 ], [ -73.665928391134017, 45.437627214568224 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1664", "footprint_area": 855.313686118232, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1664_de6c70d0.json", "type": "Building", "building_type": "1000", "number_of_stories": 15, "name": "Building_1664", "number_of_stories_above_ground": 15, "floor_area": 12829.70529177348, "maximum_roof_height": 60.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.66801719364247, 45.436793649477018 ], [ -73.667596622414578, 45.436793617659305 ], [ -73.667596622414578, 45.437028621599758 ], [ -73.668017013592291, 45.437028654137954 ], [ -73.66801719364247, 45.436793649477018 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1665", "footprint_area": 1149.438834497756, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1665_156fa2e7.json", "type": "Building", "building_type": "1000", "number_of_stories": 15, "name": "Building_1665", "number_of_stories_above_ground": 15, "floor_area": 17241.582517466341, "maximum_roof_height": 60.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.666044727070982, 45.436769741251766 ], [ -73.666044837597411, 45.436803158516874 ], [ -73.665941879046017, 45.436803425356793 ], [ -73.665939390855229, 45.437027725380389 ], [ -73.666478602281259, 45.437027845311647 ], [ -73.666478602281259, 45.436803158516874 ], [ -73.666440085838005, 45.436803158516874 ], [ -73.666440085838005, 45.436776026773252 ], [ -73.666044727070982, 45.436769741251766 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1666", "footprint_area": 2324.0116964114713, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1666_a8635b05.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1666", "number_of_stories_above_ground": 8, "floor_area": 18592.093571291771, "maximum_roof_height": 31.999999999999996, "building_type_2": 1921, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.665132598176768, 45.436857164525861 ], [ -73.665132598176768, 45.436830168904962 ], [ -73.66526101030756, 45.436830168904962 ], [ -73.665261665863596, 45.436950811398802 ], [ -73.665541986084719, 45.436950063128975 ], [ -73.665547984414985, 45.43642947858028 ], [ -73.66526555307334, 45.436427909596567 ], [ -73.665262428718847, 45.436704189340773 ], [ -73.665134022837194, 45.436704189340773 ], [ -73.665134283864731, 45.436681107253577 ], [ -73.664537543332827, 45.436677193719873 ], [ -73.664535192983209, 45.436853246633184 ], [ -73.665132598176768, 45.436857164525861 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1667", "footprint_area": 1027.8277728328394, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1667_4e77528c.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1667", "number_of_stories_above_ground": 8, "floor_area": 8222.6221826627152, "maximum_roof_height": 31.999999999999996, "building_type_2": 1921, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.665549510877995, 45.436294496839402 ], [ -73.665546533973455, 45.436294494963875 ], [ -73.665551547608715, 45.43611412122825 ], [ -73.664891717500467, 45.43611412122825 ], [ -73.664889716569192, 45.436294496839402 ], [ -73.665549510877995, 45.436294496839402 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1668", "footprint_area": 735.09355594096996, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1668_a550f9b3.json", "type": "Building", "building_type": "1000", "number_of_stories": 4, "name": "Building_1668", "number_of_stories_above_ground": 4, "floor_area": 2940.3742237638799, "maximum_roof_height": 16.0, "building_type_2": 1921, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.66475047967208, 45.436114828937427 ], [ -73.664570742063574, 45.436113825659589 ], [ -73.664564689409346, 45.436586226359324 ], [ -73.664744425564265, 45.436587357626195 ], [ -73.66475047967208, 45.436114828937427 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1669", "footprint_area": 374.11245699843494, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1669_f3b002d8.json", "type": "Building", "building_type": "1000", "number_of_stories": 3, "name": "Building_1669", "number_of_stories_above_ground": 3, "floor_area": 1122.3373709953048, "maximum_roof_height": 12.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668905035441242, 45.435101111653012 ], [ -73.669237843191354, 45.43510214606615 ], [ -73.669238664872836, 45.434972279551545 ], [ -73.668905857122724, 45.434971245138399 ], [ -73.668905035441242, 45.435101111653012 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1676", "footprint_area": 2131.0154588451987, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1676_b0ffe753.json", "type": "Building", "building_type": "7444", "number_of_stories": 4, "name": "Building_1676", "number_of_stories_above_ground": 4, "floor_area": 8524.0618353807949, "maximum_roof_height": 16.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.664914894830218, 45.437389562610612 ], [ -73.664914421982061, 45.437416567275534 ], [ -73.665251242135469, 45.437416567275534 ], [ -73.665537365859819, 45.437416574265519 ], [ -73.665540953534972, 45.437218607178806 ], [ -73.664917888530852, 45.437218590425296 ], [ -73.664917396555353, 45.437246687465077 ], [ -73.664788944729779, 45.43724558257906 ], [ -73.664791833138949, 45.437080662156177 ], [ -73.664531700372052, 45.437080298164545 ], [ -73.664524863570179, 45.437482564295294 ], [ -73.664781660571592, 45.437482564295294 ], [ -73.664786491369767, 45.437389885181737 ], [ -73.664914894830218, 45.437389562610612 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1677", "footprint_area": 3933.6318337951816, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1677_4ce319f5.json", "type": "Building", "building_type": "7222", "number_of_stories": 3, "name": "Building_1677", "number_of_stories_above_ground": 3, "floor_area": 11800.895501385545, "maximum_roof_height": 12.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.664510358921731, 45.43833589104328 ], [ -73.665166245421304, 45.438215027152289 ], [ -73.665169463688571, 45.438042724913529 ], [ -73.665525747607063, 45.437978053148655 ], [ -73.665528747828148, 45.437726296140902 ], [ -73.665172919706151, 45.43772566338501 ], [ -73.664779484869115, 45.43772566338501 ], [ -73.664519435051503, 45.437773130608782 ], [ -73.664510358921731, 45.43833589104328 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1678", "footprint_area": 4641.7803576890328, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1678_02988034.json", "type": "Building", "building_type": "6111", "number_of_stories": 3, "name": "Building_1678", "number_of_stories_above_ground": 3, "floor_area": 13925.341073067098, "maximum_roof_height": 12.0, "building_type_2": 6000, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668421955626641, 45.43559119537175 ], [ -73.668022358103428, 45.435590593066074 ], [ -73.668017148524001, 45.436852538891273 ], [ -73.668017013602807, 45.437028640404428 ], [ -73.668149244825912, 45.437029414121227 ], [ -73.668149629990353, 45.436996506459352 ], [ -73.668131488745573, 45.436996398476872 ], [ -73.668131803506142, 45.436970122699734 ], [ -73.668226675715701, 45.436970725641395 ], [ -73.668228200928937, 45.436853097330918 ], [ -73.668416561775643, 45.436853385924174 ], [ -73.66841847435542, 45.436407825441904 ], [ -73.668421955626641, 45.43559119537175 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1679", "footprint_area": 4319.0295927044426, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1679_b24420b9.json", "type": "Building", "building_type": "6111", "number_of_stories": 3, "name": "Building_1679", "number_of_stories_above_ground": 3, "floor_area": 12957.088778113328, "maximum_roof_height": 12.0, "building_type_2": 6000, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.6676053228109, 45.435591523940779 ], [ -73.667602613827711, 45.436793618112581 ], [ -73.66801719364247, 45.436793649477039 ], [ -73.66802232750409, 45.435594547117901 ], [ -73.667654200178163, 45.435593080355837 ], [ -73.667654208542956, 45.435592048718291 ], [ -73.6676053228109, 45.435591523940779 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1680", "footprint_area": 1225.15986339136, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1680_6c9bd455.json", "type": "Building", "building_type": "6111", "number_of_stories": 3, "name": "Building_1680", "number_of_stories_above_ground": 3, "floor_area": 3675.4795901740799, "maximum_roof_height": 12.0, "building_type_2": 6000, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667596622414578, 45.437020511364551 ], [ -73.667596622489881, 45.436793617659319 ], [ -73.666974026335765, 45.436790318252953 ], [ -73.666971576490013, 45.437017206599805 ], [ -73.667596622414578, 45.437020511364551 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1681", "footprint_area": 7440.6678389157605, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1681_884eb763.json", "type": "Building", "building_type": "6111", "number_of_stories": 3, "name": "Building_1681", "number_of_stories_above_ground": 3, "floor_area": 22322.003516747282, "maximum_roof_height": 12.0, "building_type_2": 6000, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.666492248633858, 45.43638661369733 ], [ -73.666473547611133, 45.43638661369733 ], [ -73.666482465287686, 45.435869205032546 ], [ -73.666486037344583, 45.435671228711151 ], [ -73.66649324539415, 45.434974010180255 ], [ -73.666403327005156, 45.434973140984212 ], [ -73.6660085967535, 45.434970382162497 ], [ -73.666006550487495, 45.436769134310026 ], [ -73.666479628079273, 45.436776655426591 ], [ -73.666492248633858, 45.43638661369733 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1687", "footprint_area": 3264.7409803860646, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1687_cb4cf712.json", "type": "Building", "building_type": "1000", "number_of_stories": 11, "name": "Building_1687", "number_of_stories_above_ground": 11, "floor_area": 35912.150784246711, "maximum_roof_height": 44.0, "building_type_2": 1921, "building_type_3": 6111 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.665567583885291, 45.43466932058314 ], [ -73.665283112941253, 45.434850377542183 ], [ -73.665281874817651, 45.43496198922243 ], [ -73.665153485795187, 45.434961718577995 ], [ -73.665153808453496, 45.434932632276528 ], [ -73.664555714212526, 45.43531323855396 ], [ -73.664551889509383, 45.435609400125053 ], [ -73.664834024034789, 45.435611334713926 ], [ -73.66483749936549, 45.435362156046601 ], [ -73.665151281977501, 45.435160383553075 ], [ -73.665151792763695, 45.435114338318201 ], [ -73.665280184788216, 45.435114338338892 ], [ -73.665277174814051, 45.435385665207676 ], [ -73.665559627580862, 45.435386548251792 ], [ -73.665567583885291, 45.43466932058314 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1674", "footprint_area": 2484.8825099908718, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1674_bbeef534.json", "type": "Building", "building_type": "6000", "number_of_stories": 3, "name": "Building_1674", "number_of_stories_above_ground": 3, "floor_area": 7454.6475299726153, "maximum_roof_height": 12.0, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667248610160003, 45.435924163141479 ], [ -73.66724798100546, 45.435945580128184 ], [ -73.667549584180662, 45.435948734169607 ], [ -73.66754952022481, 45.435951888250706 ], [ -73.667604511663086, 45.435951888211008 ], [ -73.667605126160126, 45.43567920089707 ], [ -73.666884389888097, 45.435671430856793 ], [ -73.66688434878435, 45.435674445624294 ], [ -73.666486030839678, 45.435671772067714 ], [ -73.66648176823378, 45.435909648495979 ], [ -73.666563136490083, 45.435909648495979 ], [ -73.666563129588553, 45.435924001221537 ], [ -73.667248610160003, 45.435924163141479 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1688", "footprint_area": 1641.9575463399633, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1688_55a8cadd.json", "type": "Building", "building_type": "1000", "number_of_stories": 14, "name": "Building_1688", "number_of_stories_above_ground": 14, "floor_area": 22987.405648759486, "maximum_roof_height": 56.0, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.665920466951619, 45.438074832810123 ], [ -73.666515593195911, 45.437963343188848 ], [ -73.666515593195911, 45.437725645247056 ], [ -73.66614588653529, 45.437725086993041 ], [ -73.666145886539852, 45.437636265029319 ], [ -73.665966143158769, 45.437636222120737 ], [ -73.665966572968443, 45.437725511285144 ], [ -73.665926803843391, 45.437725157245957 ], [ -73.665920466951619, 45.438074832810123 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1675", "footprint_area": 3125.7782000612933, "floor_height": 4.0, "year_built": 1990, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1675_730b8065.json", "type": "Building", "building_type": "6000", "number_of_stories": 3, "name": "Building_1675", "number_of_stories_above_ground": 3, "floor_area": 9377.33460018388, "maximum_roof_height": 12.0, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.666490452451612, 45.434756728517236 ], [ -73.666493252099286, 45.434974531817161 ], [ -73.666486031717994, 45.435671772046057 ], [ -73.66688434878435, 45.435674445624294 ], [ -73.666888584086863, 45.435363806039966 ], [ -73.666893304291094, 45.434832713951032 ], [ -73.66680618457589, 45.43483247822946 ], [ -73.66680664677321, 45.434750015606156 ], [ -73.666571966084391, 45.434749376709796 ], [ -73.666571925317186, 45.434756728517236 ], [ -73.666490452451612, 45.434756728517236 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1689", "footprint_area": 2187.8048172803792, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1689_909fbfb4.json", "type": "Building", "building_type": "1000", "number_of_stories": 15, "name": "Building_1689", "number_of_stories_above_ground": 15, "floor_area": 32817.072259205685, "maximum_roof_height": 60.0, "building_type_2": null, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.667504385093551, 45.437594060949706 ], [ -73.667144840702818, 45.437660657392186 ], [ -73.667144834020434, 45.437688581026286 ], [ -73.667042118950661, 45.437707606377302 ], [ -73.667042099336527, 45.43721728784066 ], [ -73.666785074014001, 45.437217907319628 ], [ -73.666785208300354, 45.437912954554328 ], [ -73.667042081174898, 45.437865459625925 ], [ -73.667042087856515, 45.437837539218407 ], [ -73.667144802918216, 45.43781854754981 ], [ -73.667144796236599, 45.437846467957336 ], [ -73.667504385093537, 45.437779981190126 ], [ -73.667504385093551, 45.437594060949706 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1690", "footprint_area": 1674.9280842908665, "floor_height": 4.0, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1690_0146d7fc.json", "type": "Building", "building_type": "1000", "number_of_stories": 10, "name": "Building_1690", "number_of_stories_above_ground": 10, "floor_area": 16749.280842908665, "maximum_roof_height": 40.0, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.668126534542566, 45.437681866271078 ], [ -73.668383377125423, 45.437633845683195 ], [ -73.668383491801876, 45.437217551516433 ], [ -73.668126409436084, 45.437217643643855 ], [ -73.668126534542566, 45.437523541871258 ], [ -73.668023824027188, 45.437542745148519 ], [ -73.668023824027188, 45.437514805548552 ], [ -73.66766413614485, 45.437582054613621 ], [ -73.66766415445214, 45.437768315190588 ], [ -73.668023765788789, 45.437701080436888 ], [ -73.668023824027188, 45.437673129948379 ], [ -73.6681266029602, 45.437653913879537 ], [ -73.668126534542566, 45.437681866271078 ] ] ] } },
{ "type": "Feature", "properties": { "id": "1691", "footprint_area": 2416.2204562020706, "floor_height": 3.9999999999999996, "year_built": 2019, "detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1691_e4a64903.json", "type": "Building", "building_type": "1000", "number_of_stories": 8, "name": "Building_1691", "number_of_stories_above_ground": 8, "floor_area": 19329.763649616565, "maximum_roof_height": 31.999999999999996, "building_type_2": 6111, "building_type_3": null }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -73.66765675225426, 45.435369763356881 ], [ -73.667656760492804, 45.435368747291285 ], [ -73.668226081270987, 45.435369758924502 ], [ -73.668226073032457, 45.435310418637101 ], [ -73.668225335766905, 45.435310418637101 ], [ -73.668225335766905, 45.435220718797545 ], [ -73.668226073032457, 45.435220718797545 ], [ -73.66842324930586, 45.435220707215464 ], [ -73.66842268222733, 45.435175714511374 ], [ -73.668422683258228, 45.434982523102775 ], [ -73.667606057102702, 45.434982225122766 ], [ -73.667606057102702, 45.435220703648262 ], [ -73.66765675225426, 45.435220718797545 ], [ -73.66765675225426, 45.435369763356881 ] ] ] } }
]
}

158
main.py
View File

@ -7,9 +7,31 @@ from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
import hub.helpers.constants as cte
from hub.imports.energy_systems_factory import EnergySystemsFactory
import geopandas as gpd
# Specify the GeoJSON file path
input_files_path = (Path(__file__).parent / 'input_files')
geojson_file_path = input_files_path / 'test.geojson'
building_type_2_modelling=2
#'Lachine_New_Developments.geojson'
geojson_file_path = input_files_path / 'Lachine_moved_2024_type.geojson'
if building_type_2_modelling==1:
gdf = gpd.read_file(geojson_file_path)
# Filter gdf when 'building_type_2' is not null
filtered_gdf = gdf[gdf['building_type_2'].notnull()]
output_geojson =input_files_path /'Lachine_moved_2024_type_2.geojson'
geojson_file_path =output_geojson
filtered_gdf.to_file(output_geojson, driver='GeoJSON')
print(f"New GeoJSON saved in: {output_geojson}")
if building_type_2_modelling==2:
gdf = gpd.read_file(geojson_file_path)
# Filter gdf when 'building_type_3' is not null
filtered_gdf = gdf[gdf['building_type_3'].notnull()]
output_geojson =input_files_path /'Lachine_moved_2024_type_3.geojson'
geojson_file_path = output_geojson
filtered_gdf.to_file(output_geojson, driver='GeoJSON')
print(f"New GeoJSON saved in: {output_geojson}")
output_path = (Path(__file__).parent / 'out_files').resolve()
output_path.mkdir(parents=True, exist_ok=True)
# Create city object from GeoJSON file
@ -24,34 +46,114 @@ ConstructionFactory('nrcan', city).enrich()
UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich()
energy_plus_workflow(city)
def to_dict(building, total_floor_area):
return {
'roof_area': building.floor_area,
'total_floor_area': total_floor_area,
'year_of_construction' : building.year_of_construction,
'type_function':building.function,
'beam_kWh_per_m2': sum(building.beam[cte.HOUR])/ (3.6e6),
'diffuse_kWh_per_m2': sum(building.diffuse[cte.HOUR])/ (3.6e6),
'direct_normal_kWh_per_m2': sum(building.direct_normal[cte.HOUR])/ (3.6e6),
'average_storey_height_meters': building.average_storey_height,
'max_height_meters_meters': building.max_height,
'global_horizontal_kWh_per_m2': sum(building.global_horizontal[cte.HOUR])/ (3.6e6),
'appliances_peak_load_kW':building.appliances_peak_load[cte.YEAR][0]/ (1e3),
'domestic_hot_water_peak_load_kW': building.domestic_hot_water_peak_load[cte.YEAR][0]/ (1e3),
'heating_peak_load_kW': building.heating_peak_load[cte.YEAR][0]/ (1e3),
'cooling_peak_load_kW': building.cooling_peak_load[cte.YEAR][0]/ (1e3),
'lighting_peak_load_kW': building.lighting_peak_load[cte.YEAR][0]/ (1e3),
'heating_demand_kWh_per_m2' : sum(building.heating_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
'cooling_demand_kWh_per_m2' : sum(building.cooling_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
'domestic_hot_water_heat_demand_kWh_per_m2': sum(building.domestic_hot_water_heat_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
'appliances_electrical_demand_kWh_per_m2':sum(building.appliances_electrical_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
'lighting_electrical_demand_kWh_per_m2': sum(building.lighting_electrical_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
'heating_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.heating_demand[cte.HOUR]],
'cooling_demand_kWh':[x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.cooling_demand[cte.HOUR]],
'domestic_hot_water_heat_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.domestic_hot_water_heat_demand[cte.HOUR]],
'appliances_electrical_demand_kWh':[x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.appliances_electrical_demand[cte.HOUR]],
'lighting_electrical_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.lighting_electrical_demand[cte.HOUR]]
}
buildings_dic={}
for building in city.buildings:
print(building.heating_demand[cte.YEAR][0] / 3.6e6)
print(building.name)
total_floor_area = 0
for thermal_zone in building.thermal_zones_from_internal_zones:
total_floor_area += thermal_zone.total_floor_area
print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))
building.energy_systems_archetype_name = 'system 1 gas'
total_floor_area = 0
for thermal_zone in building.thermal_zones_from_internal_zones:
total_floor_area += thermal_zone.total_floor_area
print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))
building.energy_systems_archetype_name = 'system 1 gas'
buildings_dic[building.name] = to_dict(building,total_floor_area)
print('test')
EnergySystemsFactory('montreal_custom', city).enrich()
print('test')
for building in city.buildings:
energy_systems = building.energy_systems
for energy_system in energy_systems:
generation_units = energy_system.generation_systems
if cte.HEATING in energy_system.demand_types:
for generation_unit in generation_units:
generation_unit.heat_efficiency = 0.96
""""EXPORTERS"""
import pandas as pd
# Convert the dictionary to a DataFrame
df = pd.DataFrame.from_dict(buildings_dic, orient='index')
# Export the DataFrame to an Excel file
excel_file_path = r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\buildings.xlsx'
df.to_excel(excel_file_path, index=True, index_label='Building')
import json
def make_json_serializable(data):
if isinstance(data, (str, int, float, bool, type(None))):
return data
elif isinstance(data, dict):
return {k: make_json_serializable(v) for k, v in data.items()}
elif isinstance(data, list):
return [make_json_serializable(item) for item in data]
else:
return str(data) # Convert any other type to a string
# Load the existing GeoJSON file
with open(geojson_file_path, 'r') as f:
geojson_data = json.load(f)
# Update the properties of each feature
for feature in geojson_data['features']:
# Attempt to retrieve the building_id from 'id' or 'properties'
building_id = feature.get('id') or feature['properties'].get('id')
if building_id in buildings_dic:
serializable_properties = make_json_serializable(buildings_dic[building_id])
feature['properties'].update(serializable_properties)
# Save the updated GeoJSON to a new file
updated_geojson_file_path = r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\updated_buildings.geojson' # Replace with your actual path
with open(updated_geojson_file_path, 'w') as f:
json.dump(geojson_data, f, indent=4)
# EnergySystemsFactory('montreal_custom', city).enrich()
# print('test')
# for building in city.buildings:
# building.function = cte.COMMERCIAL
#
# ConstructionFactory('nrcan', city).enrich()
# UsageFactory('nrcan', city).enrich()
# energy_plus_workflow(city)
# energy_systems = building.energy_systems
# for energy_system in energy_systems:
# generation_units = energy_system.generation_systems
# if cte.HEATING in energy_system.demand_types:
# for generation_unit in generation_units:
# generation_unit.heat_efficiency = 0.96
# # for building in city.buildings:
# # building.function = cte.COMMERCIAL
# #
# # ConstructionFactory('nrcan', city).enrich()
# # UsageFactory('nrcan', city).enrich()
# # energy_plus_workflow(city)
# # for building in city.buildings:
# # print(building.heating_demand[cte.YEAR][0] / 3.6e6)
# # print(building.name)
# # total_floor_area = 0
# # for thermal_zone in building.thermal_zones_from_internal_zones:
# # total_floor_area += thermal_zone.total_floor_area
# # print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))
# for building in city.buildings:
# print(building.heating_demand[cte.YEAR][0] / 3.6e6)
# print(building.name)
# total_floor_area = 0
# for thermal_zone in building.thermal_zones_from_internal_zones:
# total_floor_area += thermal_zone.total_floor_area
# print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))
# print(building.name)
# print(building.year_of_construction)
# print(building.usages_percentage)

176
main_results_in_geojson.py Normal file
View File

@ -0,0 +1,176 @@
from pathlib import Path
from scripts.ep_workflow import energy_plus_workflow
from hub.helpers.monthly_values import MonthlyValues
from hub.imports.geometry_factory import GeometryFactory
from hub.helpers.dictionaries import Dictionaries
from hub.imports.construction_factory import ConstructionFactory
from hub.imports.usage_factory import UsageFactory
from hub.imports.weather_factory import WeatherFactory
import hub.helpers.constants as cte
from hub.imports.energy_systems_factory import EnergySystemsFactory
from hub.helpers.peak_loads import PeakLoads
import geopandas as gpd
import json
# Specify the GeoJSON file path
input_files_path = (Path(__file__).parent / 'input_files')
output_path = (Path(__file__).parent / 'out_files').resolve()
output_path.mkdir(parents=True, exist_ok=True)
geojson_file_path = output_path / 'updated_buildings_with_all_data.geojson'
with open(geojson_file_path , 'r') as f:
building_type_data = json.load(f)
# Create city object from GeoJSON file
city = GeometryFactory('geojson',
path=geojson_file_path,
height_field='maximum_roof_height',
year_of_construction_field='year_built',
function_field='building_type',
function_to_hub=Dictionaries().montreal_function_to_hub_function).city
# Enrich city data
ConstructionFactory('nrcan', city).enrich()
UsageFactory('nrcan', city).enrich()
WeatherFactory('epw', city).enrich()
# #energy plus is not going to be processed here, as demand has been obtained before
# energy_plus_workflow(city)
percentage_data = {
1646: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2672.550473, "total_floor_area": 26725.50473},
1647: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2653.626087, "total_floor_area": 26536.26087},
1648: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1056.787496, "total_floor_area": 10567.87496},
1649: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1906.620746, "total_floor_area": 19066.20746},
1650: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 659.1119416, "total_floor_area": 5272.895533},
1651: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1167.208109, "total_floor_area": 9337.664871},
1652: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1193.251653, "total_floor_area": 9546.013222},
1653: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1491.722543, "total_floor_area": 11933.78035},
1654: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1168.005028, "total_floor_area": 9344.040224},
1655: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1264.906961, "total_floor_area": 10119.25569},
1656: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1281.768818, "total_floor_area": 10254.15054},
1657: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 290.3886018, "total_floor_area": 2323.108814},
1658: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 847.5095193, "total_floor_area": 6780.076155},
1659: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1115.319153, "total_floor_area": 8922.553224},
1660: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 469.2918062, "total_floor_area": 3754.33445},
1661: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1292.298346, "total_floor_area": 10338.38677},
1662: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 625.7828863, "total_floor_area": 5006.263091},
1663: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1876.02897, "total_floor_area": 15008.23176},
1664: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1118.224781, "total_floor_area": 22364.49562},
1665: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1502.787808, "total_floor_area": 30055.75617},
1666: {"type1_%": 0.891045711, "type2_%": 0.108954289, "type3_%": 0, "roof_area": 3038.486076, "total_floor_area": 30384.86076},
1667: {"type1_%": 0.8, "type2_%": 0.2, "type3_%": 0, "roof_area": 1343.832818, "total_floor_area": 13438.32818},
1668: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 961.0996956, "total_floor_area": 4805.498478},
1669: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 489.1282111, "total_floor_area": 1956.512845},
1673: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1693.141465, "total_floor_area": 5079.424396},
1674: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 3248.827576, "total_floor_area": 9746.482729},
1675: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 4086.842191, "total_floor_area": 12260.52657},
1676: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2786.114146, "total_floor_area": 11144.45658},
1677: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 5142.784184, "total_floor_area": 15428.35255},
1678: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 6068.664574, "total_floor_area": 18205.99372},
1679: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 5646.751407, "total_floor_area": 16940.25422},
1680: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1601.765953, "total_floor_area": 4805.297859},
1681: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 9728.221797, "total_floor_area": 29184.66539},
1687: {"type1_%": 0.606611029, "type2_%": 0.28211422, "type3_%": 0.11127475, "roof_area": 4268.608743, "total_floor_area": 59760.52241},
1688: {"type1_%": 0.92, "type2_%": 0.08, "type3_%": 0, "roof_area": 2146.654828, "total_floor_area": 38639.7869},
1689: {"type1_%": 0.96, "type2_%": 0.04, "type3_%": 0, "roof_area": 2860.270711, "total_floor_area": 57205.41421},
1690: {"type1_%": 0.94, "type2_%": 0.06, "type3_%": 0, "roof_area": 2189.732519, "total_floor_area": 28466.52275},
1691: {"type1_%": 0.75, "type2_%": 0.25, "type3_%": 0, "roof_area": 3159.077523, "total_floor_area": 31590.77523},
}
def enrich_buildings_with_geojson_data (building_type_data, city):
for building in city.buildings:
for idx, feature in enumerate(building_type_data['features']):
if feature['properties']['id'] == str(building.name):
building.heating_demand[cte.HOUR] = [x *1000* cte.WATTS_HOUR_TO_JULES for x in building_type_data['features'][idx]['properties'].get('heating_demand_kWh', [0])]
building.cooling_demand[cte.HOUR] = [x *1000* cte.WATTS_HOUR_TO_JULES for x in building_type_data['features'][idx]['properties'].get('cooling_demand_kWh', [0])]
building.domestic_hot_water_heat_demand[cte.HOUR] = [x *1000* cte.WATTS_HOUR_TO_JULES for x in building_type_data['features'][idx]['properties'].get('domestic_hot_water_heat_demand_kWh', [0])]
building.appliances_electrical_demand[cte.HOUR] = [x *1000* cte.WATTS_HOUR_TO_JULES for x in building_type_data['features'][idx]['properties'].get('appliances_electrical_demand_kWh', [0])]
building.lighting_electrical_demand[cte.HOUR] = [x *1000* cte.WATTS_HOUR_TO_JULES for x in building_type_data['features'][idx]['properties'].get('lighting_electrical_demand_kWh', [0])]
building.heating_demand[cte.MONTH] = MonthlyValues.get_total_month(building.heating_demand[cte.HOUR])
building.cooling_demand[cte.MONTH] = MonthlyValues.get_total_month(building.cooling_demand[cte.HOUR])
building.domestic_hot_water_heat_demand[cte.MONTH] = (MonthlyValues.get_total_month(building.domestic_hot_water_heat_demand[cte.HOUR]))
building.appliances_electrical_demand[cte.MONTH] = (MonthlyValues.get_total_month(building.appliances_electrical_demand[cte.HOUR]))
building.lighting_electrical_demand[cte.MONTH] = (MonthlyValues.get_total_month(building.lighting_electrical_demand[cte.HOUR]))
building.heating_demand[cte.YEAR] = [sum(building.heating_demand[cte.MONTH])]
building.cooling_demand[cte.YEAR] = [sum(building.cooling_demand[cte.MONTH])]
building.domestic_hot_water_heat_demand[cte.YEAR] = [sum(building.domestic_hot_water_heat_demand[cte.MONTH])]
building.appliances_electrical_demand[cte.YEAR] = [sum(building.appliances_electrical_demand[cte.MONTH])]
building.lighting_electrical_demand[cte.YEAR] = [sum(building.lighting_electrical_demand[cte.MONTH])]
enrich_buildings_with_geojson_data (building_type_data, city)
# for building in city.buildings:
# monthly_values = PeakLoads().peak_loads_from_hourly(building.lighting_electrical_demand[cte.HOUR])
# building.lighting_peak_load[cte.MONTH]=[x / cte.WATTS_HOUR_TO_JULES for x in monthly_values]
# building.lighting_peak_load[cte.YEAR] = [max(monthly_values) / cte.WATTS_HOUR_TO_JULES]
# monthly_values = PeakLoads().peak_loads_from_hourly(building.appliances_electrical_demand[cte.HOUR])
# building.appliances_electrical_demand[cte.MONTH]=[x / cte.WATTS_HOUR_TO_JULES for x in monthly_values]
# building.appliances_electrical_demand[cte.YEAR] = [max(monthly_values) / cte.WATTS_HOUR_TO_JULES]
# def to_dict(building, total_floor_area):
# return {
# 'roof_area': building.floor_area,
# 'total_floor_area': total_floor_area,
# 'year_of_construction' : building.year_of_construction,
# 'type_function':building.function,
# 'beam_kWh_per_m2': sum(building.beam[cte.HOUR])/ (3.6e6),
# 'diffuse_kWh_per_m2': sum(building.diffuse[cte.HOUR])/ (3.6e6),
# 'direct_normal_kWh_per_m2': sum(building.direct_normal[cte.HOUR])/ (3.6e6),
# 'average_storey_height_meters': building.average_storey_height,
# 'max_height_meters_meters': building.max_height,
# 'global_horizontal_kWh_per_m2': sum(building.global_horizontal[cte.HOUR])/ (3.6e6),
# 'appliances_peak_load_kW':building.appliances_peak_load[cte.YEAR][0]/ (1e3),
# 'domestic_hot_water_peak_load_kW': building.domestic_hot_water_peak_load[cte.YEAR][0]/ (1e3),
# 'heating_peak_load_kW': building.heating_peak_load[cte.YEAR][0]/ (1e3),
# 'cooling_peak_load_kW': building.cooling_peak_load[cte.YEAR][0]/ (1e3),
# 'lighting_peak_load_kW': building.lighting_peak_load[cte.YEAR][0]/ (1e3),
# 'heating_demand_kWh_per_m2' : sum(building.heating_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
# 'cooling_demand_kWh_per_m2' : sum(building.cooling_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
# 'domestic_hot_water_heat_demand_kWh_per_m2': sum(building.domestic_hot_water_heat_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
# 'appliances_electrical_demand_kWh_per_m2':sum(building.appliances_electrical_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
# 'lighting_electrical_demand_kWh_per_m2': sum(building.lighting_electrical_demand[cte.HOUR])/ (3.6e6 * total_floor_area),
# 'heating_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.heating_demand[cte.HOUR]],
# 'cooling_demand_kWh':[x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.cooling_demand[cte.HOUR]],
# 'domestic_hot_water_heat_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.domestic_hot_water_heat_demand[cte.HOUR]],
# 'appliances_electrical_demand_kWh':[x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.appliances_electrical_demand[cte.HOUR]],
# 'lighting_electrical_demand_kWh': [x / (cte.WATTS_HOUR_TO_JULES * 1000) for x in building.lighting_electrical_demand[cte.HOUR]]
# }
# buildings_dic={}
for building in city.buildings:
total_floor_area = 0
for thermal_zone in building.thermal_zones_from_internal_zones:
total_floor_area += thermal_zone.total_floor_area
print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))
building.energy_systems_archetype_name = 'system 1 gas'
EnergySystemsFactory('montreal_custom', city).enrich()
print('test')
for building in city.buildings:
energy_systems = building.energy_systems
for energy_system in energy_systems:
generation_units = energy_system.generation_systems
if cte.HEATING in energy_system.demand_types:
for generation_unit in generation_units:
generation_unit.heat_efficiency = 0.96
# for building in city.buildings:
# print(building.heating_demand[cte.YEAR][0] / 3.6e6)
# print(building.name)
# total_floor_area = 0
# for thermal_zone in building.thermal_zones_from_internal_zones:
# total_floor_area += thermal_zone.total_floor_area
# print(building.heating_demand[cte.YEAR][0] / (3.6e6 * total_floor_area))

345
processor.py Normal file
View File

@ -0,0 +1,345 @@
import json
from pathlib import Path
import pandas as pd
import geopandas as gpd
#define output path
output_path = (Path(__file__).parent / 'out_files').resolve()
output_path.mkdir(parents=True, exist_ok=True)
# Define output folders
output_folders = ['building_type', 'building_type_2', 'building_type_3']
#output paths containing energy+ results are read
path1=r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\building_type\updated_buildings.geojson'
path2=r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\building_type_2\updated_buildings.geojson'
path3=r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\building_type_3\updated_buildings.geojson'
with open(path1, 'r') as f:
building_type_data = json.load(f)
with open(path2, 'r') as f:
building_type_data2 = json.load(f)
with open(path3, 'r') as f:
building_type_data3 = json.load(f)
percentage_data = {
1646: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2672.550473, "total_floor_area": 26725.50473},
1647: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2653.626087, "total_floor_area": 26536.26087},
1648: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1056.787496, "total_floor_area": 10567.87496},
1649: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1906.620746, "total_floor_area": 19066.20746},
1650: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 659.1119416, "total_floor_area": 5272.895533},
1651: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1167.208109, "total_floor_area": 9337.664871},
1652: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1193.251653, "total_floor_area": 9546.013222},
1653: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1491.722543, "total_floor_area": 11933.78035},
1654: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1168.005028, "total_floor_area": 9344.040224},
1655: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1264.906961, "total_floor_area": 10119.25569},
1656: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1281.768818, "total_floor_area": 10254.15054},
1657: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 290.3886018, "total_floor_area": 2323.108814},
1658: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 847.5095193, "total_floor_area": 6780.076155},
1659: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1115.319153, "total_floor_area": 8922.553224},
1660: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 469.2918062, "total_floor_area": 3754.33445},
1661: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1292.298346, "total_floor_area": 10338.38677},
1662: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 625.7828863, "total_floor_area": 5006.263091},
1663: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1876.02897, "total_floor_area": 15008.23176},
1664: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1118.224781, "total_floor_area": 22364.49562},
1665: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 1502.787808, "total_floor_area": 30055.75617},
1666: {"type1_%": 0.891045711, "type2_%": 0.108954289, "type3_%": 0, "roof_area": 3038.486076, "total_floor_area": 30384.86076},
1667: {"type1_%": 0.8, "type2_%": 0.2, "type3_%": 0, "roof_area": 1343.832818, "total_floor_area": 13438.32818},
1668: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 961.0996956, "total_floor_area": 4805.498478},
1669: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 489.1282111, "total_floor_area": 1956.512845},
1673: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1693.141465, "total_floor_area": 5079.424396},
1674: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 3248.827576, "total_floor_area": 9746.482729},
1675: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 4086.842191, "total_floor_area": 12260.52657},
1676: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 2786.114146, "total_floor_area": 11144.45658},
1677: {"type1_%": 1, "type2_%": 0, "type3_%": 0, "roof_area": 5142.784184, "total_floor_area": 15428.35255},
1678: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 6068.664574, "total_floor_area": 18205.99372},
1679: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 5646.751407, "total_floor_area": 16940.25422},
1680: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 1601.765953, "total_floor_area": 4805.297859},
1681: {"type1_%": 0.7, "type2_%": 0.3, "type3_%": 0, "roof_area": 9728.221797, "total_floor_area": 29184.66539},
1687: {"type1_%": 0.606611029, "type2_%": 0.28211422, "type3_%": 0.11127475, "roof_area": 4268.608743, "total_floor_area": 59760.52241},
1688: {"type1_%": 0.92, "type2_%": 0.08, "type3_%": 0, "roof_area": 2146.654828, "total_floor_area": 38639.7869},
1689: {"type1_%": 0.96, "type2_%": 0.04, "type3_%": 0, "roof_area": 2860.270711, "total_floor_area": 57205.41421},
1690: {"type1_%": 0.94, "type2_%": 0.06, "type3_%": 0, "roof_area": 2189.732519, "total_floor_area": 28466.52275},
1691: {"type1_%": 0.75, "type2_%": 0.25, "type3_%": 0, "roof_area": 3159.077523, "total_floor_area": 31590.77523},
}
# Define a function to calculate new demands based on percentages
def calculate_demands(building_id, percentages, building_type_data, building_type_data2, building_type_data3):
new_demands = {}
for idx, feature in enumerate(building_type_data['features']):
if feature['properties']['id'] == str(building_id):
for demand_type in [
'heating_demand_kWh', 'cooling_demand_kWh',
'domestic_hot_water_heat_demand_kWh',
'appliances_electrical_demand_kWh',
'lighting_electrical_demand_kWh']:
demand_list_1 = building_type_data['features'][idx]['properties'].get(demand_type, [0])
# Initialize demand lists for type 2 and type 3 with zeros
demand_list_2 = [0] * len(demand_list_1)
demand_list_3 = [0] * len(demand_list_1)
# Update demand_list_2 if percentages['type2_%'] is not zero
if percentages['type2_%'] != 0:
for feature2 in building_type_data2['features']:
if feature2['properties']['id'] == str(building_id):
demand_list_2 = feature2['properties'].get(demand_type, [0])
break
# Update demand_list_3 if percentages['type3_%'] is not zero
if percentages['type3_%'] != 0:
for feature3 in building_type_data3['features']:
if feature3['properties']['id'] == str(building_id):
demand_list_3 = feature3['properties'].get(demand_type, [0])
break
# Ensure the demand lists are the same length by padding with zeros if necessary
max_len = max(len(demand_list_1), len(demand_list_2), len(demand_list_3))
demand_list_1 += [0] * (max_len - len(demand_list_1))
demand_list_2 += [0] * (max_len - len(demand_list_2))
demand_list_3 += [0] * (max_len - len(demand_list_3))
new_demand_list = [
demand_list_1[i] * percentages['type1_%'] +
demand_list_2[i] * percentages['type2_%'] +
demand_list_3[i] * percentages['type3_%']
for i in range(max_len)
]
new_demands[demand_type] = new_demand_list
return new_demands
# Calculate demand per square meter for each building
def calculate_demand_per_m2(building_type_data, building_type_data2, building_type_data3, percentage_data):
results = {}
for building_id, percentages in percentage_data.items():
print(percentages ["total_floor_area"])
new_demands = calculate_demands(building_id, percentages, building_type_data, building_type_data2,
building_type_data3)
for idx, feature in enumerate(building_type_data['features']):
if feature['properties']['id'] == str(building_id):
total_floor_area = percentages ["total_floor_area"]
results[building_id] = {
'roof_area':percentages["roof_area"],
'total_floor_area': percentages["total_floor_area"],
'heating_demand_kWh':new_demands.get('heating_demand_kWh', []),
'cooling_demand_kWh':new_demands.get('cooling_demand_kWh', []),
'domestic_hot_water_heat_demand_kWh': new_demands.get('domestic_hot_water_heat_demand_kWh', []),
'appliances_electrical_demand_kWh': new_demands.get('appliances_electrical_demand_kWh', []),
'lighting_electrical_demand_kWh': new_demands.get('lighting_electrical_demand_kWh', []),
'heating_demand_kWh_per_m2': sum(new_demands.get('heating_demand_kWh', [])) / total_floor_area,
'cooling_demand_kWh_per_m2': sum(new_demands.get('cooling_demand_kWh', [])) / total_floor_area,
'domestic_hot_water_heat_demand_kWh_per_m2': sum(
new_demands.get('domestic_hot_water_heat_demand_kWh', [])) / total_floor_area,
'appliances_electrical_demand_kWh_per_m2': sum(
new_demands.get('appliances_electrical_demand_kWh', [])) / total_floor_area,
'lighting_electrical_demand_kWh_per_m2': sum(
new_demands.get('lighting_electrical_demand_kWh', [])) / total_floor_area,
'appliances_peak_load_kW': max(
new_demands.get('appliances_electrical_demand_kWh', [])),
'domestic_hot_water_peak_load_kW': max(
new_demands.get('domestic_hot_water_heat_demand_kWh', [])) ,
'heating_peak_load_kW': max(new_demands.get('heating_demand_kWh', [])),
'cooling_peak_load_kW': max(new_demands.get('cooling_demand_kWh', [])),
'lighting_peak_load_kW': max(
new_demands.get('lighting_electrical_demand_kWh', [])),
}
return results
# Example usage
new_demands = calculate_demand_per_m2(building_type_data, building_type_data2, building_type_data3, percentage_data)
# for building_id, demand_data in results.items():
# print(f"Building ID: {building_id}")
# for demand_type, value in demand_data.items():
# print(f" {demand_type}: {value}")
# new_demands = {}
# for building_id, percentages in percentage_data.items():
# print(building_id)
# new_demands[building_id] = calculate_demands(building_id, percentages, building_type_data, building_type_data2, building_type_data3)
# #
import pandas as pd
# Export the DataFrame to an Excel file
output_path = r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\new_demands.xlsx'
# Create an Excel writer object
with pd.ExcelWriter(output_path, engine='xlsxwriter') as writer:
for building_id, demands in new_demands.items():
# Convert demands to a DataFrame
df_demands = pd.DataFrame(demands)
# Convert building_id to string and check its length
sheet_name = str(building_id)
if len(sheet_name) > 31:
sheet_name = sheet_name[:31] # Truncate to 31 characters if necessary
# Write the DataFrame to a specific sheet named after the building_id
df_demands.to_excel(writer, sheet_name=sheet_name, index=False)
import matplotlib.pyplot as plt
import numpy as np
# Assume calculate_demand_per_m2 and results have been computed as before
def extract_demands(data, building_id, demand_type):
for feature in data['features']:
if feature['properties']['id'] == str(building_id):
return feature['properties'].get(demand_type, [0])
return 0
# Create a list of building IDs
building_ids = list(percentage_data.keys())
# Define the demand types to be plotted
demand_types = [
'heating_demand_kWh_per_m2',
'cooling_demand_kWh_per_m2',
'domestic_hot_water_heat_demand_kWh_per_m2',
'appliances_electrical_demand_kWh_per_m2',
'lighting_electrical_demand_kWh_per_m2'
]
# Initialize lists to store values for plotting
new_demands_values = {demand_type: [] for demand_type in demand_types}
building_type_data_values = {demand_type: [] for demand_type in demand_types}
building_type_data2_values = {demand_type: [] for demand_type in demand_types}
building_type_data3_values = {demand_type: [] for demand_type in demand_types}
# Populate the lists with the corresponding values
for building_id in building_ids:
for demand_type in demand_types:
new_demands_values[demand_type].append(new_demands[building_id][demand_type])
building_type_data_values[demand_type].append(extract_demands(building_type_data, building_id, demand_type))
building_type_data2_values[demand_type].append(extract_demands(building_type_data2, building_id, demand_type))
building_type_data3_values[demand_type].append(extract_demands(building_type_data3, building_id, demand_type))
# Plot the values for each demand type
for demand_type in demand_types:
x = np.arange(len(building_ids)) # the label locations
width = 0.2 # the width of the bars
fig, ax = plt.subplots(figsize=(15, 7))
ax.bar(x - 1.5 * width, new_demands_values[demand_type], width, label='New Demands')
ax.bar(x - 0.5 * width, building_type_data_values[demand_type], width, label='Old Demands - Type 1')
ax.bar(x + 0.5 * width, building_type_data2_values[demand_type], width, label='Old Demands - Type 2')
ax.bar(x + 1.5 * width, building_type_data3_values[demand_type], width, label='Old Demands - Type 3')
# Add some text for labels, title, and custom x-axis tick labels, etc.
ax.set_xlabel('Building ID')
ax.set_ylabel(f'{demand_type} (kWh/m²)')
ax.set_title(f'Comparison of {demand_type} by Building ID')
ax.set_xticks(x)
ax.set_xticklabels(building_ids, rotation=90)
ax.legend()
fig.tight_layout()
plt.show()
# Load the existing GeoJSON file
geojson_file_path =r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\building_type\updated_buildings.geojson' # Replace with the actual path
with open(geojson_file_path, 'r') as f:
geojson_data = json.load(f)
# Define output path
output_path = (Path(__file__).parent / 'out_files').resolve()
output_path.mkdir(parents=True, exist_ok=True)
# Load additional data from the CSV files
solar_radiation_tilted_path = r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\solar_radiation_tilted_selected_buildings.csv'
solar_radiation_horizontal_path = r'C:\Users\a_gabald\PycharmProjects\summer_course_2024\out_files\solar_radiation_horizontal_selected_buildings.csv'
import csv
def load_solar_data(file_path, key_name):
solar_data = {}
with open(file_path, 'r') as f:
reader = csv.reader(f)
headers = next(reader)[1:] # Skip the first header and get building IDs
for row in reader:
for building_id, solar_value in zip(headers, row[1:]): # Skip the first column in each row
building_id = int(building_id)
solar_value = float(solar_value)
if building_id not in solar_data:
solar_data[building_id] = {}
if key_name not in solar_data[building_id]:
solar_data[building_id][key_name] = []
solar_data[building_id][key_name].append(solar_value)
return solar_data
solar_radiation_tilted = load_solar_data(solar_radiation_tilted_path, 'solar_radiation_tilted')
solar_radiation_horizontal = load_solar_data(solar_radiation_horizontal_path, 'solar_radiation_horizontal')
# Merge the solar data into a single dictionary
solar_data = {}
for building_id in set(solar_radiation_tilted.keys()).union(solar_radiation_horizontal.keys()):
solar_data[building_id] = {}
if building_id in solar_radiation_tilted:
solar_data[building_id]['solar_radiation_tilted'] = solar_radiation_tilted[building_id][
'solar_radiation_tilted']
if building_id in solar_radiation_horizontal:
solar_data[building_id]['solar_radiation_horizontal'] = solar_radiation_horizontal[building_id][
'solar_radiation_horizontal']
# Example data for results (use actual results data in practice)
results = {
1646: {
"appliances_peak_load_kW": 269.020198862769,
"domestic_hot_water_peak_load_kW": 1477.6420222203596,
"heating_peak_load_kW": 1650.4097261870008,
"cooling_peak_load_kW": 1441.1027982978985,
"lighting_peak_load_kW": 295.92221874904584,
"heating_demand_kWh_per_m2": 40.4922413088911,
"cooling_demand_kWh_per_m2": 20.33948801154316,
"domestic_hot_water_heat_demand_kWh_per_m2": 60.25215210051923,
"appliances_electrical_demand_kWh_per_m2": 19.352038723954898,
"lighting_electrical_demand_kWh_per_m2": 11.246090428260413,
}
# Add similar dictionaries for other building IDs
}
# Update GeoJSON with percentage data, results, and solar data
for feature in geojson_data['features']:
building_id = int(feature['properties']['id'])
# Update with percentage data
if building_id in percentage_data:
for key, value in percentage_data[building_id].items():
feature['properties'][key] = value
# Update with results data
if building_id in new_demands:
for key, value in new_demands[building_id].items():
feature['properties'][key] = value
# Update with solar data
if building_id in solar_data:
for key, value in solar_data[building_id].items():
feature['properties'][key] = value
# Calculate and add the sums
feature['properties']['sum_solar_radiation_tilted_kWh_per_m2'] = sum(solar_data[building_id]['solar_radiation_tilted']) / 3.6e6
feature['properties']['sum_solar_radiation_horizontal_kWh_per_m2'] = sum(solar_data[building_id]['solar_radiation_horizontal']) / 3.6e6
# Add 8760 arrays divided by 3.6e6
feature['properties']['solar_radiation_tilted_kWh_per_m2'] = [value / 3.6e6 for value in solar_data[building_id]['solar_radiation_tilted']]
feature['properties']['solar_radiation_horizontal_kWh_per_m2'] = [value / 3.6e6 for value in solar_data[building_id]['solar_radiation_horizontal']]
# Save the updated GeoJSON data to a new file
updated_geojson_file_path = output_path / 'updated_buildings_with_all_data.geojson'
with open(updated_geojson_file_path, 'w') as f:
json.dump(geojson_data, f)
print(f"Updated GeoJSON data saved to {updated_geojson_file_path}")

113
updated_buildings.geojson Normal file
View File

@ -0,0 +1,113 @@
{
"project": {
"country": "-",
"city": "Montreal, QC",
"latitude": 45.5019,
"cad_coordinates": [
0.0,
0.0
],
"longitude": -73.5674,
"time_zone": -5.0,
"elevation": 40.0
},
"type": "FeatureCollection",
"mappers": [],
"features": [
{
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-73.56460598928051,
45.49740281507067
],
[
-73.56460599751905,
45.497401799005075
],
[
-73.56517531829724,
45.49740281063829
],
[
-73.5651753100587,
45.49734347035089
],
[
-73.56517457279315,
45.49734347035089
],
[
-73.56517457279315,
45.497253770511335
],
[
-73.5651753100587,
45.497253770511335
],
[
-73.56537248633211,
45.497253758929254
],
[
-73.56537191925358,
45.497208766225164
],
[
-73.56537192028448,
45.497015574816565
],
[
-73.56455529412895,
45.49701527683656
],
[
-73.56455529412895,
45.49725375536205
],
[
-73.56460598928051,
45.497253770511335
],
[
-73.56460598928051,
45.49740281507067
]
]
]
},
"type": "Feature",
"id": "1691",
"properties": {
"footprint_area": 2416.2204562020706,
"floor_height": 3.9999999999999996,
"year_built": 2024,
"detailed_model_filename": "C:\\Users\\umroot\\Downloads\\Group 3\\hb_json\\Building_1691_e4a64903.json",
"type": "Building",
"building_type": "1000",
"number_of_stories": 8,
"name": "Building_1691",
"number_of_stories_above_ground": 8,
"floor_area": 19329.763649616565,
"maximum_roof_height": 31.999999999999996,
"year_of_construction": 2024,
"type_function": "residential",
"heating_demand": [
4528783398296.355
],
"cooling_demand": [
2074220778983.8276
],
"domestic_hot_water_heat_demand": [
6848139964182.653
],
"appliances_electrical_demand": [
2199514382726.829
],
"lighting_electrical_demand": [
1278208358263.9053
],
"walls": [