Created
February 11, 2013 21:25
-
-
Save hollywas/4757770 to your computer and use it in GitHub Desktop.
This Python script will extract the heating, cooling and totals from the BEPS tables of a .sim file. This script was tested on DOE 2.1e .sim files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glob | |
import re | |
import csv | |
''' | |
This script will extract the heating, cooling | |
and totals from the BEPS tables of a .sim file. | |
This script was tested on DOE 2.1e .sim files. | |
To run, please ensure that you have the files in a folder called: | |
design_phase | |
And this script is located in the same folder as the design_phase folder | |
but not in that folder itself! | |
It will iterate over all .sim files in the design_phase folder | |
Upon completion, it will add the files: | |
* BEPS.csv | |
These is a comma-separated variable files with the delimiter ',' | |
Please run this using Python 2.7, which can be obtained here: | |
http://www.python.org/download/releases/2.7/ | |
This script was inspired by code by Alex Storer, which can be found here: | |
https://gist.github.com/alexstorer/4228694 | |
This script is released without any support! Good luck! | |
Holly Samuelson, Alex Storer | |
December 2012 | |
Harvard University | |
''' | |
allfiles = glob.glob('design_phase/*.sim') | |
# Holly's script to write out heating, cooling, and totals from BEPS Tables. | |
# It first checks to see that we're in the BEPS Table, because the names | |
# "TOTAL" etc show up in the .sim file before the BEPS table. They | |
# do NOT show up again afterward, so I do not need to check that we've left | |
# the BEPS Table. | |
print "Extracting BEPS Data..." | |
fw = open('beps.csv','w') | |
dw = csv.DictWriter(fw,["filename","category","electricity","gas"]) | |
dw.writeheader() | |
for fname in allfiles: | |
f = open(fname) | |
print "BEPS>",fname | |
d = dict() | |
inBEPS = False | |
for line in f: | |
res = re.search('REPORT- BEPS',line) | |
if res is not None: | |
inBEPS = True | |
for line in f: | |
res = re.search('\SPACE HEAT\ \s* (\d+\.\d) (\s* (\d+\.\d))?',line) | |
if res is not None: | |
d["category"] = "heat (MBTU)" | |
d["electricity"] = res.group(1) | |
d["gas"] = res.group(3) | |
d["filename"] = fname | |
dw.writerow(d) | |
res = re.search('\SPACE COOL\ \s* (\d+\.\d) (\s* (\d+\.\d))?',line) | |
if res is not None: | |
d["category"] = "cool (MBTU)" | |
d["electricity"] = res.group(1) | |
d["gas"] = res.group(3) | |
d["filename"] = fname | |
dw.writerow(d) | |
res = re.search('\TOTAL\ \s* (\d+\.\d) (\s* (\d+\.\d))?',line) | |
if res is not None: | |
d["category"] = "total (MBTU)" | |
d["electricity"] = res.group(1) | |
d["gas"] = res.group(3) | |
d["filename"] = fname | |
dw.writerow(d) | |
f.close() | |
fw.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not able use this code with eQUEST SIM file. Could you share SIM file on which you have tested it.
eQUEST format is as below:
REPORT- BEPS Building Energy Performance WEATHER FILE- EPW
EM1 ELECTRICITY
MBTU 308.8 0.0 157.9 0.0 481.5 0.0 0.0 76.4 0.0 0.0 0.0 0.0 1024.6
FM1 NATURAL-GAS
MBTU 0.0 0.0 0.0 0.0 43544.0 0.0 0.0 0.0 0.0 0.0 22.3 0.0 22.3
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ========