# Generate time domain signal from frequency domain filter

I am familiar with using the Fourier transform to take a signal from the time domain to the frequency domain. What I would like to do is the reverse: describe a signal in the frequency domain and then take the IFT to generate the time domain signal.

Explicitly, I want to take a gaussian in the frequency domain and transform this into a pulse in time domain. Here is the code that I have so far:

# Description of time domain sampling.
sampling_frequency = 10e6
sample_length = 100
time_index = np.arange(0, sample_length) * 1 / sampling_frequency

# Frequency domain sampling. Half the length of time domain since we only describe the positive frequency components.

frequency_domain_sample_length = sample_length // 2
sampling_frequency_domain = sampling_frequency / frequency_domain_sample_length

# Frequency domain filter.
center = 5e6
sigma = 1e6
frequency_index = np.arange(0, 10e6, bin_size_frequency_domain)
frequency_signal = np.exp(-(index - center) ** 2. / (2 * sigma ** 2.))

# Inverse fourier transform.
time_signal = np.fft.irfft(frequency_signal, sample_length)


I expect this to generate a pulse with a gaussian envelope in the time domain.

However, when I generate my signal it appears to have the "flipped" positive and negative sections that I usually correct using fftshift. However, I was under the impression that this should not be necessary when doing an inverse real fft. Here is what I get when I plot my time and frequency signals:

My questions are:

1) Is this an appropriate method for generating time domain signals? Since I am only describing a real component of the frequency content, this is more like a "filter" or a "power spectral density" than the result one would actually get when taking the FT of a time domain signal.

2) Why is the signal split and halves reversed? How do I correct this -- fftshift or is something else required.

• Could you provide the value of bin_size_frequency_domain you are using? – zabop Feb 5 '19 at 12:59