code: def impulse_deltav_general_curvedstream(v,x,b,w,x0,v0,pot):
      
      pot= flatten_potential(pot)
      if len(v.shape) == 1: v= numpy.reshape(v,(1,3))
      if len(x.shape) == 1: x= numpy.reshape(x,(1,3))
      b0 = numpy.cross(w,v0)
      b0 *= b/numpy.sqrt(numpy.sum(b0**2))
      b_ = b0+x-x0
      return numpy.array(list(map(lambda i:_deltav_integrate(0.,i[1],i[0],pot)
                          ,zip(w-v,b_))))
docs: NAME:
  
         impulse_deltav_general_curvedstream
  
      PURPOSE:
  
         calculate the delta velocity to due an encounter with a general spherical potential in the impulse approximation; allows for arbitrary velocity vectors and arbitrary shaped streams
  
      INPUT:
  
         v - velocity of the stream (nstar,3)
  
         x - position along the stream (nstar,3)
  
         b - impact parameter
  
         w - velocity of the subhalo (3)
  
         x0 - position of closest approach (3)
  
         v0 - velocity of stream at closest approach (3)
  
         pot - Potential object or list thereof (should be spherical)
  
      OUTPUT:
  
         deltav (nstar,3)
  
      HISTORY:
  
         2015-05-04 - SANDERS
  
         2015-06-15 - Tweak to use galpy' potential objects - Bovy (IAS)