0
$\begingroup$

I have a csv file of data sampled with Ts=1ns which looks like this: enter image description here

This signal is a step response of some system which responds to a step of value 1. I'm trying to get the impedance profile of the signal by using $$ Z\left( f \right)=\frac{V\left( f \right)}{I\left( f \right)}=\mathcal{F}\left\{ \frac{1}{A}\frac{\partial }{\partial t}v\left( t \right) \right\} $$ The signal is noisy and needs filtering, so i'm separating the droop part from the non-droop part and filtering them independently using savgol filter. enter image description here

Than, i'm applying FFT on each of the signal parts above using the following code:

n = 1024
from scipy.fftpack import diff
frqs = np.fft.fftfreq(n, d=1.0 * 1.e-9)[range(n // 2)]
Y = np.fft.fft(diff(data_y, order=1), n=n, norm='ortho')  # fft computing and normalization
Y = abs(Y[range(len(frqs) // 2)])
return frqs, Y

Next, I take the high frequencies from the FFT applied on the droop part and the rest from the non-droop part and I stitch the results and plot them in log scale. We get a result with expected shape as below: enter image description here

Now, the problem arise when we change the droop part to be longer (and thus, the non-droop part to be shorter) as seen here:

enter image description here

The output of this looks like this:

enter image description here

The noisy shape is expected, but the amplitude is changing drastically and I can't figure out why. can someone point what the problems are are help with a solution?

Thanks!

$\endgroup$
0
$\begingroup$

I believe you need to scale by the sample period $\Delta T$ properly in your differentiator (divide by $\Delta T$) if your time units are in seconds not samples.

Your differentiator can be arrived at by using the backward Euler approximation of a continuous time differentiation.

The mapping from s to z using the backward Euler

$$s \leftrightarrow \frac{1-z^{-1}}{\Delta T}$$

$1-z^{-1}$ is simply subtracting the past sample from the current sample. To maintain your time axis in seconds, divide by $\Delta T$. If your time axis is in samples (as we often do), the $\Delta T=1$ and further scaling is not needed.

Similarly an integrator which is $1/s$ would be multiplied by $\Delta T$. For all other mappings you see the same $\Delta T$ appear, just as it exists as $dt$ in the continuous time equations.

$\endgroup$
  • $\begingroup$ the time axis is in nano seconds. How exactly do I approach this in the code? $\endgroup$ – Aviv Azran May 2 '20 at 8:46
  • $\begingroup$ Delta T is the time duration between samples or the inverse of your sample rate, so just multiply by your sample rate when you take the difference between samples. You only take the difference once to get your new result so you just need to multiply your result by the sampling rate. $\endgroup$ – Dan Boschen May 2 '20 at 11:05
  • $\begingroup$ But that doesn’t seem right looking at your data as your issue is the answer went from 0.1 to 0.5 so you got an increase factor of 5 you are trying to track down? $\endgroup$ – Dan Boschen May 2 '20 at 11:07
0
$\begingroup$

So I solved it eventually. The root of the problem wasn't in the fft to start with. I've changed np.diff(data) to np.gradient(data) and the amplitudes were consistent. Thanks!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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