code: def sphere2cart(r, theta, phi):
      """Spherical to Cartesian coordinates
  
      This is the standard physics convention where `theta` is the
      inclination (polar) angle, and `phi` is the azimuth angle.
  
      Imagine a sphere with center (0,0,0).  Orient it with the z axis
      running south-north, the y axis running west-east and the x axis
      from posterior to anterior.  `theta` (the inclination angle) is the
      angle to rotate from the z-axis (the zenith) around the y-axis,
      towards the x axis.  Thus the rotation is counter-clockwise from the
      point of view of positive y.  `phi` (azimuth) gives the angle of
      rotation around the z-axis towards the y axis.  The rotation is
      counter-clockwise from the point of view of positive z.
  
      Equivalently, given a point P on the sphere, with coordinates x, y,
      z, `theta` is the angle between P and the z-axis, and `phi` is
      the angle between the projection of P onto the XY plane, and the X
      axis.
  
      Geographical nomenclature designates theta as 'co-latitude', and phi
      as 'longitude'
  
      Parameters
      ----------
      r : array_like
         radius
      theta : array_like
         inclination or polar angle
      phi : array_like
         azimuth angle
  
      Returns
      -------
      x : array
         x coordinate(s) in Cartesian space
      y : array
         y coordinate(s) in Cartesian space
      z : array
         z coordinate
  
      Notes
      -----
      See these pages:
  
      * https://en.wikipedia.org/wiki/Spherical_coordinate_system
      * https://mathworld.wolfram.com/SphericalCoordinates.html
  
      for excellent discussion of the many different conventions
      possible.  Here we use the physics conventions, used in the
      wikipedia page.
  
      Derivations of the formulae are simple. Consider a vector x, y, z of
      length r (norm of x, y, z).  The inclination angle (theta) can be
      found from: cos(theta) == z / r -> z == r * cos(theta).  This gives
      the hypotenuse of the projection onto the XY plane, which we will
      call Q. Q == r*sin(theta). Now x / Q == cos(phi) -> x == r *
      sin(theta) * cos(phi) and so on.
  
      We have deliberately named this function ``sphere2cart`` rather than
      ``sph2cart`` to distinguish it from the Matlab function of that
      name, because the Matlab function uses an unusual convention for the
      angles that we did not want to replicate.  The Matlab function is
      trivial to implement with the formulae given in the Matlab help.
  
      """
      sin_theta = np.sin(theta)
      x = r * np.cos(phi) * sin_theta
      y = r * np.sin(phi) * sin_theta
      z = r * np.cos(theta)
      x, y, z = np.broadcast_arrays(x, y, z)
      return x, y, z
  
imports: import itertools
  import math
  import numpy
  import numpy.linalg
label_desc: Use image node_id 1 for calling a global function with example usage: sphere2cart(r, theta, phi) and returns: x,  y,  z