Circuit simulator with variable simulation time step. How to obtain FFT afterwards?
Thank you for your response. I registered to this website, so not sure if my name is the same one or not anymore, but I am the OP. 
I'm not quite sure I fully understand the solution on how the resampling and interpolation can help me. If I downsample (let's say every 100th sample), I will have a 100x smaller Dataframe size, but the elements are not evenly separated, i.e. the sampling time between two samples is not constant.

If I upsample afterwards to create empty entries in my Datafra, I get my original Dataframe size. So far, so good.
But the interpolate function somehow seem not to work in my case. I'm new to Pandas, so please be patient :)

import math
import numpy as np
from scipy.fftpack import fft
import matplotlib.pyplot as plt
import pandas as pd


buckstruct = pd.read_csv('buck.txt', sep = '\\t', engine='python')
buckstruct.index = pd.to_datetime(buckstruct.index, unit='s')
buckstruct_downsampled = buckstruct.resample('100s').sum()
buckstruct_upsampled = buckstruct_downsampled.resample('10s').sum()
buckstruct_interpolated = buckstruct_upsampled.interpolate()




EDIT1: Previous contribution merged into this answer:

Thanks for your reply. Yes it's LTSpice, and thanks for the tool. I will look at it. Though it would be nice to also have a solution in Python.

Let me ask the question the other way around, since I am no expert on FFT. Maybe there is no need for this kind of workaround after all.

Given the RAW data samples from my .txt file, i.e. not resampled, interpolated or whatever, and by simply running the FFT, I receive the following FFT result:


So, I have something around 1.75 (y-Axis) at 0 (x-Axis), and something around 0.5 (y-Axis) at 300 (x-Axis).

The 300 is NOT the frequency, because the frequency of my electronic circuit is 100kHz. So I need to find a way to map the 300 in the graph to 100kHz to match my simulations. This is fairly easy if the sample rate was constant. But is it also possible if the sample rate in the .txt is non-uniform?

Thank you,

EDIT2: Solution to the problem: Translating a non-uniformed dataset into a uniformed dataset.

This can be achieved using Scipy's interpolation function. Below is a minimal working example that does not need the initial dataset, but uses 10 consecutive data samples coming from the initial dataset. As one can see, the sample time is not constant which makes it difficult to perform a FFT and to extract the frequencies. Using the interpolation function, constant sample time can be achieved and the resulting data set can be used for FFT calculation. The procedure is to obtain the interpolation function first, and then for a given data length to perform the actual interpolation and to use the interpolated data set for FFT purposes. I hope this minimum working example can be useful for others.
Thank you,



# Minimum working example to show the effectiveness of the interpolation function

import matplotlib.pyplot as plt
from scipy import interpolate
import numpy as np

time_raw = [0.0009999650511607746,
 0.000999965566641282,
 0.0009999660821217893,
 0.0009999672947956213,
 0.0009999682836389868,
 0.0009999696068367931,
 0.0009999715724226046,
 0.000999978044536965,
 0.0009999994033983994,
 0.001]

signal_raw = [1.132772,
 1.132642,
 1.132511,
 1.132205,
 1.1319549999999998,
 1.13162,
 1.131124,
 1.1294879999999998,
 1.124091,
 1.12394]

fxxx = interpolate.interp1d(time_raw, signal_raw)

num = len(time_raw)
xx = np.linspace(time_raw[0], time_raw[-1], num)
yy = fxxx(xx)

plt.figure(1)
plt.plot(time_raw, signal_raw,'bo-', label='Original')
plt.plot(xx,yy,'g.-', label='Interpolated')
plt.ylim([1.120, 1.135])
plt.legend();


The resulting FFT for the initial problem with the actual data set from the simulation is then as expected. My apologies for this messy thread.