pv_forecasting/tools.py

72 lines
2.5 KiB
Python
Raw Normal View History

2023-08-23 16:00:06 +08:00
# -*-utf8-*-
import numpy as np
import json
import math
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
def cal_generation(cap: [int, float], angle, best_angle, dhi_list):
"""_summary_
G = Y * cos(|x - y|)* 0.9 * GHI
"""
dhi_list = np.asarray(dhi_list)
2023-08-31 16:19:25 +08:00
return list(cap * math.cos(math.radians(abs(angle - best_angle))) * dhi_list)
def cal_complex_gen(cap:float, angle:float, best_angle:float,
dhi_list:list, t_list:list, materials:str, sigma:float=None,
t_noct:[float, int]=45, t_a_noct:[float, int]=20, g_noct:[float, int]=800, ita:float=0.083/0.9)->list:
"""复杂的计算出力的方式
Args:
cap (float): _装机容量(KW).
angle (float): _光伏安装倾角(°).
best_angle (float): _当地最佳安装倾角
dhi_list (list): _未来120h辐照预测值W/m2
t_list (list): _未来120气温预测值,
materials (str): _晶体材料
sigma (float, optional): _温度系数%/取值一般为[-0.45 ~ -0.33]当该值不为None时不通过晶体材料计算sigma. Defaults to None.
t_noct (int, optional): _电池片结温. Defaults to 45.
t_a_noct (int, optional): _NOCT下的环境温度. Defaults to 20.
g_noct (int, optional): _NOCT下的辐照(W/m2). Defaults to 800.
ita (_type_, optional): _常数系数. Defaults to 0.083/0.9=0.0922
Returns:
power_list(list[float]): 未来120h的小时出力KW
"""
sigma_dict = {
"N型单晶": -0.38,
"P型单晶": -0.42,
"P型多晶": -0.42
}
t_list = np.asarray(t_list)
dhi_list = np.asarray(dhi_list)
t_cell = t_list + (t_noct - t_a_noct)*(dhi_list / g_noct)*(1-ita)
if sigma is None:
sigma = sigma_dict.get(materials, -0.42)
K = 1 + sigma / 100 * (t_cell - t_a_noct)
return list(cap * math.cos(math.radians(abs(angle - best_angle))) * dhi_list) * K