def mt_deconvolve(data_a, data_b, delta, nfft=None, time_bandwidth=None,
                  number_of_tapers=None, weights="adaptive", demean=True,
                  fmax=0.0):
    """
    Deconvolve two time series using multitapers.

    This uses the eigencoefficients and the weights from the multitaper
    spectral estimations and more or less follows this paper:

    .. |br| raw:: html

        <br />

    **Receiver Functions from Multiple-Taper Spectral Correlation Estimates**
    *Jeffrey Park, Vadim Levin* |br|
    Bulletin of the Seismological Society of America Dec 2000,
    90 (6) 1507-1520
    http://dx.doi.org/10.1785/0119990122

    :type data_a: :class:`numpy.ndarray`
    :param data_a: Data for first time series.
    :type data_b: :class:`numpy.ndarray`
    :param data_b: Data for second time series.
    :type delta: float
    :param delta: Sample spacing of the data.
    :type nfft: int
    :param nfft: Number of points for the FFT. If ``nfft == None``, no zero
        padding will be applied before the FFT.
    :type time_bandwidth: float
    :param time_bandwidth: Time-bandwidth product. Common values are 2, 3, 4,
        and numbers in between.
    :type number_of_tapers: int
    :param number_of_tapers: Number of tapers to use. Defaults to
        ``int(2*time_bandwidth) - 1``. This is maximum senseful amount. More
        tapers will have no great influence on the final spectrum but increase
        the calculation time. Use fewer tapers for a faster calculation.
    :type weights: str
    :param weights: ``"adaptive"`` or ``"constant"`` weights.
    :type deman: bool
    :param demean: Force the complex TF to be demeaned.
    :type fmax: float
    :param fmax: Maximum frequency for lowpass cosine filter. Set this to
        zero to not have a filter.

    :return: Returns a dictionary with 5 :class:`numpy.ndarray`'s. See the note
        below.

    .. note::

        Returns a dictionary with five arrays:

        * ``"deconvolved"``: Deconvolved time series.
        * ``"spectrum_a"``: Spectrum of the first time series.
        * ``"spectrum_b"``:  Spectrum of the second time series.
        * ``"spectral_ratio"``: The ratio of both spectra.
        * ``"frequencies"``: The used frequency bins for the spectra.

    """
    npts = len(data_a)
    if len(data_b) != npts:
        raise ValueError("Input arrays must have the same length!")

    if nfft is None:
        nfft = npts
    elif nfft < npts:
        raise ValueError("nfft must be larger then the number of samples in "
                         "the array.")

    # Deconvolution utilizes the 32bit version.
    mt = _MtspecType("float32")

    # Use the optimal number of tapers in case no number is specified.
    if number_of_tapers is None:
        number_of_tapers = int(2 * time_bandwidth) - 1

    # Transform the data to work with the library.
    data_a = np.require(data_a, mt.float, requirements=[mt.order])
    data_b = np.require(data_b, mt.float, requirements=[mt.order])

    nf = nfft // 2 + 1

    # Internally uses integers
    if demean:
        demean = 1
    else:
        demean = 0

    # iad = 0 are adaptive, iad = 1 are constant weight - this is
    # counter intuitive.
    if weights == "constant":
        adaptive = 1
    elif weights == "adaptive":
        adaptive = 0
    else:
        raise ValueError('Weights must be either "adaptive" or "constant".')

    tfun = mt.empty(nfft)
    freq = mt.empty(nf)
    spec_ratio = mt.empty(nf)
    speci = mt.empty(nf)
    specj = mt.empty(nf)

    mtspeclib.mt_deconv_(
        C.byref(C.c_int(int(npts))),
        C.byref(C.c_int(int(nfft))),
        C.byref(C.c_float(float(delta))),
        mt.p(data_a),
        mt.p(data_b),
        C.byref(C.c_float(float(time_bandwidth))),
        C.byref(C.c_int(int(number_of_tapers))),
        C.byref(C.c_int(int(nf))),
        C.byref(C.c_int(adaptive)),
        mt.p(freq),
        mt.p(tfun),
        mt.p(spec_ratio),
        mt.p(speci),
        mt.p(specj),
        C.byref(C.c_int(demean)),
        C.byref(C.c_float(fmax)))

    return {
        "frequencies": freq,
        "deconvolved": tfun,
        "spectral_ratio": spec_ratio,
        "spectrum_a": speci,
        "spectrum_b": specj
    }