Add debug mode and update folder structure

This commit is contained in:
Koa Wells 2023-04-21 14:59:04 -04:00
parent 3f1bab01c8
commit 9992f3681c
4 changed files with 37 additions and 21 deletions

View File

@ -6,6 +6,7 @@ import pandas as pd
import platform import platform
import os import os
import xlsxwriter import xlsxwriter
from subprocess import SubprocessError, TimeoutExpired, CalledProcessError
from hub.imports.geometry_factory import GeometryFactory from hub.imports.geometry_factory import GeometryFactory
from hub.imports.weather_factory import WeatherFactory from hub.imports.weather_factory import WeatherFactory
@ -21,7 +22,9 @@ from meb import Meb
from meb_results import Results as MEBResults from meb_results import Results as MEBResults
class EnergyValidation: class EnergyValidation:
def __init__(self): def __init__(self, debug=False):
self.debug = debug
self.weather_file = Path('./data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve() self.weather_file = Path('./data/CAN_PQ_Montreal.Intl.AP.716270_CWEC.epw').resolve()
self.climate_file_name = 'Montreal' self.climate_file_name = 'Montreal'
self.tmp_folder = Path('./tmp').resolve() self.tmp_folder = Path('./tmp').resolve()
@ -297,27 +300,31 @@ class EnergyValidation:
print(f"{building_id} meb time: {meb_end}") print(f"{building_id} meb time: {meb_end}")
print(f"{building_id} ep time: {ep_end}") print(f"{building_id} ep time: {ep_end}")
except: except (SubprocessError, TimeoutExpired, CalledProcessError) as error:
building_with_error = pd.DataFrame([ if self.debug is True:
building_id, raise Exception(error)
'NA', else:
'NA', print(building_id, " failed SRA, MEB, or EP")
'NA', building_with_error = pd.DataFrame([
'NA', building_id,
'NA', 'NA',
'NA', 'NA',
'NA', 'NA',
]).transpose() 'NA',
'NA',
'NA',
'NA',
]).transpose()
with pd.ExcelWriter(self.result_file, engine='openpyxl', if_sheet_exists='overlay', with pd.ExcelWriter(self.result_file, engine='openpyxl', if_sheet_exists='overlay',
mode='a') as writer: mode='a') as writer:
building_with_error.to_excel( building_with_error.to_excel(
writer, writer,
startrow=writer.sheets['Simulation data'].max_row, startrow=writer.sheets['Simulation data'].max_row,
sheet_name='Simulation data', sheet_name='Simulation data',
index=False, index=False,
header=False, header=False,
) )
if cleanup is True: if cleanup is True:
[os.remove(os.path.join(self.tmp_folder, file)) for file in os.listdir(self.tmp_folder)] [os.remove(os.path.join(self.tmp_folder, file)) for file in os.listdir(self.tmp_folder)]

5
results/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/*
/*/
!.gitignore
!/meb/
!/ep/

2
results/ep/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore

2
results/meb/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*
!.gitignore