如何在python2.7.2中计算一组GPS卫星的DOP值?

2024-06-02 09:09:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用numpy1.9.3在python2.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 noob,数学也不是我的强项,我只是通过google一条又一条的错误信息才做到这一点。你知道吗

我现在看到它运行时没有任何错误消息,但它似乎也不正确,否则TDOP值应该是可计算的。你知道吗

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

干杯


Tags: thetoisasnpsinbecos
1条回答
网友
1楼 · 发布于 2024-06-02 09:09:42

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

应该是的

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

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

相关问题 更多 >