David 1 month ago
parent
commit
de43197583
1 changed files with 8 additions and 6 deletions
  1. 8 6
      post_processing/cdq_coe_gen.py

+ 8 - 6
post_processing/cdq_coe_gen.py

@@ -35,6 +35,7 @@ def iterate_coe_simple(pre_data, point, config, coe):
     best_score, best_acc1, best_score_m, best_score_n = 999, 0, 999, 0
 
     pre_data = history_error(pre_data, config['col_power'], config['col_pre'], int(coe[T]['hour']//0.25))
+    pre_data = curve_limited(pre_data, config, 'his_fix')
     req_his_fix = prepare_request_body(pre_data, config, 'his_fix')
     req_dq = prepare_request_body(pre_data, config, col_pre)
 
@@ -79,6 +80,7 @@ def iterate_coe(pre_data, point, config, coe):
 
     # 历史数据处理(保持原逻辑)
     pre_data = history_error(pre_data, config['col_power'], config['col_pre'], int(coe[T]['hour'] // 0.25))
+    pre_data = curve_limited(pre_data, config, 'his_fix')
     req_his_fix = prepare_request_body(pre_data, config, 'his_fix')
     req_dq = prepare_request_body(pre_data, config, col_pre)
 
@@ -152,6 +154,7 @@ def iterate_his_coe(pre_data, point, config, coe):
         data = pre_data.copy()
         his_window = int(hour // 0.25)
         pre_data_f = history_error(data, config['col_power'], config['col_pre'], his_window)
+        pre_data_f = curve_limited(pre_data_f, config, 'his_fix')
         req_his_fix = prepare_request_body(pre_data_f, config, 'his_fix')
         his_fix_acc, his_fix_score = calculate_acc(API_URL, req_his_fix)
 
@@ -237,19 +240,18 @@ def history_error(data, col_power, col_pre, his_window):
     print("???", len(data), len(pad_data_error))
     data['his_fix'] = data[col_pre] + pad_data_error
     data = data.iloc[his_window:, :].reset_index(drop=True)
-
-    data = curve_limited(data, config, 'his_fix')
     return data
 
 def curve_limited(pre_data, config, predict):
     """
     plant_type: 0 风 1 光
     """
+    data = pre_data.copy()
     col_pre, col_time, cap = config['col_pre'], config['col_time'], config['openCapacityName']
-    pre_data[col_time] = pd.to_datetime(pre_data[col_time])
-    pre_data.loc[pre_data[predict] < 0, [predict]] = 0
-    pre_data.loc[pre_data[predict] > cap, [predict]] = cap
-    return pre_data
+    data[col_time] = pd.to_datetime(data[col_time])
+    data.loc[data[predict] < 0, [predict]] = 0
+    data.loc[data[predict] > cap, [predict]] = cap
+    return data
 
 @app.route('/cdq_coe_gen', methods=['POST'])
 def get_station_cdq_coe():