def MorletVec (sig, sampr, freq, width, m=None, getphase=False):
  """ Final units of y: signal units squared. For instance, a signal of Am would have Am^2
  The energy is calculated using Morlet's wavelets; also returns phase when getphase==True
  sig: input signal
  sampr: sampling rate (Hz)
  freq: frequency
  m: Morlet wavelet        
  width: number of cycles of Morlet wavelet
  """
  # calculate the morlet wavelet for this frequency
  # units of m are 1/s
  if m is None: m = Morlet(sampr, freq, width)
  # convolve wavelet with signal
  y = sps.fftconvolve(sig, m)
  if getphase: phs = np.angle(y) # get phase too?
  # take the power ...
  y = (2. * abs(y) / sampr)**2.
  i_lower = int(np.ceil(len(m) / 2.))
  i_upper = int(len(y) - np.floor(len(m) / 2.)+1)
  if getphase: return y[i_lower:i_upper], phs[i_lower:i_upper]
  else: return y[i_lower:i_upper]
Final units of y: signal units squared. For instance, a signal of Am would have Am^2
  The energy is calculated using Morlet's wavelets; also returns phase when getphase==True
  sig: input signal
  sampr: sampling rate (Hz)
  freq: frequency
  m: Morlet wavelet        
  width: number of cycles of Morlet wavelet