def fft_deconvolve(num, denom):
    s1 = num.shape[-1]
    s2 = denom.shape[-1]
    valid = abs(s2-s1) + 1
    fsize = 2**np.ceil(np.log2(s1+s2-1))

    deconvolver = 1.0/(EPS + signal.fft(denom, fsize, axis=-1))
    deconvolved = np.real(signal.ifft(deconvolver * signal.fft(num, fsize, axis=-1), axis=-1))
    return deconvolved[..., :valid]
def fft_convolve(v1, v2):
    s1 = v1.shape[-1]
    s2 = v2.shape[-1]
    valid = abs(s2-s1) + 1
    fsize = 2**np.ceil(np.log2(s1+s2-1))

    convolver = (EPS + signal.fft(v2, fsize, axis=-1))
    convolved = np.real(signal.ifft(convolver * signal.fft(v1, fsize, axis=-1), axis=-1))
    return _centered(convolved, valid)
Example #3
0
fft = sci.fft(y-pl.average(y))

l = len(fft)
dt = x[1]-x[0]

# kill the negative frequencies
#fft[l/2:] = 0.0

# kill the low frequency bits > ~ 1hour
k = int(24.0*l*dt)
print k

fft[0:5] = 0.0
fft[-5:] = 0.0

yy = sci.ifft(fft)


pl.subplot(311)
pl.plot(x,y,'.')

pl.subplot(312)
pl.plot(x,yy,'-')

pl.subplot(313)
pl.plot(x,y-yy,'.')

pl.show()

temp = []
temp.append(x)
Example #4
0
def ifft_value(signal):
    """ Gets the inverse fft of a signal.
    """
    import scipy.signal as sig
    return sig.ifft(signal)
Example #5
0
temp.append(date)
temp.append(phase)
temp.append(flux)

pl.save('HeIIlightcurve.dat',pl.array(temp).transpose())

lt = phase < 7.9

date = date[lt]
flux = pl.array(flux)[lt]
phase = pl.array(phase)[lt]
# flatten lightcurve using fourier method
fft = sci.fft(flux)
fft[0:4] = 0.0
fft[-4:] = 0.0
flux = sci.ifft(fft)

f,a = ast.signal.dft(date,flux,0,4000,1)
pl.figure()
pl.subplot(211)
pl.plot(phase,flux)
#pl.ylim(-5e-8,5e-8)
pl.subplot(212)
pl.plot(f,a)
sort,argsort = stats.fastsort(a)
print 'Max amplitude of %s at %s' % (a[argsort[-1]],f[argsort[-1]])
#print 'Second highest amplitude of %s at %s' % (a[argsort[-2]],f[argsort[-2]])
pl.show()