assuming you want your output center location to be in the form (lat, lon), shouldn't you switch the ordering of your return statements?
i.e: return (atan2(z, sqrt(x * x + y * y)), atan2(y, x))
A very useful function, thank you.
Just a note, most Geolocation API deals latitude and longitude in degrees.
So in most cases, you have to use radians() for the input and degrees() for the output (those two functions are in Python math library).