直到最近,我用来计算来自某个特定地点的卫星的仰角和方位角的代码似乎仍然有效。然后我使用了一个站点的不同文件,不是在北半球,而是在南半球。计算的仰角有时是负的,即卫星在地平线以下。这是不正确的,因此用于卫星位置的文件参数是错误的(不太可能),或者我下面的代码不正确(更有可能)。
rx_position = (self.X_rx, self.Y_rx, self.Z_rx)
diff_position = satellite_carteisan_coords - rx_position
diff_position_individual = diff_position[0]
rho = np.sqrt(diff_position_individual[0]**2 + diff_position_individual[1]**2 + diff_position_individual[2]**2)
dphi, dlambda, h = self.cartesian_to_geoid(rx_position)
slat = np.sin(np.radians(dphi))
slon = np.sin(np.radians(dlambda))
clat = np.cos(np.radians(dphi))
clon = np.cos(np.radians(dlambda))
F = np.array([[-slon, -slat*clon, clat*clon],
[clon, -slat*slon, clat*slon],
[0, clat, slat ]])
np.split(diff_position_individual, 3)
local_vector = np.dot(F.T, diff_position_individual)
E = local_vector[0]
N = local_vector[1]
U = local_vector[2]
hor_dis = np.sqrt(E**2 + N**2)
if hor_dis < 1e-20:
Azi = 0
Ele = 90
else:
Azi = np.rad2deg(math.atan2(E, N))
Ele = np.rad2deg(math.atan2(U, hor_dis))
if Azi < 0:
Azi = Azi + 360
return Azi, Ele
如何确保上面的代码不会最终计算出负仰角?