Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hollywas/4757770 to your computer and use it in GitHub Desktop.
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.
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()
@JohnAh
Copy link

JohnAh commented Apr 20, 2014

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

                     TASK     MISC    SPACE    SPACE     HEAT    PUMPS     VENT    REFRIG  HT PUMP   DOMEST    EXT
           LIGHTS   LIGHTS   EQUIP   HEATING  COOLING   REJECT   & AUX     FANS   DISPLAY  SUPPLEM  HOT WTR   USAGE    TOTAL
          -------  -------  -------  -------  -------  -------  -------  -------  -------  -------  -------  -------  --------

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
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ========

MBTU        308.8      0.0    157.9      0.0    481.5      0.0      0.0     76.4      0.0      0.0     22.3      0.0    1046.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment