def phaseSpaceToAstrometry(x, y, z, vx, vy, vz):
u, phi, theta = cartesianToSpherical(x, y, z)<EOL>parallax = _auMasParsec/u<EOL>p, q, r = normalTriad(phi, theta)<EOL>velocitiesArray=array([vx,vy,vz])<EOL>if  isscalar(u):<EOL><INDENT>muphistar=dot(p,velocitiesArray)*parallax/_auKmYearPerSec<EOL>mutheta=dot(q,velocitiesArray)*parallax/_auKmYearPerSec<EOL>vrad=dot(r,velocitiesArray)<EOL><DEDENT>else:<EOL><INDENT>muphistar=zeros_like(parallax)<EOL>mutheta=zeros_like(parallax)<EOL>vrad=zeros_like(parallax)<EOL>for i in range(parallax.size):<EOL><INDENT>muphistar[i]=dot(p[:,i],velocitiesArray[:,i])*parallax[i]/_auKmYearPerSec<EOL>mutheta[i]=dot(q[:,i],velocitiesArray[:,i])*parallax[i]/_auKmYearPerSec<EOL>vrad[i]=dot(r[:,i],velocitiesArray[:,i])<EOL><DEDENT><DEDENT>return phi, theta, parallax, muphistar, mutheta, vrad<EOL>
From the given phase space coordinates calculate the astrometric observables, including the radial
velocity, which here is seen as the sixth astrometric parameter. The phase space coordinates are
assumed to represent barycentric (i.e. centred on the Sun) positions and velocities.

This function has no mechanism to deal with units. The velocity units are always assumed to be km/s,
and the code is set up such that for positions in pc, the return units for the astrometry are radians,
milliarcsec, milliarcsec/year and km/s. For positions in kpc the return units are: radians,
microarcsec, microarcsec/year, and km/s.

NOTE that the doppler factor k=1/(1-vrad/c) is NOT used in the calculations. This is not a problem for
sources moving at typical velocities of Galactic stars.

Parameters
----------

x - The x component of the barycentric position vector (in pc or kpc).
y - The y component of the barycentric position vector (in pc or kpc).
z - The z component of the barycentric position vector (in pc or kpc).
vx - The x component of the barycentric velocity vector (in km/s).
vy - The y component of the barycentric velocity vector (in km/s).
vz - The z component of the barycentric velocity vector (in km/s).

Returns
-------

phi       - The longitude-like angle of the position of the source (radians).
theta     - The latitude-like angle of the position of the source (radians).
parallax  - The parallax of the source (in mas or muas, see above)
muphistar - The proper motion in the longitude-like angle, multiplied by cos(theta) (mas/yr or muas/yr,
see above)
mutheta   - The proper motion in the latitude-like angle (mas/yr or muas/yr, see above)
vrad      - The radial velocity (km/s)