David vor 5 Monaten
Ursprung
Commit
c6bd04f06a
3 geänderte Dateien mit 123 neuen und 109 gelöschten Zeilen
  1. 9 4
      app.py
  2. 18 13
      cache/clocking.py
  3. 96 92
      config.yml

+ 9 - 4
app.py

@@ -190,7 +190,12 @@ if __name__ == "__main__":
     #     "access_log_format": "gunicorn %(h)s - %(t)s - %(r)s - %(s)s - %(f)s",
     #     "backlog": 30,
     # }
-    threading.Thread(target=clock.calculate_coe, args=(True,)).start()
-    # # 启动服务
-    # StandaloneApplication(app, options=gunicorn_config).run()
-    app.run(host='0.0.0.0', port=opt.port, debug=False, ssl_context=(current_path + '/ssl/server.pem', current_path + '/ssl/server.key'))
+
+    if opt.algorithm_platform['switch']:
+        clock.calculate_coe(True)
+    else:
+        threading.Thread(target=clock.calculate_coe, args=(True,)).start()
+        # # 启动服务
+        # StandaloneApplication(app, options=gunicorn_config).run()
+        app.run(host='0.0.0.0', port=opt.port, debug=False,
+                ssl_context=(current_path + '/ssl/server.pem', current_path + '/ssl/server.key'))

+ 18 - 13
cache/clocking.py

@@ -234,14 +234,20 @@ class Clock(object):
             self.logger.info(
                 "4.过去{}天的短期的考核分:{:.4f},自动确认系数后,{} 超短期的考核分:{:.4f},超短期公式:{:.4f},神经网络:{:.4f},历史功率:{:.4f}".format(
                     str(self.opt.update_coe_days), dq_score, T, best_score, cdq_score, dq_fix_score, his_fix_score))
-            if self.opt.coe[T]['score']:
-                self.opt.coe[T]['m'] = round(best_score_m, 3)
-                self.opt.coe[T]['n'] = round(best_score_n, 3)
-                pre_data["new"] = round(best_score_m * pre_data['dq_fix'] + best_score_n * pre_data['history'], 3)
+            if not self.opt.algorithm_platform['switch']:
+                if self.opt.coe[T]['score']:
+                    self.opt.coe[T]['m'] = round(best_score_m, 3)
+                    self.opt.coe[T]['n'] = round(best_score_n, 3)
+                    pre_data["new"] = round(best_score_m * pre_data['dq_fix'] + best_score_n * pre_data['history'], 3)
+                else:
+                    self.opt.coe[T]['m'] = round(best_coe_m, 3)
+                    self.opt.coe[T]['n'] = round(best_coe_n, 3)
+                    pre_data["new"] = round(best_coe_m * pre_data['dq_fix'] + best_coe_n * pre_data['history'], 3)
             else:
-                self.opt.coe[T]['m'] = round(best_coe_m, 3)
-                self.opt.coe[T]['n'] = round(best_coe_n, 3)
-                pre_data["new"] = round(best_coe_m * pre_data['dq_fix'] + best_coe_n * pre_data['history'], 3)
+                self.opt.coe[T]['score_m'] = round(best_score_m, 3)
+                self.opt.coe[T]['score_n'] = round(best_score_n, 3)
+                self.opt.coe[T]['acc_m'] = round(best_coe_m, 3)
+                self.opt.coe[T]['acc_n'] = round(best_coe_n, 3)
             pre_data.to_csv(current_path + '/data/测试集{}.csv'.format(point + 1), index=False)
         else:
             best, best_coe_m, best_coe_n = 0, 0, 0
@@ -295,8 +301,6 @@ class Clock(object):
             day_start = day_end - pd.Timedelta(days=1)
             db = DataBase(begin=day_start, end=day_end, opt=self.opt, logger=self.logger)
             db.data_process()
-            formula = Formulas(self.opt)
-            assess = Assessment(self.opt, self.logger)
             self.logger.info("------------进入测试集自动计算-------------")
             nwp, env, dq, rp, rp_his = self.material(day_start, day_end)
             nwp = pd.merge(nwp, dq, on="C_TIME")
@@ -313,7 +317,7 @@ class Clock(object):
             _, _, env_features = self.normalize(env, mean=mean, std=std)
 
             data_test, env = self.process.get_test_data(nwp_features, env_features)
-            test_X, data_Y = self.features.get_test_data(data_test, env)
+            test_X, test_Y, data_Y = self.features.get_test_data(data_test, env)
             result = self.fmi.predict(test_X, batch_size=8)
             mongo_data = []
             # 2.历史数据
@@ -338,10 +342,11 @@ class Clock(object):
                 pre_data['history'] = self.fix.history_error_clock(pre_data, rp_his, 16 - point - 1)
                 self.logger.info("第{}点的时间周期为:{}-{}".format(T, pre_data['C_TIME'][0], pre_data['C_TIME'].iloc[-1]))
 
-                pre_data = self.update_coe(pre_data, assess, formula, point, test=False)
+                pre_data["coe-ass"] = round(self.opt.coe[T]['score_m'] * pre_data['dq_fix'] + self.opt.coe[T]['score_n'] * pre_data['history'],3)
+                pre_data["coe-acc"] = round(self.opt.coe[T]['acc_m'] * pre_data['dq_fix'] + self.opt.coe[T]['acc_n'] * pre_data['history'], 3)
                 pre_data['howLongAgo'] = point + 1
-                pre_data = pre_data.loc[:,['C_TIME', 'dq_fix', 'C_FP_VALUE', 'history', 'coe-acc', 'coe-ass', 'howLongAgo']]
-                df_melted = pre_data.melt(id_vars=['C_TIME', 'howLongAgo'], var_name='model', value_name='power_forecast')
+                pre_data = pre_data.loc[:,['C_TIME', 'C_REAL_VALUE', 'dq_fix', 'C_FP_VALUE', 'history', 'coe-acc', 'coe-ass', 'howLongAgo']]
+                df_melted = pre_data.melt(id_vars=['C_TIME', 'C_REAL_VALUE', 'howLongAgo'], var_name='model', value_name='power_forecast')
                 df_melted['farm_id'] = self.opt.algorithm_platform['farm_id']
                 mongo_data.append(df_melted)
             from cache.mongo import insert_data_into_mongo

+ 96 - 92
config.yml

@@ -24,23 +24,23 @@ Model:
   use_cuda: false
   valid_data_rate: 0.15
 algorithm_platform:
-  farm_id: j00314
+  farm_id: j00083
   mongodb_database: db_cdq
-  mongodb_write_table: j00314
+  mongodb_write_table: j00083
   overwrite: 1
-  switch: 1
+  switch: true
 authentication:
-  date: '2025-01-08'
-  full_cap: '2024-04-30'
-  repair: '2025-01-08'
+  date: '2024-01-06'
+  full_cap: '2021-04-30'
+  repair: '2024-01-06'
 calculate: []
-cap: 50.0
+cap: 10.0
 coe:
   T1:
-    m: 0.029
-    n: 0.847
+    m: 0.418
+    n: 0.553
     score: false
-    update: true
+    update: false
   T10:
     m: 0.418
     n: 0.294
@@ -72,9 +72,13 @@ coe:
     score: true
     update: false
   T16:
-    m: 0.582
-    n: 0.429
+    acc_m: 0.935
+    acc_n: 0.029
+    m: 0.988
+    n: 0.029
     score: false
+    score_m: 1.235
+    score_n: 0.606
     update: true
   T2:
     m: 0.365
@@ -107,17 +111,17 @@ coe:
     score: true
     update: false
   T8:
-    m: 0.706
-    n: 0.282
+    m: 0.918
+    n: 0.029
     score: false
-    update: true
+    update: false
   T9:
     m: 0.535
     n: 0.447
     score: true
     update: false
 config_yaml: config.yml
-database: mysql+pymysql://root:123456@192.168.1.37:3306/ipfcst-v3-j00105-s-nx55
+database: mysql+pymysql://root:mysql_T7yN3E@192.168.12.10:19306/ipfcst_j00083_20240516123732
 dataloc: ./data
 env_columns:
 - C_TIME
@@ -127,48 +131,48 @@ env_columns:
 - C_RH
 - C_REAL_VALUE
 first_point:
-  sun_up_time: '2024-11-10 07:30:00'
-  sun_up_value: 0.11
+  sun_up_time: '2024-01-06 07:30:00'
+  sun_up_value: 0.14
   switch: true
 full_field: true
 history_hours: 1
 mean:
-  C_AIRT: -0.568
-  C_CELLT: 2.067
-  C_DIFFUSER: 117.133
-  C_DIFFUSE_RADIATION: 56.596
-  C_DIRECTR: 77.507
-  C_DIRECT_RADIATION: 132.056
-  C_FP_VALUE: 5.097
-  C_GLOBALR: 194.641
-  C_GLOBALRDA: 7.952
-  C_HOURDA: 3.617
-  C_OBLIQUER: 252.529
-  C_OBLIQUERDA: 10.286
-  C_P: 867.866
-  C_PRESSURE: 860.412
-  C_REAL_VALUE: 6.675
-  C_RH: 38.579
-  C_SWR: 188.652
-  C_T: -1.862
-  C_WD: 211.749
-  C_WD10: 214.02
-  C_WD100: 224.432
-  C_WD170: 224.909
-  C_WD30: 218.134
-  C_WD50: 220.114
-  C_WD70: 221.475
-  C_WD80: 222.015
-  C_WD90: 222.551
-  C_WS: 1.916
-  C_WS10: 2.963
-  C_WS100: 4.467
-  C_WS170: 4.766
-  C_WS30: 3.612
-  C_WS50: 3.921
-  C_WS70: 4.131
-  C_WS80: 4.214
-  C_WS90: 4.292
+  C_AIRT: -0.916
+  C_CELLT: 0.64
+  C_DIFFUSER: 124.212
+  C_DIFFUSERDA: 5.399
+  C_DIFFUSE_RADIATION: 31.081
+  C_DIRECTR: 75.206
+  C_DIRECTRDA: 3.249
+  C_DIRECT_RADIATION: 72.522
+  C_FP_VALUE: 1.249
+  C_GLOBALR: 205.895
+  C_GLOBALRDA: 8.857
+  C_HOURDA: 3.065
+  C_P: 980.66
+  C_PRESSURE: 987.154
+  C_REAL_VALUE: 1.456
+  C_RH: 52.221
+  C_SWR: 103.602
+  C_T: -2.562
+  C_WD: 223.007
+  C_WD10: 231.404
+  C_WD100: 233.81
+  C_WD170: 234.108
+  C_WD30: 232.365
+  C_WD50: 232.774
+  C_WD70: 233.008
+  C_WD80: 233.032
+  C_WD90: 233.027
+  C_WS: 2.966
+  C_WS10: 3.697
+  C_WS100: 6.751
+  C_WS170: 6.936
+  C_WS30: 4.982
+  C_WS50: 5.608
+  C_WS70: 6.045
+  C_WS80: 6.218
+  C_WS90: 6.391
   DT_TAG: 48.5
 new_field: true
 nwp_columns:
@@ -204,53 +208,53 @@ repair_model_cycle: 5
 reset_sys: false
 spot_trading: []
 std:
-  C_AIRT: 6.321
-  C_CELLT: 11.059
-  C_DIFFUSER: 172.191
-  C_DIFFUSE_RADIATION: 85.053
-  C_DIRECTR: 134.741
-  C_DIRECT_RADIATION: 198.457
-  C_FP_VALUE: 9.418
-  C_GLOBALR: 299.8
-  C_GLOBALRDA: 7.964
-  C_HOURDA: 3.584
-  C_OBLIQUER: 390.907
-  C_OBLIQUERDA: 10.47
-  C_P: 5.749
-  C_PRESSURE: 5.371
-  C_REAL_VALUE: 11.936
-  C_RH: 13.209
-  C_SWR: 283.51
-  C_T: 5.829
-  C_WD: 89.245
-  C_WD10: 61.869
-  C_WD100: 67.519
-  C_WD170: 67.519
-  C_WD30: 62.113
-  C_WD50: 63.592
-  C_WD70: 65.084
-  C_WD80: 65.77
-  C_WD90: 66.516
-  C_WS: 1.587
-  C_WS10: 1.732
-  C_WS100: 2.58
-  C_WS170: 2.6
-  C_WS30: 2.084
-  C_WS50: 2.264
-  C_WS70: 2.391
-  C_WS80: 2.442
-  C_WS90: 2.486
+  C_AIRT: 9.717
+  C_CELLT: 11.517
+  C_DIFFUSER: 208.45
+  C_DIFFUSERDA: 5.589
+  C_DIFFUSE_RADIATION: 49.036
+  C_DIRECTR: 120.093
+  C_DIRECTRDA: 3.31
+  C_DIRECT_RADIATION: 114.417
+  C_FP_VALUE: 2.201
+  C_GLOBALR: 325.022
+  C_GLOBALRDA: 9.05
+  C_HOURDA: 3.048
+  C_P: 8.428
+  C_PRESSURE: 7.625
+  C_REAL_VALUE: 2.652
+  C_RH: 16.703
+  C_SWR: 163.453
+  C_T: 9.78
+  C_WD: 69.052
+  C_WD10: 91.085
+  C_WD100: 95.049
+  C_WD170: 95.067
+  C_WD30: 92.649
+  C_WD50: 93.547
+  C_WD70: 94.253
+  C_WD80: 94.522
+  C_WD90: 94.577
+  C_WS: 1.952
+  C_WS10: 1.889
+  C_WS100: 2.885
+  C_WS170: 2.873
+  C_WS30: 2.309
+  C_WS50: 2.526
+  C_WS70: 2.676
+  C_WS80: 2.736
+  C_WS90: 2.78
   DT_TAG: 27.711
 update_add_train_days: 60
 update_coe_days: 3
 usable_power:
   api_able_power: true
-  bias: 2.524
+  bias: 0.478
   clean_power_which: 1
   coe: 4
   down_fractile: 30
   env: C_GLOBALR
-  k: 0.04079
+  k: 0.00831
   outliers_threshold: 1.5
   up_fractile: 70
 version: solar-3.1.0.south