Exemplo n.º 1
0
        Td = T[1] - T[0]
        if gauss:
            wn, dft = fk.DFT(T_d,
                             Zg,
                             Td,
                             l_ref,
                             harmonic,
                             zeroPaddingFactor=zeroPaddingFactor)
        else:
            wn, dft = fk.DFT(T_d,
                             Z,
                             Td,
                             l_ref,
                             harmonic,
                             zeroPaddingFactor=zeroPaddingFactor)
        FWHM, peakFullWidth = fk.PeakWidth(T, 0.1, False, zeroPaddingFactor)
        FWHM = FWHM

        # theoretical spectrum
        center = 1E7 * (1 / l_fel -
                        1 / l_ref) * mfli_harmonic + harmonic * 1E7 / l_ref
        spectrum = np.exp(-4.0 * 0.693147 * (points - center)**2 /
                          fwhm_FEL_wn**2)  # spectrum in wavenumber space
        spectrum *= (max(abs(dft)) - min(abs(dft))) + min(abs(dft))
        ''' Plot time domain '''
        figTD = plt.figure('scan_{0:03}_{1}_d{2}_TD_{3}'.format(
            run, dev, d, i),
                           figsize=(14, 10))

        ax = figTD.add_subplot(321)
        ax.set_title('scan_{0:03}_{1}_d{2}_TD_{3}'.format(run, dev, d, i))
# -*- coding: utf-8 -*-
"""
Created on Fri May 31 10:07:34 2019

@author: LukasB
"""
import numpy as np
import fermi_analysis.functions as fk
import scipy.constants as spc

factor = spc.h * spc.c / spc.e * 100.
T = np.linspace(0.0, 550.0, 200)
peakMargin = 0.05
suscept = False
zeroPaddingFactor = 1
FWHM, Full = fk.PeakWidth(T, peakMargin, suscept, zeroPaddingFactor)
print FWHM, Full
FWHM *= factor
print FWHM
Z_cut = X_d + 1j*Y_d
Z_plot = Z_cut
Z_cut = fk.Phasing_TD(Z_cut,T_d,E_r) #time domain phasing of data set to take into account position of data window

scaling = 1 #max(Z.real)/max(Ttheo)

# Fourier traffo

Td = np.mean(np.unique(np.diff(delay)))
if gauss:
    Zg = fk.GaussWindow(T_d, Z_cut, suscept)
    wn, dft = fk.DFT(T_d, Zg, Td, l_ref , harmonic, zeroPaddingFactor = zeroPaddingFactor)
else:
    wn, dft = fk.DFT(T_d, Z_cut, Td, l_ref , harmonic, zeroPaddingFactor = zeroPaddingFactor)
#        dft = dft[::-1]
FWHM , peakFullWidth = fk.PeakWidth(T_d, 0.05, False, zeroPaddingFactor)

       
#Fouriert Trafo of the theoretical dataset
wn_theo, dft_theo = fk.DFT(t_fano_theo, I_fano_theo, t_fano_theo[1]-t_fano_theo[0], l_ref , harmonic, zeroPaddingFactor = zeroPaddingFactor)

''' Fitting the dephasing for 6th harmonic R'''

def decay(t,amp,tau):
    return amp*np.exp(-t/tau) + 0.001828
def decay_theo(t,amp,tau):
    return amp*np.exp(-t/tau)
    
t_start =-200 #time from where the fitting of the decay starts
idx_start = fk.find_index(T_d,t_start)
        if gauss:
            Zg = fk.GaussWindow(T_d, Z_cut, suscept)
            wn, dft = fk.DFT(T_d,
                             Zg,
                             Td,
                             l_ref,
                             harmonic,
                             zeroPaddingFactor=zeroPaddingFactor)
        else:
            wn, dft = fk.DFT(T_d,
                             Z_cut,
                             Td,
                             l_ref,
                             harmonic,
                             zeroPaddingFactor=zeroPaddingFactor)
        FWHM, peakFullWidth = fk.PeakWidth(T_d, peakMargin, suscept,
                                           zeroPaddingFactor)

        # theoretical spectrum
        center = 1E7 * (1 / l_fel -
                        1 / l_ref) * mfli_harmonic + harmonic * 1E7 / l_ref
        spectrum = np.exp(-4.0 * 0.693147 * (points - center)**2 /
                          fwhm_FEL_wn**2)  # spectrum in wavenumber space
        spectrum *= (max(abs(dft)) - min(abs(dft))) + min(abs(dft))
        ''' Plot time domain '''
        figTD = plt.figure('scan_{0:03}_{1}_d{2}_TD_{3}'.format(
            run, dev, d, i),
                           figsize=(14, 10))

        ax = figTD.add_subplot(321)
        ax.set_title('scan_{0:03}_{1}_d{2}_TD_{3}'.format(run, dev, d, i))
        #ax.errorbar(delay, X, yerr=X_s, color='b', linestyle='')