|
@@ -22,23 +22,30 @@ def forecast_data_distribution(pre_data, args):
|
|
|
col_time = args['col_time']
|
|
|
farm_id = args['farm_id']
|
|
|
col_radiance = args['col_radiance']
|
|
|
- radiance_max = float(args['radiance_max'])
|
|
|
+ pre_radiance_max = pre_data[col_radiance].max()
|
|
|
cap = float(args['cap'])
|
|
|
pre_data['farm_id'] = farm_id
|
|
|
+ if 'control_type' in args and args['control_type'] == 'cut':
|
|
|
+ radiance_max = args['radiance_max']
|
|
|
+ else:
|
|
|
+ radiance_max = max(float(args['radiance_max']), pre_radiance_max)
|
|
|
pre_data['power_forecast'] = round(pre_data[col_radiance] * cap / radiance_max, 2)
|
|
|
+
|
|
|
if 'sunrise_time' in args:
|
|
|
sunrise_time = args['sunrise_time']
|
|
|
pre_data.loc[pre_data[col_time].dt.time < sunrise_time, 'power_forecast'] = 0
|
|
|
if 'sunset_time' in args:
|
|
|
sunset_time = args['sunset_time']
|
|
|
- pre_data[pre_data[col_time] > sunset_time, 'power_forecast'] = 0
|
|
|
+ pre_data.loc[pre_data[col_time] > sunset_time, 'power_forecast'] = 0
|
|
|
+ pre_data.loc[pre_data['power_forecast'] > cap, 'power_forecast'] = cap
|
|
|
+ pre_data.loc[pre_data['power_forecast'] < 0, 'power_forecast'] = 0
|
|
|
return pre_data[['farm_id', 'date_time', 'power_forecast']]
|
|
|
|
|
|
|
|
|
def model_prediction(df, args):
|
|
|
# 新增日出、日落时间参数
|
|
|
howLongAgo, farm_id, target, cap, col_radiance, radiance_max, model_name, col_time = int(args['howLongAgo']), args['farm_id'], \
|
|
|
- args['target'], float(args['cap']), args['col_radiance'], args['radiance_max'], args['model_name'], args['col_time']
|
|
|
+ args['target'], float(args['cap']), args['col_radiance'], float(args['radiance_max']), args['model_name'], args['col_time']
|
|
|
df['power_forecast'] = round(df[col_radiance]*cap/radiance_max, 2)
|
|
|
df.loc[df['power_forecast'] < 0, 'power_forecast'] = 0
|
|
|
if 'sunrise_time' in args:
|
|
@@ -50,6 +57,8 @@ def model_prediction(df, args):
|
|
|
df['model'] = model_name
|
|
|
df['howLongAgo'] = howLongAgo
|
|
|
df['farm_id'] = farm_id
|
|
|
+ df.loc[df['power_forecast'] > cap, 'power_forecast'] = cap
|
|
|
+ df.loc[df['power_forecast'] < 0, 'power_forecast'] = 0
|
|
|
print("model predict result successfully!")
|
|
|
return df[['dateTime', 'howLongAgo', 'model', 'farm_id', 'power_forecast', target]]
|
|
|
|