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