pv_forecasting/tools.py

81 lines
2.5 KiB
Python
Raw Permalink Normal View History

2023-08-23 16:00:06 +08:00
# -*-utf8-*-
import numpy as np
import json
import math
2023-09-07 10:16:10 +08:00
from logzero import logger
2023-08-23 16:00:06 +08:00
def load_config(path):
with open(path, 'r', encoding='utf-8') as fr:
config = json.load(fr)
return config
def cal_angle(prov:str, city:str, angle_config:dict):
"""_summary_
Args:
2023-08-31 16:19:25 +08:00
prov (str): _ 直辖市自治区特别行政区
city (str): _ 地级市地区自治州
angle_config (dict): _
2023-08-23 16:00:06 +08:00
Returns:
_type_: _description_
"""
prov_values = angle_config.get(prov)
if not prov_values:
return False
city_values = prov_values.get(city)
if not prov_values:
values = np.mean(list(prov_values.values), axis=0)
else:
values = city_values
return values
2023-09-07 10:16:10 +08:00
def cal_generation(cap:float, angle, best_angle, dhi_list):
2023-08-23 16:00:06 +08:00
"""_summary_
G = Y * cos(|x - y|)* 0.9 * GHI
"""
dhi_list = np.asarray(dhi_list)
2023-09-07 10:16:10 +08:00
logger.info(dhi_list)
index = math.cos(math.radians(abs(angle - best_angle)))
return list(cap * index * 0.9 * dhi_list / 1000)
2023-08-31 16:19:25 +08:00
def cal_complex_gen(cap:float, angle:float, best_angle:float,
dhi_list:list, t_list:list, materials:str, sigma:float=None,
2023-09-07 10:16:10 +08:00
t_noct:[float, int]=45)->list:
2023-08-31 16:19:25 +08:00
"""复杂的计算出力的方式
Args:
cap (float): _装机容量(KW).
angle (float): _光伏安装倾角(°).
best_angle (float): _当地最佳安装倾角
dhi_list (list): _未来120h辐照预测值W/m2
2023-09-07 10:16:10 +08:00
t_list (list): _未来120h气温预测值,
2023-08-31 16:19:25 +08:00
materials (str): _晶体材料
sigma (float, optional): _温度系数%/取值一般为[-0.45 ~ -0.33]当该值不为None时不通过晶体材料计算sigma. Defaults to None.
t_noct (int, optional): _电池片结温. Defaults to 45.
Returns:
power_list(list[float]): 未来120h的小时出力KW
"""
2023-09-07 10:16:10 +08:00
t_a_noct = 20
g_noct = 800
ita = 0.083 / 0.9
2023-08-31 16:19:25 +08:00
sigma_dict = {
"N型单晶": -0.38,
"P型单晶": -0.42,
"P型多晶": -0.42
}
t_list = np.asarray(t_list)
dhi_list = np.asarray(dhi_list)
2023-09-07 10:16:10 +08:00
t_cell = t_list + (float(t_noct) - t_a_noct)*(dhi_list / g_noct)*(1-ita)
2023-08-31 16:19:25 +08:00
if sigma is None:
sigma = sigma_dict.get(materials, -0.42)
2023-09-07 10:16:10 +08:00
else:
sigma = float(sigma)
2023-08-31 16:19:25 +08:00
K = 1 + sigma / 100 * (t_cell - t_a_noct)
2023-09-07 10:16:10 +08:00
return list(cap * math.cos(math.radians(abs(angle - best_angle))) * dhi_list) * K
if __name__ == '__main__':
print(cal_generation(200., 32, 33, [15., 21., 33., 94.]))