fixed bug not printing results when building not processed

This commit is contained in:
Pilar Monsalvete 2023-03-24 11:47:09 -04:00
parent effdad4437
commit 17fcc5d41f
3 changed files with 29 additions and 203 deletions

View File

@ -1,185 +0,0 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 5755,
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-73.56190787594767,
45.61726266364104
],
[
-73.56159977630858,
45.61712866375689
],
[
-73.56162477566284,
45.617100363890756
],
[
-73.56158587638703,
45.61708356365557
],
[
-73.56166777584713,
45.616990464038736
],
[
-73.56167107635906,
45.6169866644031
],
[
-73.56164947644214,
45.61697766398805
],
[
-73.56169957587468,
45.61691836359165
],
[
-73.56170267583781,
45.61691466378079
],
[
-73.56133437558094,
45.61675966382745
],
[
-73.5613311757931,
45.61676336363837
],
[
-73.56127957629138,
45.61682316405785
],
[
-73.56116397563693,
45.616774063772084
],
[
-73.56115897630565,
45.61677186403034
],
[
-73.56002217568283,
45.618082264385066
],
[
-73.5600191764438,
45.618085763647116
],
[
-73.56081077589653,
45.618423463572014
],
[
-73.56081287581355,
45.618421064180836
],
[
-73.56095257560082,
45.61826276371562
],
[
-73.5609934758682,
45.618216364093996
],
[
-73.56114967641639,
45.618284263807766
],
[
-73.56141957555292,
45.617978363910424
],
[
-73.56131567597765,
45.61793316398439
],
[
-73.56190787594767,
45.61726266364104
]
]
]
},
"properties": {
"OBJECTID_12_13": 5755,
"ID_UEV": "02039261",
"CIVIQUE_DE": " 8501",
"CIVIQUE_FI": " 8501",
"NOM_RUE": "boulevard Ray-Lawson (ANJ)",
"SUITE_DEBU": " ",
"MUNICIPALI": "50",
"ETAGE_HORS": 0,
"NOMBRE_LOG": 0,
"ANNEE_CONS": 1980,
"CODE_UTILI": "3019",
"LETTRE_DEB": " ",
"LETTRE_FIN": " ",
"LIBELLE_UT": "Autres activit\u00c3\u00a9s d'impression commerciale",
"CATEGORIE_": "R\u00c3\u00a9gulier",
"MATRICULE8": "0053-00-3380-2-000-0000",
"SUPERFICIE": 23420,
"SUPERFIC_1": 11317,
"NO_ARROND_": "REM09",
"Shape_Leng": 0.00572785554549,
"OBJECTID": 5755,
"Join_Count": 1,
"TARGET_FID": 5755,
"feature_id": "dd2be07a-6632-4e83-b2a4-d4b6d99ed706",
"md_id": " ",
"acqtech": 1360,
"acqtech_en": "Lidar",
"acqtech_fr": "Lidar",
"provider": 461,
"provideren": "Municipal",
"providerfr": "Municipal",
"datemin": "20151124",
"datemax": "20151208",
"haccmin": 2,
"haccmax": 2,
"vaccmin": 1,
"vaccmax": 1,
"heightmin": 0,
"heightmax": 49.8,
"elevmin": 40.63,
"elevmax": 42.29,
"bldgarea": 13314.83,
"comment": " ",
"OBJECTID_1": 5755,
"Shape_Le_1": 0.00572785554549,
"Shape_Ar_1": 1.53632150501e-06,
"OBJECTID_12": 5755,
"Join_Count_1": 1,
"TARGET_FID_1": 5754,
"g_objectid": "893223",
"g_co_mrc": "66023",
"g_code_mun": "66023",
"g_arrond": "REM09",
"g_anrole": "2019",
"g_usag_pre": "Industrie l\u00c3\u00a9g\u00c3\u00a8re",
"g_no_lot": "1005810",
"g_nb_poly_": "1",
"g_utilisat": "3019",
"g_nb_logem": " ",
"g_nb_locau": "1",
"g_descript": "Unit\u00c3\u00a9 d'\u00c3\u00a9valuation",
"g_id_provi": "66023005300338020000000",
"g_sup_tota": "23419.6",
"g_geometry": "0.00700953",
"g_geomet_1": "2.70165e-006",
"g_dat_acqu": "2020-02-12 00:00:00.0000000",
"g_dat_char": "2020-02-17 00:00:00.0000000",
"Shape_Leng_1": 0.00572785554549,
"Shape_Area_1": 1.53632150501e-06,
"Shape_Length": 0.005727851497694299,
"Shape_Area": 1.53632150501e-06
}
}
]
}

View File

@ -11,7 +11,7 @@ from sra_engine import SraEngine
try: try:
file_path = (Path(__file__).parent / 'input_files' / 'neighbours.geojson') file_path = (Path(__file__).parent / 'input_files' / 'selected_building.geojson')
climate_reference_city = 'Montreal' climate_reference_city = 'Montreal'
weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw' weather_file = 'CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw'
weather_format = 'epw' weather_format = 'epw'
@ -26,7 +26,7 @@ try:
print('[simulation start]') print('[simulation start]')
city = GeometryFactory('geojson', city = GeometryFactory('geojson',
path=file_path, path=file_path,
height_field='citygml_me', height_field='building_height',
year_of_construction_field='ANNEE_CONS', year_of_construction_field='ANNEE_CONS',
function_field='CODE_UTILI', function_field='CODE_UTILI',
function_to_hub=Dictionaries().montreal_function_to_hub_function).city function_to_hub=Dictionaries().montreal_function_to_hub_function).city

View File

@ -12,14 +12,22 @@ class Results:
print_results = None print_results = None
file = 'city name: ' + self._city.name + '\n' file = 'city name: ' + self._city.name + '\n'
for building in self._city.buildings: for building in self._city.buildings:
heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'}) if cte.MONTH in building.heating.keys():
cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'}) heating_results = building.heating[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} heating Wh'})
lighting_results = building.lighting_electrical_demand[cte.MONTH]\ cooling_results = building.cooling[cte.MONTH].rename(columns={cte.INSEL_MEB: f'{building.name} cooling Wh'})
.rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'}) lighting_results = building.lighting_electrical_demand[cte.MONTH]\
appliances_results = building.appliances_electrical_demand[cte.MONTH]\ .rename(columns={cte.INSEL_MEB: f'{building.name} lighting electrical demand Wh'})
.rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'}) appliances_results = building.appliances_electrical_demand[cte.MONTH]\
dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\ .rename(columns={cte.INSEL_MEB: f'{building.name} appliances electrical demand Wh'})
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'}) dhw_results = building.domestic_hot_water_heat_demand[cte.MONTH]\
.rename(columns={cte.INSEL_MEB: f'{building.name} domestic hot water demand Wh'})
else:
array = [None] * 12
heating_results = pd.DataFrame(array, columns=[f'{building.name} heating Wh'])
cooling_results = pd.DataFrame(array, columns=[f'{building.name} cooling Wh'])
lighting_results = pd.DataFrame(array, columns=[f'{building.name} lighting electrical demand Wh'])
appliances_results = pd.DataFrame(array, columns=[f'{building.name} appliances electrical demand Wh'])
dhw_results = pd.DataFrame(array, columns=[f'{building.name} domestic hot water demand Wh'])
if print_results is None: if print_results is None:
print_results = heating_results print_results = heating_results
else: else:
@ -30,16 +38,19 @@ class Results:
appliances_results, appliances_results,
dhw_results], axis='columns') dhw_results], axis='columns')
file += '\n' file += '\n'
file += 'name: ' + building.name + '\n' file += f'name: {building.name}\n'
file += 'year of construction: ' + str(building.year_of_construction) + '\n' file += f'year of construction: {building.year_of_construction}\n'
file += 'function: ' + building.function + '\n' file += f'function: {building.function}\n'
file += 'floor area: ' + str(building.floor_area) + '\n' file += f'floor area: {building.floor_area}\n'
file += 'storeys: ' + str(int(building.eave_height / building.average_storey_height)) + '\n' if building.average_storey_height is not None and building.eave_height is not None:
file += 'heated_volume: ' + str(0.85 * building.volume) + '\n' file += f'storeys: {int(building.eave_height / building.average_storey_height)}\n'
file += 'volume: ' + str(building.volume) + '\n' else:
file += f'storeys: n/a\n'
file += f'heated_volume: {0.85 * building.volume}\n'
file += f'volume: {building.volume}\n'
full_path_results = Path(self._path / 'demand.csv').resolve() full_path_results = Path(self._path / 'demand.csv').resolve()
print_results.to_csv(full_path_results) print_results.to_csv(full_path_results, na_rep='null')
full_path_metadata = Path(self._path / 'metadata.csv').resolve() full_path_metadata = Path(self._path / 'metadata.csv').resolve()
with open(full_path_metadata, 'w') as metadata_file: with open(full_path_metadata, 'w') as metadata_file:
metadata_file.write(file) metadata_file.write(file)