I am working with data from a TeraFlash THz Spectrometer from Toptica, which gives me the pulse in the time domain and the spectrum in the frequency domain

I have been experimenting with the FFT to get to the spectrum myself and I see some discrepancies compared to the spectrum from the software. The manufacturer told me that they use an adapted blackman window that only changes the first pulse sample and the last two pulse samples, so I assume that everything in-between will be weighted with 1 and only the beginning and end will have a smooth transition to 0. Apparently, this is done such that the pulse will not be altered by the window if it is not centered.

In the attached plot I have included the window (adapted blackman window) as well as the pulse and the two spectra (the software's and mine). I am particularly interested in the absorption lines in the spectrum that are not identical between the two calculation methods...

As I am new to DSP, I am not sure if this is a significant difference or if both spectra should suffice. In this setup, only the absorption lines air (mainly water) are visible, but for further measurements I am interested in the absorption lines of different materials.

EDIT: the other window functions shown in the legend of the plot result in even more discrepancies than the adapted blackman window, thus I chose not to show them.

enter image description here

I used numpy FFT calculation:

def get_fft(t, p, padding=True):
    if padding:
        t, p = zero_padding(t, p)  # apply zero padding to get 100001 datapoints on the spectrum
    p = p * blackman(len(t))  # apply blackman window
    SAMPLE_RATE = len(t) / (t[-1] - t[0]) * 1e12
    N = len(p)
    a = np.abs(rfft(p))
    f = rfftfreq(N, 1 / SAMPLE_RATE) / 1e12
    return f, a
  • 1
    $\begingroup$ Since there is no stated question, I'm assuming you're asking us to figure out why the software's and yours' FFT give different results. As such, please include your implementation so we can see if there's anything off there. Might be worth showing the results with a window that gives you the MOST difference, to help identify what the problem is. The only thing I can tell you is that both spectra look VERY similar, so I'm guessing there's a VERY slight difference in the two implementations, and yes, both spectra should suffice, but that's about it. $\endgroup$
    – Jdip
    Aug 19, 2022 at 9:57
  • $\begingroup$ Thanks for the reply and edit suggestions! I added a new plot and my implementation (sorry that the color scheme is not the same for both plots). What bothers me is the different extend to certain absorption lines... for example the one shortly before 2 THz is less visible in the software's spectrum - however all other significant absorption lines seem more dominant.. $\endgroup$
    – lazerlini
    Aug 19, 2022 at 10:06
  • $\begingroup$ It might be hard to figure this out without access to the software, but have you tried squaring your fft magnitude (this would give you the Power Spectral Density)? Then there might be a scaling issue: scaling the PSD. Finally, not familiar with the application at all, but this looks to me to be in the log-scale ($10*\log_{10}()$) $\endgroup$
    – Jdip
    Aug 19, 2022 at 10:35
  • 1
    $\begingroup$ Ah, sorry for the confusion. Ok then because your results are so similar, I'm guessing your Blackman implementation is slightly different from theirs. What does your modified Blackman window look like? The other thing I can think of is that under the hood, the software might be using zero-padding to make the length of the DFT a power of 2, effectively modifying the frequency precision. Please edit out the second plot showing the hamming window, it has no value here (my bad!) and replace the code portion with the Blackman window to avoid confusing others ;) $\endgroup$
    – Jdip
    Aug 19, 2022 at 11:29
  • 1
    $\begingroup$ If you're still struggling, let's keep this going here: chat.stackexchange.com/rooms/138629/toptica-fft $\endgroup$
    – Jdip
    Aug 19, 2022 at 11:35

1 Answer 1

  1. The modified Blackman would have higher side-lobes that traditional Hamming or Hann or regular Blackman windows, so more spectral leakage, which tells me your software isn't too worried about lower-valued fft coefficients (loss of weak components shadowed by neighboring stronger ones). If you are worried about that, I'd suggest using a window with more taper.
  2. Your results are so close that I'm guessing your implementation of the modified Blackman window is slightly different from theirs. Maybe try playing around with how many samples you taper at the start and end of the window.
  3. I wouldn't worry too much about trying to match exactly the software's black-box. Clearly your implementation is correct, just not exactly the same as theirs.
  • $\begingroup$ very good point with the taper - I experimented and noticed that if I change the adaptation to be in the first ps and in the last 7 ps it resembles the one of the Toptica software much closer! Thanks! $\endgroup$
    – lazerlini
    Aug 19, 2022 at 13:09
  • $\begingroup$ Great, glad I could help :) $\endgroup$
    – Jdip
    Aug 19, 2022 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.