Ejemplo n.º 1
0
def plot_freqs(tup, wl, from_t, to_t, taus=[1]):
    ti = dv.make_fi(tup.t)
    wi = dv.make_fi(tup.wl)
    tl = tup.t[ti(from_t):ti(to_t)]
    trans = tup.data[ti(from_t):ti(to_t), wi(wl)]

    #ax1 = plt.subplot(311)
    #ax1.plot(tl, trans)
    dt = dv.exp_detrend(trans, tl, taus)

    #ax1.plot(tl, -dt+trans)
    #ax2 = plt.subplot(312)
    ax3 = plt.subplot(111)

    f = abs(np.fft.fft(np.kaiser(2 * dt.size, 2) * dt, dt.size * 2))**2
    freqs = np.fft.fftfreq(dt.size * 2, tup.t[ti(from_t) + 1] - tup.t[ti(from_t)])
    n = freqs.size // 2
    ax3.plot(dv.fs2cm(1000 / freqs[1:n]), f[1:n])
    ax3.set_xlabel('freq / cm$^{-1}$')
    return dv.fs2cm(1000 / freqs[1:n]), f[1:n]
Ejemplo n.º 2
0
def plot_freqs(tup, wl, from_t, to_t, taus=[1]):
    ti = dv.make_fi(tup.t)
    wi = dv.make_fi(tup.wl)
    tl = tup.t[ti(from_t):ti(to_t)]
    trans = tup.data[ti(from_t):ti(to_t), wi(wl)]

    #ax1 = plt.subplot(311)
    #ax1.plot(tl, trans)
    dt = dv.exp_detrend(trans, tl, taus)

    #ax1.plot(tl, -dt+trans)
    #ax2 = plt.subplot(312)
    ax3 = plt.subplot(111)

    f = abs(np.fft.fft(np.kaiser(2*dt.size, 2)*dt, dt.size*2))**2
    freqs = np.fft.fftfreq(dt.size*2, tup.t[ti(from_t)+1]-tup.t[ti(from_t)])
    n = freqs.size//2
    ax3.plot(dv.fs2cm(1000/freqs[1:n]), f[1:n])
    ax3.set_xlabel('freq / cm$^{-1}$')
    return dv.fs2cm(1000/freqs[1:n]), f[1:n]
Ejemplo n.º 3
0
def plot_fft(x, y, min_amp=0.2, order=1, padding=2, power=1, ax=None):
    from scipy.signal import argrelmax
    if ax is None:
        ax = plt.gca()
    f = abs(np.fft.fft(y, padding * y.size))**power
    freqs = np.fft.fftfreq(padding * x.size, x[1] - x[0])
    n = freqs.size // 2 + 1
    fr_cm = -dv.fs2cm(1000 / freqs[n:])

    ax.plot(fr_cm, f[n:])
    ax.set_xlabel('Wavenumber / cm$^{-1}$')
    ax.set_ylabel('FFT amplitude')
    for i in argrelmax(f[n:], order=1)[0]:
        if f[n + i] > min_amp:
            ax.text(fr_cm[i], f[n + i], '%d' % fr_cm[i], ha='center')
Ejemplo n.º 4
0
def plot_fft(x, y, min_amp=0.2, order=1, padding=2, power=1, ax=None):
    from scipy.signal import argrelmax
    if ax is None:
        ax = plt.gca()
    f = abs(np.fft.fft(y, padding*y.size))**power
    freqs = np.fft.fftfreq(padding*x.size, x[1]-x[0])
    n = freqs.size//2+1
    fr_cm = -dv.fs2cm(1000/freqs[n:])

    ax.plot(fr_cm, f[n:])
    ax.set_xlabel('Wavenumber / cm$^{-1}$')
    ax.set_ylabel('FFT amplitude')
    for i in argrelmax(f[n:], order=1)[0]:
        if f[n+i]>min_amp:
            ax.text(fr_cm[i], f[n+i], '%d'%fr_cm[i], ha='center')