hello!
Currently doing some things externally from Rh/Gh:
From the results of an annual simulation, I’m basically wanting to create analysis periods to use to via apply analysis period methodology on the annual data.
Below I have some “it works but I’m sure there is a more elegant way”, as atleast in jupyter its taking ~ 1.5 seconds to return… and I’m wanting to apply this to about 1,500 results at a time as quickly as possible
I don’t frequently write stuff that uses SQL sooo this may be kinda ugly:
def get_peak_days(sql) -> tuple:
conn = sqlite3.connect(str(sql))
cur = conn.cursor()
for i, row in enumerate(cur.execute('SELECT * FROM ZoneSizes;')):
if row[2] == 'Cooling':
cx = row
if row[2] == 'Heating':
hx = row
cx_month = cx[8].split(' ')[0].split('/')[0]
cx_day = cx[8].split(' ')[0].split('/')[1]
hx_month = hx[8].split(' ')[0].split('/')[0]
hx_day = hx[8].split(' ')[0].split('/')[1]
cx_per = ap.AnalysisPeriod(st_month=cx_month,
st_day=cx_day, end_month=cx_month, end_day=cx_day)
hx_per = ap.AnalysisPeriod(st_month=hx_month,
st_day=hx_day, end_month=hx_month, end_day=hx_day)
return (cx_per, hx_per)
rsl = 'assets/eplusout.sql'
stuff = get_peak_days(rsl)
print(stuff)
>> (7/21 to 7/21 between 0 and 23 @1, 1/21 to 1/21 between 0 and 23 @1)