#Z = Z_uhlia if i0_correction: Z = Z*(np.nanmean(data['LDM']['I0'])/data['LDM']['I0']) if i0_6H_correction: Z = Z*i0_6H Z *= np.exp(1j*np.pi/180.*phas_corr) #phasing of dataset according to phase difference between reference and WPI signal R = np.abs(Z) Phi = np.angle(Z, deg=False) # plt.plot(np.unwrap(Phi)) # Create theoretical curve Ttheo = np.linspace(delay[0],delay[-1], 30000) Xtd,Ytd,Xt,Yt = fk.Curve(spc.h*spc.c/(spc.e*l_trans)*1e9, l_ref, harmonic, phi, a*max(abs(Z)), offset, delay[0], delay[-1], 30000) # theo curve for transition Xtd,Ytd,Xt,Yt = fk.Curve(l_fel/harmonic, l_ref, harmonic, phi, a*max(abs(Z)), offset, delay[0], delay[-1], 30000) # theo curve for laser CWL T_d,X_d,Y_d = fk.CutDataSet(delay, Z.real, Z.imag, data_window) 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)
mfli_harmonic = data[dev]['harmonic'][int(d)] i = str(mfli_harmonic) + 'H' Z = (data[dev]['x' + d] + 1j * data[dev]['y' + d] ) # / data['LDM']['I0'] if i0_correction: Z = Z * (np.nanmean(data['LDM']['I0']) / data['LDM']['I0']) Z_s = data[dev]['s_x' + d] + 1j * data[dev]['s_y' + d] R = np.sqrt(Z.real**2 + Z.imag**2) R_s = np.sqrt(Z_s.real**2 + Z_s.imag**2) Phi = np.angle(Z, deg=False) # Create theoretical curve # if draw_theory: #Ttheo = np.linspace(T[0],T[-1], 1000) Xtd, Ytd, Xt, Yt = fk.Curve(l_trans, l_ref, harmonic, phi, a * max(abs(Z)), offset, T[0], T[-1], 1000) delay = T X = Z.real X_s = Z_s.real Y = Z.imag Y_s = Z_s.imag T_d, X_d, Y_d = fk.CutDataSet(T, X, Y, data_window) Z = X_d + 1j * Y_d scaling = 1E-4 #max(Z.real)/max(Ttheo) # Fourier traffo Zg = fk.GaussWindow(T_d, Z, suscept) Td = T[1] - T[0] if gauss:
"""Plotting parameters""" demod = 0 # in [0,1,2,3]. Choose which demodulator channel to analyse and plot downshifted = False # plot downshifted spectrum absolute = True # plot absorption spectrum absorptive = False # plot absorptive and dispersive spectrum """TD Analysis & Plotting""" # delay parameters start = min(data['delay']) stop = max(data['delay']) length = len(data['delay']) T = np.linspace(start, stop, length, endpoint=True) print(np.unique(np.diff(data['delay']))) #calculation of theoretical curve Xtd, Ytd, X, Y = fk.Curve(l_He, l_ref, h, phi, A, offset, start, stop, length) # Xtd/Ytd is time domain data, where 10fs are added/substracted to start/stop of dataset,X and Y start/stop at edges of data set and are used for DFT #plot in phase and in quadrature components of theoretical curve and of data plt.figure() fk.PlotCurve(Xtd, Ytd, start, stop) fk.PlotTdData(data, demod) # #"""FD Analysis & Plotting""" #"""""""""""""""""" # ## discrete complex fourier transform of theoretical curve: #Z = X + 1j * Y # # ## from phancy
i = str(mfli_harmonic) + 'H' Z = (data[dev]['x' + d] + 1j * data[dev]['y' + d] ) # / data['LDM']['I0'] # Z *= np.exp(1j*40./360.*2.*np.pi) if i0_correction: Z = Z * (np.nanmean(data['LDM']['I0']) / data['LDM']['I0']) Z_s = data[dev]['s_x' + d] + 1j * data[dev]['s_y' + d] R = np.sqrt(Z.real**2 + Z.imag**2) R_s = np.sqrt(Z_s.real**2 + Z_s.imag**2) Phi = np.angle(Z, deg=False) # Create theoretical curve # if draw_theory: #Ttheo = np.linspace(T[0],T[-1], 1000) Xtd, Ytd, Xt, Yt = fk.Curve(l_trans, l_ref, harmonic, phi, a * max(abs(Z)), offset, T[0], T[-1], 1000) X = Z.real X_s = Z_s.real Y = Z.imag Y_s = Z_s.imag # T_d,X_d,Y_d = fk.CutDataSet(T, X, Y, data_window) # # # Z = X_d + 1j*Y_d Z *= np.exp(1j * np.pi / 180 * phas_corr) scaling = 1E-4 #max(Z.real)/max(Ttheo) T_d, X_d, Y_d = fk.CutDataSet(T, Z.real, Z.imag, data_window) Z_cut = X_d + 1j * Y_d
while 1: try: imp_data.append(pickle.load(fp)) except EOFError: break fp.close() T = imp_data[0] Z = imp_data[1] + 1j*imp_data [3] Z_s = imp_data[2] + 1j*imp_data [4] R = np.sqrt(Z.real**2 + Z.imag**2) R_s = np.sqrt(Z_s.real**2 + Z_s.imag**2) Phi = np.angle(Z, deg=True) Ttheo = np.linspace(T[0],T[-1], 1000) Xtd,Ytd,Xt,Yt = fk.Curve(l_He, l_ref, harmonic, -90.0, max(abs(Z)), offset, T[0], T[-1], 1000) # Optimal phase Phi_theo = T * 1e-6 * (spc.c/l_ref * harmonic - spc.c/l_He) * 360.0 Phi_theo -= (Phi_theo[0]- Phi[0]) Phi -= Phi_theo delay = T X = Z.real X_s = Z_s.real Y = Z.imag Y_s = Z_s.imag # Fourier traffo Zg = fk.GaussWindow(T, Z, False) Td = T[1]-T[0]
AC = np.exp(-4.0 * np.log(2) * ((Ttheo) / AC_FWHM)**2) Fano = np.exp((Ttheo) / Fano_FWHM) # loop over the mfli devices for dev in device: # loop over the demodulators for d in demod: mfli_harmonic = data[dev]['harmonic'][int(d)] i = str(mfli_harmonic) + 'H' Z = data[dev]['x' + d] + 1j * data[dev]['y' + d] Z_s = data[dev]['s_x' + d] + 1j * data[dev]['s_y' + d] # Create theoretical curve # if draw_theory: Xtd, Ytd, Xt, Yt = fk.Curve(l_trans, l_ref, harmonic, phi, a * max(abs(Z)), offset, T[0], T[-1], np.size(T)) Xtd_gaus, Ytd_gaus, Xt_gaus, Yt_gaus = fk.Curve( l_fel / harmonic, l_ref, harmonic, phi, a * max(abs(Z)), offset, T[0] - t_corr, T[-1] - t_corr, np.size(T)) Xt *= Fano Yt *= Fano # Xt -= 1*Xt_gaus*abs(data[dev]['x0'] + 1j * data[dev]['y0'])/max(abs(data[dev]['x0'] + 1j * data[dev]['y0'])) # Yt -= 1*Yt_gaus*abs(data[dev]['x0'] + 1j * data[dev]['y0'])/max(abs(data[dev]['x0'] + 1j * data[dev]['y0'])) # correct time and phase for susceptibility T += t_corr Z *= np.exp(1j * np.pi * phi_sus / 180.0) # correction of phase if plotTheo: T = Ttheo + t_corr
mfli_harmonic = data[device]['harmonic'][int(demod)] i = str(mfli_harmonic) + 'H' Z = (data[device]['x' + demod] + 1j * data[device]['y' + demod] ) # / data['LDM']['I0'] if i0_correction: Z = Z * (np.nanmean(data['LDM']['I0']) / data['LDM']['I0']) R = np.abs(Z) Phi = np.angle(Z, deg=False) # plt.plot(np.unwrap(Phi)) # Create theoretical curve Ttheo = np.linspace(delay[0], delay[-1], 30000) Xtd, Ytd, Xt, Yt = fk.Curve(spc.h * spc.c / (spc.e * l_trans) * 1e9, l_ref, harmonic, phi, A, offset, delay[0], delay[-1], 30000) # theo curve for transition #Xtd,Ytd,Xt,Yt = fk.Curve(l_fel/harmonic, l_ref, harmonic, phi, a*max(abs(Z)), offset, delay[0], delay[-1], 30000) # theo curve for laser CWL T_d, X_d, Y_d = fk.CutDataSet(delay, Z.real, Z.imag, data_window) 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 # Fourier traffo Td = np.mean(np.unique(np.diff(delay))) if gauss: Zg = fk.GaussWindow(T_d, Z_cut, suscept)