37 lines
993 B
Python
37 lines
993 B
Python
# -*-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:
|
|
prov (str): 省、直辖市、自治区、特别行政区
|
|
city (str): 地级市、地区、自治州、盟
|
|
angle_config (dict): _description_
|
|
|
|
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)
|
|
return list(cap * math.cos(math.radians(abs(angle - best_angle))) * dhi_list) |