code: def qseries(fseries, Q, f0, return_complex=False):
      
      # normalize and generate bi-square window
      qprime = Q / 11**(1/2.)
      norm = numpy.sqrt(315. * qprime / (128. * f0))
      window_size = 2 * int(f0 / qprime * fseries.duration) + 1
      xfrequencies = numpy.linspace(-1., 1., window_size)
  
      start = int((f0 - (f0 / qprime)) * fseries.duration)
      end = int(start + window_size)
      center = (start + end) / 2
  
      windowed = fseries[start:end] * (1 - xfrequencies ** 2) ** 2 * norm
  
      tlen = (len(fseries)-1) * 2
      windowed.resize(tlen)
      windowed.roll(-center)
  
      # calculate the time series for this q -value
      windowed = FrequencySeries(windowed, delta_f=fseries.delta_f,
                              epoch=fseries.start_time)
      ctseries = TimeSeries(zeros(tlen, dtype=numpy.complex128),
                              delta_t=fseries.delta_t)
      ifft(windowed, ctseries)
  
      if return_complex:
          return ctseries
      else:
          energy = ctseries.squared_norm()
          medianenergy = numpy.median(energy.numpy())
          return  energy / float(medianenergy)
docs: Calculate the energy 'TimeSeries' for the given fseries
  
      Parameters
      ----------
      fseries: 'pycbc FrequencySeries'
          frequency-series data set
      Q:
          q value
      f0:
          central frequency
      return_complex: {False, bool}
          Return the raw complex series instead of the normalized power.
  
      Returns
      -------
      energy: '~pycbc.types.TimeSeries'
          A 'TimeSeries' of the normalized energy from the Q-transform of
          this tile against the data.