From 9992f3681c69ff2658584e99bd9f0de8204ecc2b Mon Sep 17 00:00:00 2001 From: Koa Wells Date: Fri, 21 Apr 2023 14:59:04 -0400 Subject: [PATCH] Add debug mode and update folder structure --- energy_validation.py | 49 ++++++++++++++++++++++++------------------ results/.gitignore | 5 +++++ results/ep/.gitignore | 2 ++ results/meb/.gitignore | 2 ++ 4 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 results/.gitignore create mode 100644 results/ep/.gitignore create mode 100644 results/meb/.gitignore diff --git a/energy_validation.py b/energy_validation.py index a6b173d..b4a26ad 100644 --- a/energy_validation.py +++ b/energy_validation.py @@ -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)] \ No newline at end of file diff --git a/results/.gitignore b/results/.gitignore new file mode 100644 index 0000000..d056343 --- /dev/null +++ b/results/.gitignore @@ -0,0 +1,5 @@ +/* +/*/ +!.gitignore +!/meb/ +!/ep/ \ No newline at end of file diff --git a/results/ep/.gitignore b/results/ep/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/results/ep/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/results/meb/.gitignore b/results/meb/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/results/meb/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file