python - How can I calculate the DOP values for a set of GPS satellites in Python 2.7.2?
问题描述
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
解决方案
cov_matrix = np.linalg.inv(LOS_Matrix * LOS_Matrix_t)
应该是
cov_matrix = np.linalg.inv(LOS_Matrix.dot(LOS_Matrix_t))
我知道我知道,这很混乱。但是在 numpy 中你有两种不同的类型,一种是ndarray
你应该使用的,另一种是你不应该使用的矩阵。对于ndarray
乘法,默认为元素乘法。
推荐阅读
- django - 我想在 Django 中进行两个查询集搜索
- c# - 为表格中更改的单元格值引发事件
- sql - SQL Optimize 中的 NGram 查询
- node.js - 如何在 apache 服务器 8000 和 2000 端口中运行节点 js?
- ruby-on-rails - Google API 错误:超过查询限制。导轨 4
- sql - 遍历 T-SQL 中的字符列表
- c# - FreshMvvm 中的控制反转 (IOC)
- asp.net-mvc - 回发后从控制器返回列表到视图
- javascript - 尖括号(如方法名)的用途是什么
() 在打字稿中 - reactjs - 使用 api 在 react 中创建分页