【问题标题】:How can I calculate the DOP values for a set of GPS satellites in Python 2.7.2?如何在 Python 2.7.2 中计算一组 GPS 卫星的 DOP 值?
【发布时间】:2019-11-22 15:42:53
【问题描述】:

我正在尝试使用 numpy 1.9.3 在 Python 2.7.2 中计算一组 GPS 卫星的 DOP 值。

我找到了一个 guide 来了解如何执行此操作,但我无法将其转换为 python。

到目前为止,这是我尝试过的:

import numpy as np

# First I defined 3 variables for each satellite as described in the guide.  

sat_1_1 =  np.sin(np.deg2rad(136)) * np.cos(np.deg2rad(14))
sat_1_2 =  np.cos(np.deg2rad(136)) * np.cos(np.deg2rad(14))
sat_1_3 =  np.sin(np.deg2rad(14))

sat_2_1 = np.sin(np.deg2rad(329)) * np.cos(np.deg2rad(48))
sat_2_2 = np.cos(np.deg2rad(329)) * np.cos(np.deg2rad(48))
sat_2_3 = np.sin(np.deg2rad(48))

sat_3_1 = np.sin(np.deg2rad(253)) * np.cos(np.deg2rad(36))
sat_3_2 = np.cos(np.deg2rad(253)) * np.cos(np.deg2rad(36))
sat_3_3 = np.sin(np.deg2rad(36))

sat_4_1 = np.sin(np.deg2rad(188)) * np.cos(np.deg2rad(9))
sat_4_2 = np.cos(np.deg2rad(188)) * np.cos(np.deg2rad(9))
sat_4_3 = np.sin(np.deg2rad(9)) 

# Next I created the line-of-sight matrix: 

LOS_Matrix = np.array([[sat_1_1, sat_1_2, sat_1_3, 1.0], [sat_2_1, sat_2_2, sat_2_3, 1.0], [sat_3_1, sat_3_2, sat_3_3, 1.0], [sat_4_1, sat_4_2, sat_4_3, 1.0]])

# Then its transpose:

LOS_Matrix_t = LOS_Matrix.transpose()

# Next the guide says to compute the covariance matrix which is said to be equal to the inverse of LOS_Matrix * LOS_Matrix_t, so:

cov_matrix = np.linalg.inv(LOS_Matrix * LOS_Matrix_t)

# This should now lets me calculate the DOP values such as GDOP, PDOP, etc

PDOP = np.sqrt(cov_matrix[0, 0] + cov_matrix[1, 1] + cov_matrix[2, 2])

# This comes out as 2.25575033021 which is possbile though it seems suspiciously low

# Also TDOP can't be computed since cov_matrix[3, 3] is a negative number so something must be wrong I guess? 

我是一个 python 菜鸟,数学也不是我的强项,我只是通过在错误消息后谷歌搜索错误消息来做到这一点。

我现在在运行时没有任何错误消息,但它似乎也不正确,否则 TDOP 值应该是可计算的,例如 .

有人知道问题出在哪里吗?

干杯

【问题讨论】:

    标签: python arrays numpy gps satellite


    【解决方案1】:

    cov_matrix = np.linalg.inv(LOS_Matrix * LOS_Matrix_t)

    应该是

    cov_matrix = np.linalg.inv(LOS_Matrix.dot(LOS_Matrix_t))

    我知道我知道,这很令人困惑。但是在 numpy 中,您有两种不同的类型,一种是您应该使用的 ndarray,另一种是您不应该使用的矩阵。对于ndarray,乘法默认为逐元素乘法。

    【讨论】:

    • 谢谢!这确实令人困惑。我试过了,现在这些值似乎更合理了。稍后我将用一堆不同的方位角和仰角对其进行测试,看看这一切是否有意义。
    猜你喜欢
    • 2017-04-24
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多