def initialize_model(tsid, target_date): """make instances of model classes""" start_time = time.time() tdate = target_date.strftime('%Y-%m-%d') # with futures.ThreadPoolExecutor(8) as executor: # res = [executor.submit(fn, tsid, tdate=tdate) for fn in [make_sections, # make_dgu_groups, # make_bids, # make_stations, # make_areas, # make_impex_areas, # make_nodes, # make_loads, # make_consumers, # make_dpgs, # make_dgus, # make_wsumgen, # make_gus, # make_lines, # make_price_zones, # make_settings]] # # list(res) make_sections(tsid, tdate=tdate) make_dgu_groups(tsid, tdate=tdate) make_bids(tsid, tdate=tdate) make_stations(tsid, tdate=tdate) make_areas(tsid, tdate=tdate) make_impex_areas(tsid, tdate=tdate) make_nodes(tsid, tdate=tdate) make_loads(tsid, tdate=tdate) make_consumers(tsid, tdate=tdate) make_dpgs(tsid, tdate=tdate) make_dgus(tsid, tdate=tdate) make_wsumgen(tsid, tdate=tdate) make_gus(tsid, tdate=tdate) make_lines(tsid, tdate=tdate) make_price_zones(tsid, tdate=tdate) make_settings(tsid, tdate=tdate) make_peak_so(tsid, target_date, tdate=tdate) print(time.time() - start_time)
from eq_db.classes.bids import make_bids from eq_db.vertica_corrections import add_bids_vertica tsid = 220482901 scenario = 1 tdate = '31-07-2015' bids = make_bids(tsid, tdate) bids = add_bids_vertica(bids, scenario, tdate)
from eq_db.classes.bids import make_bids bids = make_bids(220924901, '13.03.2016') bid = bids[232095] print(bid.dpg_code) for hour in bid.hour_data.keys(): [ print(bid.hour_data[hour]['hour'], b) for b in bid.hour_data[hour]['intervals'] ] # import re # # query = ''' # select hour, o$num rge_code, o$pmin pmin, o$pmax pmax, o$pminagg pmin_tech, # o$p p, o$wmax wmax, o$wmin wmin, o$vgain vgain, o$vdrop vdrop, rge.parent_object_id dpg_id # from tsdb2.wh_rastr_generator partition (&tsid) rg, tsdb2.wh_trader partition (&tsid) rge # where rge.trader_type = 103 # and rge.trader_code = rg.o$num''' # # # query = '''select trader_code dpg_code, to_number(consumer2), is_system, is_guarantee_supply_co, trader_id dpg_id, # fed_station is_fed_station, is_disqualified, is_unpriced_zone, is_fsk, es_ref area # from tsdb2.wh_trader partition (&tsid) gtp # where dpg_type = 1 # and is_impex = 0 # --and trader_code = 'PSAYANAL' # ''' # # for match in re.finditer('(wh_(\w*)\s*partition\s*\(&tsid\))', query): # print(query.replace(match.group(0), match.group(1)))