Browse Source

对功率数据进行清洗,保留归一化3位小数

liudawei 1 year ago
parent
commit
cc875bbdbb
3 changed files with 17 additions and 6 deletions
  1. 12 1
      db-light/getdata/inputData.py
  2. 2 2
      db-light/norm.py
  3. 3 3
      db-light/utils/Arg.py

+ 12 - 1
db-light/getdata/inputData.py

@@ -106,6 +106,7 @@ def get_process_weather(database):
         utils.savedata.saveData("weather/weather-{}.csv".format(i), weather)
         utils.savedata.saveData("weather/weather-{}.csv".format(i), weather)
         norm.normalize(weather)
         norm.normalize(weather)
 
 
+
 def get_process_power(database):
 def get_process_power(database):
     """
     """
     获取整体功率数据
     获取整体功率数据
@@ -113,8 +114,17 @@ def get_process_power(database):
     :return:
     :return:
     """
     """
     engine = create_database(database)
     engine = create_database(database)
+    sql_cap = "select C_CAPACITY from t_electric_field"
+    cap = exec_sql(sql_cap, engine)['C_CAPACITY']
     sql_power = "select C_TIME,C_REAL_VALUE from t_power_station_status_data"
     sql_power = "select C_TIME,C_REAL_VALUE from t_power_station_status_data"
     powers = exec_sql(sql_power, engine)
     powers = exec_sql(sql_power, engine)
+    mask1 = powers['C_REAL_VALUE'] > float(cap)
+    mask = powers['C_REAL_VALUE'] == -99
+
+    mask = mask | mask1
+    print("要剔除功率有{}条".format(mask.sum()))
+    powers = powers[~mask]
+
     utils.savedata.saveData("power.csv", powers)
     utils.savedata.saveData("power.csv", powers)
     power5, power_index = [], [0]  # 功率表,索引表
     power5, power_index = [], [0]  # 功率表,索引表
     ps = 0
     ps = 0
@@ -320,11 +330,12 @@ def data_process(database):
     :return:
     :return:
     """
     """
     clear_data()
     clear_data()
+    get_process_power(database)
     get_process_dq(database)
     get_process_dq(database)
     get_process_cdq(database)
     get_process_cdq(database)
     get_process_NWP(database)
     get_process_NWP(database)
     get_process_weather(database)
     get_process_weather(database)
-    get_process_power(database)
+
     indep_process()
     indep_process()
     NWP_indep_process()
     NWP_indep_process()
     norm.save_yml({'mean': norm.mean, 'std': norm.std}, arg.normloc)
     norm.save_yml({'mean': norm.mean, 'std': norm.std}, arg.normloc)

+ 2 - 2
db-light/norm.py

@@ -24,9 +24,9 @@ class Normalize():
         mean_dict = np.mean(df, axis=0)  # 数据的均值
         mean_dict = np.mean(df, axis=0)  # 数据的均值
         std_dict = np.std(df, axis=0)  # 标准差
         std_dict = np.std(df, axis=0)  # 标准差
         for k, v in mean_dict.to_dict().items():
         for k, v in mean_dict.to_dict().items():
-            self.mean[k] = v
+            self.mean[k] = round(v, 3)
         for k, v in std_dict.to_dict().items():
         for k, v in std_dict.to_dict().items():
-            self.std[k] = v
+            self.std[k] = round(v, 3)
         print("归一化参数,均值为:{},方差为:{}".format(self.mean, self.std))
         print("归一化参数,均值为:{},方差为:{}".format(self.mean, self.std))
 
 
     def save_yml(self, yml_dict, path):
     def save_yml(self, yml_dict, path):

+ 3 - 3
db-light/utils/Arg.py

@@ -3,10 +3,10 @@ class Arg:
         # 数据库地址
         # 数据库地址
         self.database = "mysql+pymysql://root:123@localhost:3306/ipfcst-guyuan"
         self.database = "mysql+pymysql://root:123@localhost:3306/ipfcst-guyuan"
         # 数据存放位置
         # 数据存放位置
-        self.dataloc = "../guyuan/"
+        self.dataloc = "../data/guyuan/"
         # 变量存放位置
         # 变量存放位置
-        self.varloc = "../guyuan/var/"
+        self.varloc = "../data/guyuan/var/"
         # 环境监测仪个数
         # 环境监测仪个数
         self.weatherloc = [1]
         self.weatherloc = [1]
         # 归一化文件存放位置
         # 归一化文件存放位置
-        self.normloc = '../guyuan/norm.yaml'
+        self.normloc = '../data/guyuan/norm.yaml'