def cart2sph(z, y, x):
 width = len(z)
 elevation = numpy.empty([width, width])
 radius = numpy.empty([width, width])
 azimuth = numpy.empty([width, width])
 radius = numpy.sqrt((((x ** 2) + (y ** 2)) + (z ** 2)))
 azimuth = numpy.arctan2(y, x)
 elevation = numpy.arctan2(z, numpy.sqrt(((x ** 2) + (y ** 2))))
 azimuth *= (180.0 / numpy.pi)
 elevation *= (180.0 / numpy.pi)
 sphere = numpy.array([elevation, azimuth, radius])
 sphere = numpy.rollaxis(sphere, 0, 3)
 return sphere

def cart2sph ( z , y , x ) : width = len ( z ) elevation = numpy . empty ( [ width , width ] ) radius = numpy . empty ( [ width , width ] ) azimuth = numpy . empty ( [ width , width ] ) radius = numpy . sqrt ( ( ( ( x ** 2 ) + ( y ** 2 ) ) + ( z ** 2 ) ) ) azimuth = numpy . arctan2 ( y , x ) elevation = numpy . arctan2 ( z , numpy . sqrt ( ( ( x ** 2 ) + ( y ** 2 ) ) ) ) azimuth *= ( 180.0 / numpy . pi ) elevation *= ( 180.0 / numpy . pi ) sphere = numpy . array ( [ elevation , azimuth , radius ] ) sphere = numpy . rollaxis ( sphere , 0 , 3 ) return sphere
convert from cartesian coordinates to spherical .