code: def quad(sPJ0r, sPJ0i, sPJ1r, sPJ1i, sPJ0br, sPJ0bi, ab, off, factAng, iinp):
      r
      def quad_PJ0(klambd, sPJ0, koff):
  r
          return sPJ0(np.log(klambd))*special.j0(koff*klambd)
      def quad_PJ1(klambd, sPJ1, ab, koff, kang):
  r
          tP1 = kang*sPJ1(np.log(klambd))
          if ab in [11, 12, 21, 22, 14, 24, 15, 25]:
              tP1 /= koff
          return tP1*special.j1(koff*klambd)
      def quad_PJ0b(klambd, sPJ0b, koff, kang):
  r
          return kang*sPJ0b(np.log(klambd))*special.j0(koff*klambd)
      conv = True
      out = np.array(0.0+0.0j)
      iinp['full_output'] = 1
      if sPJ0r is not None:
          re = integrate.quad(quad_PJ0, args=(sPJ0r, off), **iinp)
          im = integrate.quad(quad_PJ0, args=(sPJ0i, off), **iinp)
          out += re[0] + 1j*im[0]
          if (len(re) or len(im)) > 3:
              conv = False
      if sPJ1r is not None:
          re = integrate.quad(quad_PJ1, args=(sPJ1r, ab, off, factAng), **iinp)
          im = integrate.quad(quad_PJ1, args=(sPJ1i, ab, off, factAng), **iinp)
          out += re[0] + 1j*im[0]
          if (len(re) or len(im)) > 3:
              conv = False
      if sPJ0br is not None:
          re = integrate.quad(quad_PJ0b, args=(sPJ0br, off, factAng), **iinp)
          im = integrate.quad(quad_PJ0b, args=(sPJ0bi, off, factAng), **iinp)
          out += re[0] + 1j*im[0]
          if (len(re) or len(im)) > 3:
              conv = False
      return out, conv