|
|
@@ -34,7 +34,7 @@ def predict(*inputs,config=None):
|
|
|
|
|
|
NOW = config_reader.get_app_info(each_eaup_name,'露点预测',key='开始时间',info_type='datetime')
|
|
|
|
|
|
- use_DHU_model = config_reader.get_app_info(each_eaup_name,'露点预测',key='基于除湿机模型',info_type='bool')
|
|
|
+ use_DHU_model = config_reader.get_app_info(each_eaup_name,'露点预测',key='模型方法',info_type='str')=='除湿机模型'
|
|
|
|
|
|
dhu_State = load_dhu_State(
|
|
|
each_eaup_name = each_eaup_name,
|
|
|
@@ -72,27 +72,29 @@ def predict(*inputs,config=None):
|
|
|
else:
|
|
|
raise NotImplementedError
|
|
|
else:
|
|
|
- print('基于实测送风露点进行预测')
|
|
|
- point_B = config_reader.get_equp_point(each_eaup_name,equp_class=['B'])
|
|
|
- point = config_reader.get_equp_point(each_eaup_name,equp_class=['C'])
|
|
|
+ print('基于再生加热温度进行预测')
|
|
|
+ room_model_name = 'TinR'
|
|
|
+ point_A = config_reader.get_equp_point(each_eaup_name,equp_class=['A'])
|
|
|
+ point = config_reader.get_equp_point(each_eaup_name,equp_class=['C'])
|
|
|
if each_equp_type in ['DHU_A','DHU_B']:
|
|
|
- Dout_name = 'wheel_2_DoutP'
|
|
|
- point[Dout_name] = point_B[Dout_name]
|
|
|
+ TinR_name = ['wheel_1_TinR','wheel_2_TinR']
|
|
|
+ point['wheel_1_TinR'] = point_A['wheel_1_TinR']
|
|
|
+ point['wheel_2_TinR'] = point_A['wheel_2_TinR']
|
|
|
elif each_equp_type in ['SDHU_A','SDHU_B']:
|
|
|
- Dout_name = 'coil_2_DoutA'
|
|
|
- point[Dout_name] = point_B[Dout_name]
|
|
|
+ TinR_name = ['wheel_1_TinR']
|
|
|
+ point['wheel_1_TinR'] = point_A['wheel_1_TinR']
|
|
|
else:
|
|
|
raise NotImplementedError
|
|
|
equp_data = (
|
|
|
DataLoader(
|
|
|
path = f'{config_reader_path}/data/room_predict/data_cur/',
|
|
|
- start_time = NOW - timedelta(minutes=120),
|
|
|
+ start_time = NOW - timedelta(minutes=60),
|
|
|
end_time = NOW,
|
|
|
print_process = False
|
|
|
)
|
|
|
.download_equp_data(
|
|
|
equp_name = each_eaup_name,
|
|
|
- point = config_reader.get_equp_point(each_eaup_name,equp_class=['B','C']),
|
|
|
+ point = point,
|
|
|
url = data_URL,
|
|
|
clean_cache = True
|
|
|
)
|
|
|
@@ -100,51 +102,56 @@ def predict(*inputs,config=None):
|
|
|
equp_name = each_eaup_name,
|
|
|
)
|
|
|
)
|
|
|
- Dout = equp_data.loc[:,Dout_name].values
|
|
|
+ equp_data_sm = equp_data.rolling(10,min_periods=0).mean()
|
|
|
+ wheel_TinR = equp_data_sm.loc[:,TinR_name].mean(axis=1).values
|
|
|
room_SP_point = config_reader.get_equp_point(equp_name = each_eaup_name,equp_class = ['C','D'])
|
|
|
|
|
|
for each_room_num in range(1,config_reader.get_equp_info(each_eaup_name,'房间数量','int') + 1):
|
|
|
- Droom_cur = equp_data.loc[:,f'room_{each_room_num}_Dpv'].values[-1]
|
|
|
- if use_DHU_model:
|
|
|
- room_model = RoomDewPredictor.load(f'{config_reader_path}/model/{each_eaup_name}_room_{each_room_num}_Dpv.pkl')
|
|
|
- Droom_pred = room_model.predict_Droom(Dout=Dout_pred,Droom_cur=Droom_cur)
|
|
|
- else:
|
|
|
- room_model = RoomDewPredictor.load(f'{config_reader_path}/model/{each_eaup_name}_room_{each_room_num}_Dpv_bk.pkl')
|
|
|
- Droom_pred = room_model.predict_Droom(Dout=Dout,Droom_cur=Droom_cur)
|
|
|
- pred_lag = room_model.model_info['model_Droom']['lag']
|
|
|
-
|
|
|
- print(f'{each_eaup_name}房间{each_room_num}在{NOW}的预测值')
|
|
|
- print(f'完整预测时序:{Droom_pred}')
|
|
|
- index = pd.Index(
|
|
|
- pd.date_range(
|
|
|
- start = NOW+timedelta(minutes=1),
|
|
|
- end = NOW+timedelta(minutes=1)+timedelta(minutes=int(pred_lag)),
|
|
|
- freq = '1min'
|
|
|
+ try:
|
|
|
+ Droom_cur = equp_data.loc[:,f'room_{each_room_num}_Dpv'].values[-1]
|
|
|
+ if use_DHU_model:
|
|
|
+ room_model = RoomDewPredictor.load(f'{config_reader_path}/model/{each_eaup_name}_room_{each_room_num}_Dpv.pkl')
|
|
|
+ Droom_pred = room_model.predict_Droom(Dout=Dout_pred,Droom_cur=Droom_cur)
|
|
|
+ else:
|
|
|
+ room_model = RoomDewPredictor.load(f'{config_reader_path}/model/{each_eaup_name}_room_{each_room_num}_Dpv_{room_model_name}.pkl')
|
|
|
+ Droom_pred = room_model.predict_Droom(Dout=wheel_TinR,Droom_cur=Droom_cur,sm_frac=0.5)
|
|
|
+ pred_lag = room_model.model_info['model_Droom']['lag']
|
|
|
+
|
|
|
+ print(f'{each_eaup_name}房间{each_room_num}在{NOW}的预测值')
|
|
|
+ print(f'完整预测时序:{Droom_pred}')
|
|
|
+ index = pd.Index(
|
|
|
+ pd.date_range(
|
|
|
+ start = NOW + timedelta(minutes=1),
|
|
|
+ end = NOW + timedelta(minutes=1)+timedelta(minutes=int(pred_lag)),
|
|
|
+ freq = '1min'
|
|
|
+ )
|
|
|
)
|
|
|
- )
|
|
|
- # 完整时序预测
|
|
|
- write_ts_predict(
|
|
|
- point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpv']}",
|
|
|
- value = Droom_pred,
|
|
|
- ts = index
|
|
|
- )
|
|
|
- if config_reader.get_equp_info(each_eaup_name,'房间露点预测用当前值',info_type='bool'):
|
|
|
- print(f'{each_eaup_name}房间{each_room_num}仅输出当前露点')
|
|
|
- Droom_pred_last = Droom_cur
|
|
|
- pred_lag = 1
|
|
|
- else:
|
|
|
- Droom_pred_last = Droom_pred[-1]
|
|
|
- print(f'{pred_lag}分钟后的预测值为{Droom_pred_last}')
|
|
|
- # 最远预测点
|
|
|
- write_lag_predict(
|
|
|
- point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpd']}",
|
|
|
- value = Droom_pred_last
|
|
|
- )
|
|
|
- # 最远预测步长
|
|
|
- write_lag_predict(
|
|
|
- point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpdlag']}",
|
|
|
- value = pred_lag
|
|
|
- )
|
|
|
+ # 完整时序预测
|
|
|
+ write_ts_predict(
|
|
|
+ point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpv']}",
|
|
|
+ value = Droom_pred,
|
|
|
+ ts = index
|
|
|
+ )
|
|
|
+ if config_reader.get_equp_info(each_eaup_name,'房间露点预测用当前值',info_type='bool') or len(Droom_pred)==0:
|
|
|
+ print(f'{each_eaup_name}房间{each_room_num}仅输出当前露点')
|
|
|
+ Droom_pred_last = Droom_cur
|
|
|
+ pred_lag = 1
|
|
|
+ else:
|
|
|
+ Droom_pred_last = Droom_pred[-1]
|
|
|
+ print(f'{pred_lag}分钟后的预测值为{Droom_pred_last}')
|
|
|
+ # 最远预测点
|
|
|
+ write_lag_predict(
|
|
|
+ point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpd']}",
|
|
|
+ value = Droom_pred_last
|
|
|
+ )
|
|
|
+ # 最远预测步长
|
|
|
+ write_lag_predict(
|
|
|
+ point_id = f"{each_eaup_name}_{room_SP_point[f'room_{each_room_num}_Dpdlag']}",
|
|
|
+ value = pred_lag
|
|
|
+ )
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ continue
|
|
|
|
|
|
|
|
|
def load_data(
|