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 == 'Cooling': cx = row if row == 'Heating': hx = row cx_month = cx.split(' ').split('/') cx_day = cx.split(' ').split('/') hx_month = hx.split(' ').split('/') hx_day = hx.split(' ').split('/') 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)