Skip to content

Instantly share code, notes, and snippets.

@dfm
Created June 22, 2011 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dfm/1041170 to your computer and use it in GitHub Desktop.
Save dfm/1041170 to your computer and use it in GitHub Desktop.
For Aukosh
from numpy import array,sin,cos,cov
import numpy.random as random
def obs_to_xyz(obs):
D,th,phi,vr,vth,vphi = tuple(obs)
sth,cth = sin(th),cos(th)
sphi,cphi = sin(phi),cos(phi)
return [D*sth*cphi,
D*sth*sphi,
D*cth,
vr*sth*cphi + vth*cth*cphi - vphi*sphi,
vr*sth*sphi + vth*cth*sphi + vphi*cphi,
vr*cth - vth*sth]
N = 10000
random.seed()
obs = 10.0+random.randn(6*N).reshape((N,6))
print cov(obs)
xyz = []
for o in obs:
xyz.append(obs_to_xyz(o))
xyz = array(xyz)
print cov(xyz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment