时间序列模型 加速演算时间
将一天的数据量加速跑完, 取历史数据, 不要等待.......
def start():
now_temp = datetime.now()
t = datetime(year=now_temp.year, month=now_temp.month, day=now_temp.day, hour=now_temp.hour,
minute=now_temp.minute)
# 测试t0 时刻 预测值
t0 = datetime(t.year, t.month, t.day, config.t0_hour, config.t0_minute) - relativedelta(days=1) # 调整到的时间节点
t1 = datetime(t0.year, t0.month, t0.day, config.t1_hour, config.t1_minute)
t2 = t0 + relativedelta(days=1) - relativedelta(minutes=1)
# t2 = t0 + relativedelta(minutes=3)
print('时间: ', t0, t1, t2)
# Q_inflow_forecast = 6000.
# up_load_flow(t0, t2, tz_now, Q_inflow_forecast)
print('时间: ', t0, t1, t2)
time_lst = []
# 定截止时间
t_end = t0 + relativedelta(days=1) - relativedelta(minutes=1) # 跑到晚上24点
t_key = int((t_end - t0).seconds/60) + 1
print('执行时间查看', time_lst)
t = t0 # 实时时间调整为 t
for i in range(t_key):
time_lst.append(t)
t += relativedelta(minutes=1)
print('=========================================================================== 实时执行时间:', t0, t1, t2, t)
# 热启动
if number == 0:
Q_inflow_forecast = hotstart(config, t0, t, t1, t2, tz_now)
target_time = t
number = 1
# 上传实时SCADA数据
up_load_data(client, t0, t, tz_now)
# 预测t0点的流速
if t.hour == t0.hour and t.minute == t0.minute:
raw_water_flow_volume_t0(config, t0, t1, tz_now)
elif t.hour == t1.hour and t.minute == t1.minute:
raw_water_flow_volume_t1(config, t0, t1, t2, tz_now)
print('实时期望流速: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++', Q_inflow_forecast)
# 在t0到t1之间的调流触发
if t.hour < t1.hour or (t.hour == t1.hour and t.minute < t1.minute):
print('在t0到t1之间的调流触发')
water_volume_t0_t1, Q_inflow_t0_t1 = raw_water_volume_t0_t2(target_time, t, t1, tz_now,Q_inflow_forecast,t0)
up_load_flow(t, t1, tz_now, Q_inflow_forecast)
if abs(water_volume_t0_t1) > config.Q1:
Q_inflow_forecast = Q_inflow_t0_t1
target_time = t
# up_load_flow(t, t1, tz_now, Q_inflow_forecast)
# 当在t1和t2之间触发调流时
elif t.hour > t1.hour or (t.hour == t1.hour and t.minute >= t1.minute):
print('在t1到t2之间的调流触发')
water_volume_t0_t1, Q_inflow_t0_t1 = raw_water_volume_t0_t2(target_time, t, t2, tz_now, Q_inflow_forecast,t0)
up_load_flow(t, t2, tz_now, Q_inflow_forecast)
if abs(water_volume_t0_t1) > config.Q1:
Q_inflow_forecast = Q_inflow_t0_t1
target_time = t
传入连续pandas数据
idx = pd.period_range(start=t, end=target_time,
freq=str(interval) + "min").to_timestamp().tz_localize(tz_now)
rawwater_forecast_series = pd.Series(inflow_discharge, index=idx[1:])