code: def newsnr(snr, reduced_x2, q=6., n=2.):
      
      nsnr = numpy.array(snr, ndmin=1, dtype=numpy.float64)
      reduced_x2 = numpy.array(reduced_x2, ndmin=1, dtype=numpy.float64)
  
      # newsnr is only different from snr if reduced chisq > 1
      ind = numpy.where(reduced_x2 > 1.)[0]
      nsnr[ind] *= (0.5 * (1. + reduced_x2[ind] ** (q/n))) ** (-1./q)
  
      # If snr input is float, return a float. Otherwise return numpy array.
      if hasattr(snr, '__len__'):
          return nsnr
      else:
          return nsnr[0]
docs: Calculate the re-weighted SNR statistic ('newSNR') from given SNR and
      reduced chi-squared values. See http://arxiv.org/abs/1208.3491 for
      definition. Previous implementation in glue/ligolw/lsctables.py