Python has this wonderful command in numpy, **np.loadtxt**.

In this case, I use np.loadtxt to load a file consisting of several ADC real values to do a quick plot for visualization. The rule is that each row in the text file has to have the same number of elements. In this case it is simply.

2304
4233
3252
and so on...

import matplotlib.pyplot as plt
import numpy as np
data = np.loadtxt('/path/to/your/file')
# get x-axis bins
x_axis = np.arange(data.size) * 960 / data.size
#plot time domain
plt.plot(data)
# plot frequency domain
plt.figure()
spc = np.fft.fft(data)
plt.plot(x_axis, 20*np.log10(abs(spc)))

That’s all. Pretty quick and nifty!

### Like this:

Like Loading...

*Related*