Esempio n. 1
0
def FFTs(f, dir):
    """fft with shifting"""
    what = np.ascontiguousarray(f)

    if dir == 1:
        return np.fftshift(np.fftn(what))
    elif dir == -1:
        return np.fftshift(np.ifftn(np.ifftshift(what)))
    else:
        print('Select direction: 1 -> Direct FFT; -1 -> Inverse FFT')
        quit()
        return 0
Esempio n. 2
0
def plot_pspec(history):
    #need to modify
    field=history['field']
    rho=history['rho']
    detune=history['detune']
    plt.figure()
    fieldFFT = np.fftshift(np.fft(field.T))                  # unconjugate complex transpose by .'
    Pspec=fieldFFT*np.conj(fieldFFT)
    plt.plot(detune*2*rho,Pspec)
    plt.axis([-0.06,+0.01,0,1.2*np.max(Pspec)])
    plt.xlabel('{(\Delta\omega)/\omega_r}')
    plt.ylabel('{output spectral power} (a.u.)')
Esempio n. 3
0
def periodogram(time_series, taper=None, L=None):
    'Implements the periodogram spectral estimator.'
    #If we don't have a taper, just use a rectangular one (array of ones)
    if not taper:
        taper = N.ones_like(time_series)
    #Other wise, make sure the sizes are compatible
    elif taper.size != time_series.size and taper.size != time_series.shape[-1]:
        raise ValueError('Data and Taper must have the same size')
        
    #Zero pad if necessary
    if L is None:
        L = time_series.shape[-1]
    elif L > time_series.shape[-1]:
        num_zeros = L - time_series.shape[-1]
        zeropad = N.zeros(time_series.shape[:-1] + (num_zeros,),
            dtype=time_series.dtype)
        time_series = N.concatenate((time_series, zero_pad), axis=-1)
    elif L < time_series.shape[-1]:
        time_series = time_series[...,:L]

    Z = fftshift(fft(taper * time_series))
    return N.abs(Z)*N.abs(Z)/time_series.size
Esempio n. 4
0
def correlogram(time_series, scale='biased'):
    '''Implements the correlogram spectral estimator. This is often known as the
    Blackman-Tukey estimator with a rectangular window.'''
    R = xcorr(time_series, scale=scale)
    return N.abs(fftshift(fft(R)))
Esempio n. 5
0
# Objective: observe bubble cloud migration on high-speed camera and compare to
# ACE peak arrival (and edge detection) signal.

import numpy as np
import scipi.io as sio
import matplotlib.pyplot as plt

class array():
    def __init__(self):
        coords  = sio.loadmat('256x2cm_Hemispherical_Array_CAD_Coordinates.mat')
        X = coords['XCAD'][7:]
	Y = coords['YCAD'][7:]
	self.z = coords['ZCAD'][7:]
	t1 = np.arctan2(Y,X)-0.75*pi
	rr1 = (X**2+Y**2)**0.5
	self.x = rr1*np.cos(t1)
	self.y = rr1*np.sin(t1)
	self.z = rr1*np.tan(t1)

class bSignals():
    def FTsig(self,signal,interval)
        insig = signal(interval)
        ft = np.fftshift(np.fft(insig))
        return ft

fig = plt.figure()
plt.plot(ft)
plt.show()