<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fftgram(self, fftlength, overlap=None, window='hann', **kwargs):
 """Calculate the Fourier-gram of this `TimeSeries`. At every ``stride``, a single, complex FFT is calculated. Parameters fftlength : `float` number of seconds in single FFT. overlap : `float`, optional number of seconds of overlap between FFTs, defaults to the recommended overlap for the given window (if given), or 0 window : `str`, `numpy.ndarray`, optional window function to apply to timeseries prior to FFT, see :func:`scipy.signal.get_window` for details on acceptable Returns ------- a Fourier-gram """

        from ..spectrogram import Spectrogram
        try:
            from scipy.signal import spectrogram
        except ImportError:
            raise ImportError("Must have scipy>=0.16 to utilize "
                              "this method.")

        # format lengths
        if isinstance(fftlength, units.Quantity):
            fftlength = fftlength.value

        nfft = int((fftlength * self.sample_rate).decompose().value)

        if not overlap:
            # use scipy.signal.spectrogram noverlap default
            noverlap = nfft // 8
        else:
            noverlap = int((overlap * self.sample_rate).decompose().value)

        # generate output spectrogram
        [frequencies, times, sxx] = spectrogram(self,
                                                fs=self.sample_rate.value,
                                                window=window,
                                                nperseg=nfft,
                                                noverlap=noverlap,
                                                mode='complex',
                                                **kwargs)
        return Spectrogram(sxx.T,
                           name=self.name, unit=self.unit,
                           xindex=self.t0.value + times,
                           yindex=frequencies)