OB.DAAC Logo
NASA Logo
Ocean Color Science Software

ocssw V2022
qmethod.py
Go to the documentation of this file.
1 def qmethod(vecb, veci, wgt):
2  # Program to determine attitude using Davenport's Q-method
3  # input: vecb, veci, wgt
4  # output: qib
5  # reference: qmethod.pro by Fred Patt
6  # Liang Hong, 2/20/2020
7 
8  import numpy as np
9  from numpy import linalg as LA
10 
11  w = np.copy(vecb)
12  v = np.copy(veci)
13  w = w*np.transpose([np.sqrt(wgt),np.sqrt(wgt),np.sqrt(wgt)])
14  v = v*np.transpose([np.sqrt(wgt),np.sqrt(wgt),np.sqrt(wgt)])
15 
16  b = np.dot(np.transpose(v),w)
17  s = np.transpose(b) + b
18  z = [b[2,1]-b[1,2],b[0,2]-b[2,0],b[1,0]-b[0,1]]
19  sig = np.sum(np.diagonal(b))
20 
21  k = np.zeros((4,4))
22  k[0:3,0:3] = s
23  for i in range(0,3):
24  k[i,i] = k[i,i] - sig
25  k[0:3,3] = z
26  k[3,0:3] = z
27  k[3,3] = sig
28 
29  eigval,evec = LA.eig(k) # eigen vector differs from "eval = eigenql(k,eigenvectors = evec)" IDL output in signs
30  tmpind = np.where(eigval == np.max(eigval))
31  qib = np.squeeze(evec[:,tmpind])
32 
33  return qib
def qmethod(vecb, veci, wgt)
Definition: qmethod.py:1