|
@@ -11,7 +11,7 @@
|
|
|
import argparse
|
|
|
import pandas as pd
|
|
|
from pathlib import Path
|
|
|
-from app.common.logs import logger, args
|
|
|
+from app.common.logs import logger, params
|
|
|
|
|
|
"""
|
|
|
调用思路
|
|
@@ -31,46 +31,46 @@ def material(input_file, isDq=True):
|
|
|
nwp_v, nwp_v_h = 'DQYC_IN_FORECAST_WEATHER.txt', 'DQYC_IN_FORECAST_WEATHER_H.txt'
|
|
|
nwp_own, nwp_own_h = 'DQYC_IN_FORECAST_WEATHER_OWNER.txt', 'DQYC_IN_FORECAST_WEATHER_OWNER_H.txt',
|
|
|
input_file = Path(input_file)
|
|
|
- basic = pd.read_csv(input_file / basi, sep='\s+', header=0)
|
|
|
- power = pd.read_csv(input_file / power, sep='\s+', header=0)
|
|
|
+ basic = pd.read_csv(input_file / basi, sep=r'\s+', header=0)
|
|
|
+ power = pd.read_csv(input_file / power, sep=r'\s+', header=0)
|
|
|
plant_type = int(basic.loc[basic['PropertyID'].to_list().index(('PlantType')), 'Value'])
|
|
|
if isDq:
|
|
|
- nwp_v = pd.read_csv(input_file / '0' / nwp_v, sep='\s+', header=0)
|
|
|
- nwp_v_h = pd.read_csv(input_file / '0' / nwp_v_h, sep='\s+', header=0)
|
|
|
- nwp_own = pd.read_csv(input_file / '1' / nwp_own, sep='\s+', header=0)
|
|
|
- nwp_own_h = pd.read_csv(input_file / '1' / nwp_own_h, sep='\s+', header=0)
|
|
|
- if args['switch_nwp_owner']:
|
|
|
+ nwp_v = pd.read_csv(input_file / '0' / nwp_v, sep=r'\s+', header=0)
|
|
|
+ nwp_v_h = pd.read_csv(input_file / '0' / nwp_v_h, sep=r'\s+', header=0)
|
|
|
+ nwp_own = pd.read_csv(input_file / '1' / nwp_own, sep=r'\s+', header=0)
|
|
|
+ nwp_own_h = pd.read_csv(input_file / '1' / nwp_own_h, sep=r'\s+', header=0)
|
|
|
+ if params['switch_nwp_owner']:
|
|
|
nwp_v, nwp_v_h = nwp_own, nwp_own_h
|
|
|
# 如果是风电
|
|
|
if plant_type == 0:
|
|
|
- station_info = pd.read_csv(input_file / station_info_w, sep='\s+', header=0)
|
|
|
- station_info_d = pd.read_csv(input_file / station_info_d_w, sep='\s+', header=0)
|
|
|
- nwp = pd.read_csv(input_file / nwp_w, sep='\s+', header=0)
|
|
|
- nwp_h = pd.read_csv(input_file / nwp_w_h, sep='\s+', header=0)
|
|
|
+ station_info = pd.read_csv(input_file / station_info_w, sep=r'\s+', header=0)
|
|
|
+ station_info_d = pd.read_csv(input_file / station_info_d_w, sep=r'\s+', header=0)
|
|
|
+ nwp = pd.read_csv(input_file / nwp_w, sep=r'\s+', header=0)
|
|
|
+ nwp_h = pd.read_csv(input_file / nwp_w_h, sep=r'\s+', header=0)
|
|
|
return station_info, station_info_d, nwp, nwp_h, power, nwp_v, nwp_v_h
|
|
|
# 如果是光伏
|
|
|
elif plant_type == 1:
|
|
|
- station_info = pd.read_csv(input_file / station_info_s, sep='\s+', header=0)
|
|
|
- station_info_d = pd.read_csv(input_file / station_info_d_s, sep='\s+', header=0)
|
|
|
- nwp = pd.read_csv(input_file / nwp_s, sep='\s+', header=0)
|
|
|
- nwp_h = pd.read_csv(input_file / nwp_s_h, sep='\s+', header=0)
|
|
|
+ station_info = pd.read_csv(input_file / station_info_s, sep=r'\s+', header=0)
|
|
|
+ station_info_d = pd.read_csv(input_file / station_info_d_s, sep=r'\s+', header=0)
|
|
|
+ nwp = pd.read_csv(input_file / nwp_s, sep=r'\s+', header=0)
|
|
|
+ nwp_h = pd.read_csv(input_file / nwp_s_h, sep=r'\s+', header=0)
|
|
|
return station_info, station_info_d, nwp, nwp_h, power, nwp_v, nwp_v_h
|
|
|
else:
|
|
|
# 区域级预测待定,可能需要遍历获取场站数据
|
|
|
- basic_area = pd.read_csv(input_file / basi_area, sep='\s+', header=0)
|
|
|
+ basic_area = pd.read_csv(input_file / basi_area, sep=r'\s+', header=0)
|
|
|
return basic_area
|
|
|
|
|
|
-def input_file_handler(input_file: str):
|
|
|
+def input_file_handler(input_file: str, model_name: str):
|
|
|
# DQYC:短期预测,qy:区域级
|
|
|
if 'dqyc' in input_file.lower():
|
|
|
station_info, station_info_d, nwp, nwp_h, power, nwp_v, nwp_v_h = material(input_file, True)
|
|
|
- cap = round(station_info['PlantCap'][0], 2)
|
|
|
+ cap = round(float(station_info['PlantCap'][0]), 2)
|
|
|
# 含有predict,预测
|
|
|
if 'predict' in input_file.lower():
|
|
|
pre_data = nwp_v
|
|
|
- if args['model_name'] == 'fmi':
|
|
|
+ if model_name == 'fmi':
|
|
|
from app.predict.tf_fmi_pre import model_prediction
|
|
|
- elif args['model_name'] == 'cnn':
|
|
|
+ elif model_name == 'cnn':
|
|
|
from app.predict.tf_cnn_pre import model_prediction
|
|
|
else:
|
|
|
from app.predict.tf_lstm_pre import model_prediction
|
|
@@ -89,14 +89,14 @@ def main():
|
|
|
parser = argparse.ArgumentParser(description="程序描述")
|
|
|
# 创建
|
|
|
# 添加参数
|
|
|
- parser.add_argument("input_file", help="输入文件路径")
|
|
|
-
|
|
|
+ parser.add_argument("input_file", help="输入文件路径") # 第一个位置参数
|
|
|
+ parser.add_argument("model_name", default="cnn", help='选择短期模型') # 第二个位置参数
|
|
|
# 解析参数
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
# 使用参数
|
|
|
print(f"文件: {args.input_file}")
|
|
|
- input_file_handler(args.input_file)
|
|
|
+ input_file_handler(args.input_file, args.model_name)
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|