def cartesian_to_spherical(x, y, z):
    x = np.asanyarray(x)
    y = np.asanyarray(y)
    z = np.asanyarray(z)
    r = np.linalg.norm(np.vstack((x,y,z)), axis=0)
    return r, np.arccos(z/r), np.arctan(y/x)


#def spherical_to_cartesian(spherical):
    #"""
    #Convert spherical coordinates to cartesian coordinates.
    
    #.. math:: x = r \\sin{\\theta}\\cos{\\phi}
    #.. math:: y = r \\sin{\\theta}\\sin{\\phi}
    #.. math:: z = r \\cos{\\theta}
    #"""
    #r = spherical[0,:]
    #theta = spherical[1,:]
    #phi = spherical[2,:]
    #return np.vstack((
        #r * np.sin(theta) * np.cos(phi),
        #r * np.sin(theta) * np.sin(phi),
        #r * np.cos(theta)
        #))
    

#def cartesian_to_spherical(cartesian):
    #"""
    #Convert cartesian coordinates to spherical coordinates.
    
    #.. math:: r = \\sqrt{\\left( x^2 + y^2 + z^2 \\right)}
    #.. math:: \\theta = \\arccos{\\frac{z}{r}}
    #.. math:: \\phi = \\arccos{\\frac{y}{x}}
    #"""
    #x = spherical[0,:]
    #y = spherical[1,:]
    #z = spherical[2,:]
    #r = np.sqrt(np.sum(np.abs(cartesian)**2, axis=0)),
    #return np.vstack((
        #r,
        #np.arccos(z/r),
        #np.arctan(y/x)
        #))
See `theano.tensor.mean`.
dataset/ETHPy150Open python-acoustics/python-acoustics/acoustics/directivity.py/cartesian_to_spherical--crossover with--dataset/ETHPy150Open rizar/attention-lvcsr/libs/Theano/theano/tensor/var.py/_tensor_py_operators.mean