How can I calculate the DOP values for a set of GPS satellites in Python 2.7.2?

回眸只為那壹抹淺笑 提交于 2021-01-04 09:25:15

问题


I'm trying to calculate the DOP values for a set of GPS satellites in Python 2.7.2 using numpy 1.9.3.

I found a guide on how to do this but I'm having trouble translating it to python.

Here's what I tried so far:

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? 

I'm a python noob and math isn't my strong suit either, I only got this far by googling error message after error message.

I'm now at a point it runs without any error message but it doesn't seem correct either, otherwise the TDOP value should be computable for example .

Does anyone have an idea where the issue lies?

Cheers


回答1:


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

Should probably be

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

I know I know, it's confusing. But in numpy you have two different types, one is the ndarray which you should use and another is matrix which your should not use. For ndarray multiplication defaults to element-wise multiplication.



来源:https://stackoverflow.com/questions/58997496/how-can-i-calculate-the-dop-values-for-a-set-of-gps-satellites-in-python-2-7-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!