2 years ago

#53816

test-img

Joe

Determining spectrogram parameters in pylab

I am new to spectrogram and just start to study it by using atmospheric pressure data.

The data has a value once a day in timeseries as below. And the total number of the data is 775. So I guess n (length of the signal) is 775..

Date,Pres
2013-10-14,0.063984706
2013-10-15,-0.110020422
2013-10-16,0.134108188
2013-10-17,0.470139388
2013-10-18,0.43357662
2013-10-19,0.323462273
2013-10-20,0.145367563
2013-10-21,0.075079557
2013-10-22,0.176010769
2013-10-23,0.081473478
2013-10-24,-0.065722731

The code I made for spectrogram is as below. (I used python and pylab)

fil=pd.read_csv('filedirectory.csv')
cf=fil.iloc[:,1]

#Normalizing cf data (I am not sure which one is correct)
# 1st normalizing option
# cf=(cf-np.mean(cf))/np.std(cf)
# 2nd normalizing option    
cf=cf-cf.mean()
cf=cf/cf.max()

#Options for spectrogram
nfft=120
pp, ff, tt, pplot = pylab.specgram(cf, NFFT=nfft, Fs=1, detrend=pylab.detrend, 
window=pylab.window_hanning, noverlap=100)

pylab.title('Atmospheric_Pressure & nfft : %s' % nfft)
plt.colorbar()
plt.ylabel("Frequency")
plt.xlabel("days")
plt.show()

This is the result of the picture

enter image description here

What I want to know is..

  1. Value for Fs

When I make it '1', then y axis is from 0.0 to 0.5.

But when I change it 0.1 or other numbers, the plot does not changed as all except y axis value and color bar value.

How can I determine the value?

  1. Value for nfft and overlap

I made the values as 120 and 100.

But I do not know how to determine the value..

  1. What do pp, ff, tt mean?

I just followed an example and it assigned pp, ff, tt, pplot from the spectrogram.

What are meanings of them?

python

matplotlib

spectrogram

0 Answers

Your Answer

Accepted video resources