refactor: 移除全局参数对象并改为函数参数传递

This commit is contained in:
dmy
2026-03-02 23:11:27 +08:00
parent 630598d498
commit bcaa4a5a9e
4 changed files with 19 additions and 18 deletions

12
core.py
View File

@@ -28,9 +28,6 @@ class Parameter:
ac_or_dc: str # 交流或直流标识,"AC" 或 "DC",默认 "AC"
para = Parameter()
def rg_line_function_factory(_rg, ground_angel): # 返回一个地面捕雷线的直线方程
y_d = _rg / math.cos(ground_angel) # y轴上的截距
# 利用公式y-y0=k(x-x0) 得到直线公式
@@ -188,9 +185,8 @@ def solve_circle_line_intersection(
return [_x, _y]
def min_i(string_len, u_ph):
def min_i(string_len, u_ph, altitude: float = 0):
# 海拔修正
altitude = para.altitude
if altitude > 1000:
k_a = math.exp((altitude - 1000) / 8150) # 气隙海拔修正
else:
@@ -456,9 +452,9 @@ def tangent_line_k(line_x, line_y, center_x, center_y, radius, init_k=10.0):
return np.array(k_candidate)[np.max(k_angle) == k_angle].tolist()[-1]
def func_ng(td): # 地闪密度,通过雷暴日计算
if para.ng > 0:
r = para.ng
def func_ng(td, ng: float = 0): # 地闪密度,通过雷暴日计算
if ng > 0:
r = ng
else:
r = 0.023 * (td**1.3)
return r