#        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)

R_fit = abs(Z_cut) #region of R that will be fitted
popt, pcov = curve_fit(decay, T_d[idx_start:], R_fit[idx_start:], p0=[0.8,-110.],absolute_sigma=False)
perr = np.sqrt(np.diag(pcov))

#fitting theoretical curve:
popt_theo, pcov_theo = curve_fit(decay_theo, t_fano_theo, abs(I_fano_theo), p0=[0.8,-110.],absolute_sigma=False)
perr_theo = np.sqrt(np.diag(pcov_theo))

print('The time constant of the data fit is {} +- {} fs'.format(popt[1],perr[1]))
print('The time constant of the data fit is {} +- {} fs'.format(popt_theo[1],perr_theo[1]))

#            plt.plot(T_d,R_fit)
#            plt.plot(T_d, decay(T_d,popt[0],popt[1]))
#            plt.plot(t_fano_theo, decay(t_fano_theo,popt_theo[0],popt_theo[1]))
Esempio n. 2
0
#pd.DataFrame(save_file.transpose()).to_csv("run4644_padres.csv",delimiter="\t",index=False)

#==============================================================================
# Fitting gaussion to spectrum average
#==============================================================================


def Gauss(x, amp, mean, fwhm, offs):
    return amp * np.exp(-4 * np.log(2) * (x - mean)**2 / fwhm**2) + offs


popt_gauss, pcov_gauss = curve_fit(Gauss,
                                   padres_roi_5H,
                                   padres_single,
                                   p0=[
                                       1., padres_roi_5H[fk.find_index(
                                           padres_single, max(padres_single))],
                                       0.07, 0.05
                                   ],
                                   absolute_sigma=False)
perr_gauss = np.sqrt(np.diag(pcov_gauss))
peak_pos_sl = popt_gauss[1]

print popt_gauss[2]

#==============================================================================
# ''' Plotting '''
#==============================================================================
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(padres_roi_5H, padres_single)
ax.plot(
Esempio n. 3
0
#phasing:
if phasing:
    phi_corr = np.array([180,0,180,0,180,0]) # corrects for other output of interferometer
    gamma = 10.5*(np.arange(6)+1) #corrects for phase shift of reference transmitter
    beta = 0.01*3.03*360*(np.arange(6)+1) #phase of boxcar integrator [degree] (beta in Lukas phasing routine)
    
    Zh = Zh*np.exp(1j*(gamma-beta)/180.*np.pi)
    Zh = Zh*np.exp(1j*phi_corr/180.*np.pi)

Phih = np.angle(Zh)
t0 = 0 # indicates where actual time zero is [fs].

if unwrap:
    Phih =np.unwrap(Phih, axis =0)
    phi_0 = Phih[fk.find_index(T,t0),::] #phase at 0 delay of demodulate signal at each harmonic 
    phi_0_mod = Phih[fk.find_index(T,t0),::] % (2.*np.pi)#phase at 0 delay of demodulate signal at each harmonic 
    phi_0_mod = [a if a < np.pi else a-2*np.pi for a in phi_0_mod]
    print phi_0_mod
    Phih = Phih-phi_0+phi_0_mod


figphase = plt.figure('Phase of individual harmonic')
ax.set_title('Phase of individual harmonic')
ax = figphase.add_subplot(111)
ax.plot(T,Phih,'-')
ax.legend(legend,ncol=3)
ax.set_xlabel('delay [fs]')
ax.set_ylabel('phase [rad]')
ax.set_xlim([-10,10])
    sa = perr[0]
    sb = perr[1]

    #    print('Zero delay is {} +- {} fs'.format(-b/a, -b/a*(abs(sa/a)+abs(sb/b)) ))
    delay_range = np.append(delay_range, delay[cut_delay])
    zero_delay = np.append(zero_delay, -b / a)

figTD = plt.figure('zero_delay_vs_fit_start_point', figsize=(8, 5))
ax = figTD.add_subplot(111)
ax.set_title('zero_delay_vs_fit_start_point')
ax.plot(delay_range, zero_delay, 'o')
ax.set_xlabel('starting point of fit [fs]')
ax.set_ylabel('zero_delay [fs]')

fit_range = [-200, -370]  #for argon
mean_zero = np.mean(zero_delay[fk.find_index(delay_range, fit_range[0]):fk.
                               find_index(delay_range, fit_range[1])])
std_zero = np.std(zero_delay[fk.find_index(delay_range, fit_range[0]):fk.
                             find_index(delay_range, fit_range[1])])
print('Zero delay is {} +- {} fs'.format(mean_zero, std_zero))

#==============================================================================
# Plotting the results
#==============================================================================
figTD = plt.figure('Fringe Spacing Scan4651', figsize=(8, 5))
ax = figTD.add_subplot(111)
ax.set_title('Fringe Spacing Scan4651')
ax.plot(delay, peak_pos, 'o')
#ax.plot(delay[idx], peak_pos[idx],'o')
ax.plot(delay, Lin(delay, popt[0], popt[1]))
ax.grid()