Esempio n. 1
0
def PowerSpectrum(data):
	# power spectrum
	smooth_data = SmoothFunction(data)
	freqs = numpy.array(numpy.fft.fftfreq(n=len(data), d=dt))/c
	fft = numpy.array(numpy.fft.fft(smooth_data))
	fft = fft * freqs
	spectrum = abs(fft) * abs(fft)
	smooth_spectrum = Smoothing.window_smooth(spectrum, window='hamming', window_len=15)
  	return (freqs,spectrum,smooth_spectrum)
Esempio n. 2
0
def PlotSpans (files, axs, clr):
	cdfs = [CDF(f) for f in files]
	data = [c[0] for c in cdfs]
	data = reduce(operator.add, data)

	hist,edges = numpy.histogram(data, range=(0.0,400.0), bins=200)

  	hist = Smoothing.window_smooth(hist)
  	if clr == 'b':
		plt.bar([i-width/2 for i in range(len(new_bins[:-1]))], hist, width, color=clr, align='center')
	else:
		plt.bar([i+width/2 for i in range(len(new_bins[:-1]))], hist, width, color=clr, align='center')
Esempio n. 3
0
def getLifespan(file,axs=None):

	cdf = CDF(file)
	# raw data
	data = cdf[0]

	# smooth out the data and digitize above a certain threshold
	smooth = Smoothing.window_smooth(numpy.array(data), window_len=40, window='blackman')
	smooth = smooth - 0.18
	new_data = numpy.ceil(smooth)
  	smooth = smooth + 0.18

	if axs:
		axs.plot(data[1200:2800], linewidth=2.5, color='k', linestyle=':', alpha=0.7, label=r'$C(t)$')
		axs.plot(smooth[1200:2800], linewidth=2.0, color='r', linestyle='-', alpha=0.7, label=r'$C_s(t)$')
		axs.plot(new_data[1200:2800], linewidth=3.5, color='g', linestyle='-', alpha=0.8, label=r'$f(t)$')

  	return [c for c in CutUpCycleBits(new_data)]
Esempio n. 4
0
fig = plt.figure(num=None, facecolor='w', edgecolor='w', frameon=True)
axs = fig.add_subplot(1,1,1)
axs.set_ylabel(r'Spectrum', size='xx-large')
axs.set_xlabel(r'Frequency / cm$^{-1}$', size='xx-large')

# use the same axis for all the spectra
freq_axis = FreqAxis(len(tcfs[0])/2,dt)

fft_tcfs_x = [FFT(t) for t in tcfs_x]
fft_tcfs_y = [FFT(t) for t in tcfs_y]
fft_tcfs_z = [FFT(t) for t in tcfs_z]

fft_tcfs = [(x+y+z)/3.0 for x,y,z in zip(fft_tcfs_x,fft_tcfs_y,fft_tcfs_z)]
#avg_fft = reduce(operator.add, fft_tcfs_z)/len(fft_tcfs_z)
avg_fft = FFT(avg_tcf)
smooth = Smoothing.window_smooth(avg_fft)


#for f in fft_tcfs:
	#axs.plot(freq_axis, f, linewidth=2.0)
axs.plot(freq_axis, smooth, linewidth=4.0, linestyle='-', color='k')

vector_tcf_ffts = [FFT(t) for t in vector_tcfs]
avg_vector_fft = numpy.array(reduce(operator.add,vector_tcf_ffts))/len(vector_tcf_ffts)

smooth_vector_fft = Smoothing.window_smooth(avg_vector_fft)
vector_freq_axis = FreqAxis(correlation_tau,dt)
print len(vector_freq_axis)
print len(smooth_vector_fft)
axs.plot(vector_freq_axis, smooth_vector_fft, linewidth=4.0, linestyle='-', color='r')