docs: def filtmask(sp, fmin=0.02, fmax=0.15, debugplot=0):
      """Filter spectrum in Fourier space and apply cosine bell.
  
      Parameters
      ----------
      sp : numpy array
          Spectrum to be filtered and masked.
      fmin : float
          Minimum frequency to be employed.
      fmax : float
          Maximum frequency to be employed.
      debugplot : int
          Debugging level for messages and plots. For details see
          'numina.array.display.pause_debugplot.py'.
  
      Returns
      -------
      sp_filtmask : numpy array
          Filtered and masked spectrum
  
      """
  
      # Fourier filtering
      xf = np.fft.fftfreq(sp.size)
      yf = np.fft.fft(sp)
      if abs(debugplot) in (21, 22):
          iok = np.where(xf > 0)
          ximplotxy(xf[iok], yf[iok].real,
                    plottype='loglog',
                    xlabel='frequency', ylabel='power',
                    title='before masking', debugplot=debugplot)
  
      cut = (np.abs(xf) > fmax)
      yf[cut] = 0.0
      cut = (np.abs(xf) < fmin)
      yf[cut] = 0.0
      if abs(debugplot) in (21, 22):
          iok = np.where(xf > 0)
          ximplotxy(xf[iok], yf[iok].real,
                    plottype='loglog',
                    xlabel='frequency', ylabel='power',
                    title='after masking', debugplot=debugplot)
  
      sp_filt = np.fft.ifft(yf).real
      if abs(debugplot) in (21, 22):
          xdum = np.arange(1, sp_filt.size + 1)
          ximplotxy(xdum, sp_filt, title="filtered median spectrum",
                    debugplot=debugplot)
  
      sp_filtmask = sp_filt * cosinebell(sp_filt.size, 0.1)
      if abs(debugplot) in (21, 22):
          xdum = np.arange(1, sp_filt.size + 1)
          ximplotxy(xdum, sp_filtmask,
                    title="filtered and masked median spectrum",
                    debugplot=debugplot)
  
      return sp_filtmask