如何在Python 2.7.2中计算一组GPS卫星的DOP值? [英] How can I calculate the DOP values for a set of GPS satellites in Python 2.7.2?

查看:178
本文介绍了如何在Python 2.7.2中计算一组GPS卫星的DOP值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我找到了指南为此,但是我在将其转换为python时遇到了麻烦.

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? 

我是python noob,数学也不是我的强项,我只能通过在错误消息后依次搜索错误消息来解决这一问题.

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.

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

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?

欢呼

推荐答案

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

应该是

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

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

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.

这篇关于如何在Python 2.7.2中计算一组GPS卫星的DOP值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆