def interpolate(self, tres="<STR_LIT>", fres="<STR_LIT>", logf=False,<EOL>outseg=None):
from scipy.interpolate import (interp2d, InterpolatedUnivariateSpline)<EOL>from ..spectrogram import Spectrogram<EOL>if outseg is None:<EOL><INDENT>outseg = self.energies[<NUM_LIT:0>].span<EOL><DEDENT>frequencies = self.plane.frequencies<EOL>dtype = self.energies[<NUM_LIT:0>].dtype<EOL>if tres == "<STR_LIT>":<EOL><INDENT>tres = abs(Segment(outseg)) / <NUM_LIT><EOL><DEDENT>xout = numpy.arange(*outseg, step=tres)<EOL>nx = xout.size<EOL>ny = frequencies.size<EOL>out = Spectrogram(numpy.empty((nx, ny), dtype=dtype),<EOL>t0=outseg[<NUM_LIT:0>], dt=tres, frequencies=frequencies)<EOL>out.q = self.plane.q<EOL>for i, row in enumerate(self.energies):<EOL><INDENT>xrow = numpy.arange(row.x0.value, (row.x0 + row.duration).value,<EOL>row.dx.value)<EOL>interp = InterpolatedUnivariateSpline(xrow, row.value)<EOL>out[:, i] = interp(xout).astype(dtype, casting="<STR_LIT>",<EOL>copy=False)<EOL><DEDENT>if fres is None:<EOL><INDENT>return out<EOL><DEDENT>interp = interp2d(xout, frequencies, out.value.T, kind='<STR_LIT>')<EOL>if not logf:<EOL><INDENT>if fres == "<STR_LIT>":<EOL><INDENT>fres = <NUM_LIT><EOL><DEDENT>outfreq = numpy.arange(<EOL>self.plane.frange[<NUM_LIT:0>], self.plane.frange[<NUM_LIT:1>], fres,<EOL>dtype=dtype)<EOL><DEDENT>else:<EOL><INDENT>if fres == "<STR_LIT>":<EOL><INDENT>fres = <NUM_LIT><EOL><DEDENT>logfmin = numpy.log10(self.plane.frange[<NUM_LIT:0>])<EOL>logfmax = numpy.log10(self.plane.frange[<NUM_LIT:1>])<EOL>outfreq = numpy.logspace(logfmin, logfmax, num=int(fres))<EOL><DEDENT>new = type(out)(<EOL>interp(xout, outfreq).T.astype(<EOL>dtype, casting="<STR_LIT>", copy=False),<EOL>t0=outseg[<NUM_LIT:0>], dt=tres, frequencies=outfreq,<EOL>)<EOL>new.q = self.plane.q<EOL>return new<EOL>
Interpolate this `QGram` over a regularly-gridded spectrogram

        Parameters
        ----------
        tres : `float`, optional
            desired time resolution (seconds) of output `Spectrogram`,
            default is `abs(outseg) / 1000.`

        fres : `float`, `int`, `None`, optional
            desired frequency resolution (Hertz) of output `Spectrogram`,
            or, if ``logf=True``, the number of frequency samples;
            give `None` to skip this step and return the original resolution,
            default is 0.5 Hz or 500 frequency samples

        logf : `bool`, optional
            boolean switch to enable (`True`) or disable (`False`) use of
            log-sampled frequencies in the output `Spectrogram`

        outseg : `~gwpy.segments.Segment`, optional
            GPS `[start, stop)` segment for output `Spectrogram`,
            default is the full duration of the input

        Returns
        -------
        out : `~gwpy.spectrogram.Spectrogram`
            output `Spectrogram` of normalised Q energy

        See Also
        --------
        scipy.interpolate
            this method uses `~scipy.interpolate.InterpolatedUnivariateSpline`
            to cast all frequency rows to a common time-axis, and then
            `~scipy.interpolate.interp2d` to apply the desired frequency
            resolution across the band

        Notes
        -----
        This method will return a `Spectrogram` of dtype ``float32`` if
        ``norm`` is given, and ``float64`` otherwise.

        To optimize plot rendering with `~matplotlib.axes.Axes.pcolormesh`,
        the output `~gwpy.spectrogram.Spectrogram` can be given a log-sampled
        frequency axis by passing `logf=True` at runtime. The `fres` argument
        is then the number of points on the frequency axis. Note, this is
        incompatible with `~matplotlib.axes.Axes.imshow`.

        It is also highly recommended to use the `outseg` keyword argument
        when only a small window around a given GPS time is of interest.