python - 如何在 Python 2.7.2 中计算一组 GPS 卫星的 DOP 值?

标签 python arrays numpy gps satellite

我正在尝试使用 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 值应该是可计算的,例如。

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

干杯

最佳答案

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

应该是

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

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

关于python - 如何在 Python 2.7.2 中计算一组 GPS 卫星的 DOP 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58997496/

相关文章:

对象数组和 indexOf 的 Javascript 奇怪之处

c - sscanf 替换以前的值

python - 使用一维作为循环中的迭代器剩余维度迭代 3D numpy

python - 检查两个 scipy.sparse.csr_matrix 是否相等

javascript - 从给定索引排序数组

python - 查找图上所有边的路径

python - 通过 PyPDF2 合并两个 PDF,但出现错误 Unexpected destination '/__WKANCHOR_2'

python - 高效(空间)网络邻居?

python - 四舍五入 Python 数字列表并维护它们的总和

将成对列表转换为字典的 Pythonic 方法