Units after fourier transform of barrier - fft

Suppose you have a voltage pulse: V(x) = v for x in [-L/2, L,2] else V(x)=0. The volatage has unit [V]. If you do a Fourier transform of this signal you get:
V(k) = v*L sinc(piLk)
After the Fourier transform, the voltage has unit [Vm] because the unit of L is [m]. However, if I search on the internet then I find results that the unit does not change after Fourier transformation (which sounds also more logical to me)...
Concrete: what is the unit of my voltage pulse after Fourier transformation?

After a fft you no longer have voltage, instead you have an array where each element represents a frequency and the value of each array element is a complex number to which you can obtain the magnitude 0<->1 of the strength of that frequency along with the phase shift of that frequency
Interestingly with this fft output you can perform an inverse fft call to return back to you your original signal, in your case your voltage pulse train

Related

How to calculate spectrum-weighted mean period using Fourier Transform?

I am using EMD algorithm to extract the IMFs of a signal. Now, this signal may contain noise which lessens the significance of the IMFs. To calculate the spread function, the spectrum-weighted mean period has to be calculated using the Fourier spectrum as a function of the natural log of the period. My question is twofold.
Firstly, I am confused about the term Fourier spectrum. Is it Energy spectral density or Power spectral density?
Secondly how to estimate the integral using the formulation "Wu and Huang".
http://rspa.royalsocietypublishing.org/content/460/2046/1597.

DM Script, why does the fourier transform of gaussian-kenel needs modulus

Recently I learn DM_Script for TEM image processing
I needed Gaussian blur process and I found one whose name is 'Gaussian Blur' in http://www.dmscripting.com/recent_updates.html
This code implements Gaussian blur algorithm by multiplying the fast fourier transform(FFT) of source image by the FFT of Gaussian-kernel image and finally doing inverse fourier transform of it.
Here is the part of the code,
// Carry out the convolution in Fourier space
compleximage fftkernelimg:=realFFT(kernelimg) (-> FFT of Gaussian-kernel image)
compleximage FFTSource:=realfft(warpimg) (-> FFT of source image)
compleximage FFTProduct:=FFTSource*fftkernelimg.modulus().sqrt()
realimage invFFT:=realIFFT(FFTProduct)
The point I want to ask is this
compleximage FFTProduct:=FFTSource*fftkernelimg.modulus().sqrt()
Why does the FFT of Gaussian-kernel need '.modulus().sqrt()' for the convolution?
It is related to the fact that the fourier transform of a Gaussian function becomes another Gaussian function?
Or It is related to a sort of limitation of discrete fourier transform?
Please answer me
Thanks
This is related to the general precision limitation of any floating point numeric computing. (see f.e. here, or more in depth here)
A rotational (real-valued) Gaussian of stand.dev. sigma should be transformed into a 100% real-values rotational Gaussioan of 1/sigma. However, doing this numerically will show you deviations: Just try the following:
number sigma = 30
number A0 = 1
realimage first := RealImage( "First", 8, 256, 256 )
first = A0 * exp( - (iradius**2/(2*sigma*sigma) ))
first.showimage()
complexImage second := FFT(first)
second.Showimage()
image nonZeroImaginaryMask = ( 0 != second.Imaginary() )
nonZeroImaginaryMask.Showimage()
nonZeroImaginaryMask.SetLimits(0,1)
When you then multiply these complex images (before back-transferring) you are introducing even more errors. By using modulus, one ensures that the forward transformed kernel is purely real and hence a better "damping" curve.
A better implementation of a FFT filtering code would actually create the FFT(Gaussian) directly with a std.dev of 1/sigma, as this is the analytically correct result. Doing a FFT of the kernel only makes sense if the kernel (or its FFT) is not analytically known.
In general: When implementing any "maths" into a program code, it can pay hugely to think it through with numerical computation limits in the back of your head. Reduce actual computation whenever possible (i.e. compute analytically and use the result instead of relying on brute force numerical computation) and try to "reshape" equations when possible, f.e. avoid large sums over many small numbers, be careful about checks against exact numeric values, try to avoid expressions which are very sensitive on small numerica errors etc.

Why does fftw3 inverse fourier transform's produces output vector of type double?

I want to take inverse fourier transform of a signal. I use this
fftw_plan_dft_c2r_1d
however, the output vector is required to be double. The question is isn't that the IFFT of a signal gives complex number result?
The definition of the Discrete Fourier Transform (DFT) allows for the time-domain input to be a complex valued signal and produces a frequency-domain result which is in general also complex valued. Correspondingly the inverse transform of that complex-valued frequency-domain result would produce the same (or at least within the available implementation's numerical precision) original time-domain signal. The result of the inverse transform could thus be complex.
Just the same, if we restrict time-domain inputs of the forward transform to real-valued signals then we would similarly expect the inverse transform of the corresponding frequency-domain spectrum to give us back the same original real-valued signal.
Note that the forward transform of those real-valued signal produces a frequency domain result that exhibits Hermitian symmetry (and conversely, if a frequency domain signal has Hermitian symmetry it must be the transform of a real valued signal). fftw_plan_dft_c2r_1d then computes the inverse transform (which is real-valued and stored in double) under the assumption that the frequency domain spectrum indeed has Hermitian symmetry.

zero padded FFT using FFTW

To interpolate a signal in frequency domain, one can pad zeros in time domain and do an FFT.
Suppose the number of elements in a given vector X is N and Y is the same as X but padded one sided with N zeros. Then the following give the same result.
$$\hat{x}(k)=\sum_{n=0}^{2N-1} Y(n)e^{i2\pi k n/2N},\quad k=0,...,2N-1,$$
$$\hat{x}(k)=\sum_{n=0}^{ N-1} X(n)e^{i2\pi k n/2N},\quad k=0,...,2N-1.$$
Now if we use FFTW package, the first equation needs 2N memory space for the input vector while the second one needs only N memory space (I do not know if it is even possible to do in the existing FFTW package)! Also the computational complexity lowers from 2N^2log(2N) to 2N^2log(N). The problem is worse whenever we do a 2D FFT or 3D FFT. Is it possible to do the second approach using FFTW package? This is fairly easy to do in MATLAB though.
If x is a 2N signal padded with zeros above N , its DFT writes :
If k is even :
Hence, the coefficients of even frequencies arise from the N-point discrete Fourier transform of x(n).
if k is odd :
Hence, the coefficients of odd frequencies arise from the N-point discrete Fourier transform of x(n)exp(i*M_PI*n/N).
Thus, the discrete Fourier transform of a zero-padded 2N signal resumes to two DFT of signals of length N and fftw can be used to compute them.
The overall computation time will be 2*c*N*ln(N), where c is a constant. It is expected to be faster than the direct computation of the DFT c*2*N*ln(2*N). Remember that ln(2*N)=ln(2)+ln(N) : as N gets large, the extra work in case of direct computation is negligible compared to ln(N) : the trick becomes useless, even if the dimension is larger than one. It does not affect complexity.
Moreover, FFTW is really efficient, using lots of features of your PC if it is correctly installed, and it will be hard to do better than this in any case, even if the presented trick is used. Finally, if the input signal is real, you may use fftw_plan fftw_plan_dft_r2c_2d : only half the coefficients in the Fourier space are computed and stored.
Regarding memory requirements, if you are really short of memory, you can use the FFTW_IN_PLACE flag and use the same array for input and output. Yet, it is slightly slower.
The procedure presented above can be extended to compute the DFT of a LN signal of a N-point signal padded with (L-1)N zeros : it resumes to the computation of L DFTs of length N.
Do you have any reference showing how MATLAB handles and optimizes the DFT of padded signals compared to FFTW ?
EDIT : Further research about the 3D case :
The 3D DFT of a padded 3D signal x(n,m,p) is :
If k_n, k_m and k_p are even :
If k_n and k_m are even and k_p is odd :
...There are 8 cases.
So, the computation of the 3d dft of a 3D x of size NxNxN padded to 2Nx2Nx2N resumes to the computation of 8 3d dft of size NxNxN. Size a 3d dft is a combination of 3 1d dft, the total number of dft of size N is 3x8xNxN while the direct computation requires 3x(2N)*(2N) dft of size 2N. Computational time is 24cN^3ln(N) against 24cN^3ln(2N) : a small gain is possible...Again fftw is fast...
Yet, instead of using a black-box 3d fft, let's compute the 8 dfts of size N at once, by performing the 1d dfts in each direction.
1d dft along N : 2 cases, NxN dfts => 2cN^3ln(N)
1d dft along M : 2 cases, 2NxN dfts => 4cN^3ln(N)
1d dft along P : 2 cases, 2Nx2N dfts => 8cN^3ln(N)
Hence, the total computation time is expected to be 14cN^3ln(N) against 24cN^3ln(2N) : a small gain is possible...Again fftw is fast...
Moreover, the computation of
requires only a single call to exp : first compute w=exp(I*M_PI/N) then update wn=wn*w; x(n)=x(n)*wn or use pow if precision becomes an issue.

Convert time series to frequency domain

I have a fundamental question:
I would like to know, why this time series:
k<-c(4,5,6,2,3,1)
is equal to:
21.0+0.000000i 0.5-6.062178i -1.5-0.866025i 5.0-0.000000i -1.5+0.866025i 0.5+6.062178i
In time series I have a set of points, but what is the resault of fft , are there points?
Fourier says that any (non-pathological) waveform can be decomposed into a bunch of sinewaves. The FFT does that for reasonable samples of a given waveform.
So your FFT results are the coefficients of each sinewave sub-component: the first for 0 Hz (or DC, or sum), the 2nd for a sinewave of 1 period per aperture, the next: 2 cycles per aperture, and etc. You can consider each coefficient pair x+iy, as either a vector in the complex plane for a sinewave's magnitude and phase, or as multipliers for a cosine and a sine that sum up to another sinewave of a specified phase.