def sphericalToCartesian(r, phi, theta):
ctheta=cos(theta)<EOL>x=r*cos(phi)*ctheta<EOL>y=r*sin(phi)*ctheta<EOL>z=r*sin(theta)<EOL>return x, y, z<EOL>
Convert spherical to Cartesian coordinates. The input can be scalars or 1-dimensional numpy arrays.
Note that the angle coordinates follow the astronomical convention of using elevation (declination,
latitude) rather than its complement (pi/2-elevation), where the latter is commonly used in the
mathematical treatment of spherical coordinates.

Parameters
----------

r     - length of input Cartesian vector.
phi   - longitude-like angle (e.g., right ascension, ecliptic longitude) in radians
theta - latitide-like angle (e.g., declination, ecliptic latitude) in radians

Returns
-------

The Cartesian vector components x, y, z