Exemple #1
0
 def calc_spectrum(self):
     """
     This function calculates the 2DIR spectrum from measurement data. It does a 1D fourier transform and phases the spectra.
     It checks first if there is a spectrum in the first place and if the phase is given. 
     
     """
     if type(self.phase) == bool:
         print("WARNING (data2d, calc_spectrum): The phase was not given. It will now use 0!")
     try:
         phase_rad=self.phase*np.pi/180
         self.s=(    np.exp(-1j*phase_rad) * fourier.rb_fft_1d(self.r[0], self.undersampling) +
                     np.exp( 1j*phase_rad) * fourier.rb_fft_1d(self.r[1], self.undersampling)
                 )
         self.s_axis[2] = self.r_axis[2]
         self.s_axis[0] = fourier.fft_axis(self.r_axis[0], self.undersampling)
     except:
         print("ERROR (data2d, calc_spectrum): The spectrum couldn't be calculated.")
Exemple #2
0
    def calc_phase(self):
        
        self.s = (fourier.rb_fft_1d(self.r, undersampling=0, fft_shift_flag=1)).T
#        self.s = self.s.T
        self.abs_array = abs(self.s)
        self.phase_array = pylab.angle(self.s)
        for i in range(0, np.shape(self.phase_array)[0]):
            for j in range(0, np.shape(self.phase_array)[1]):
                  self.phase_array[i][j] = self.phase_array[i][j]*180/np.pi
        
        
        
        
        n_i=np.shape(self.r)[0]
        n_t=np.shape(self.r)[1]
        
        #calculate the frequency axis
        self.s_axis[0]=np.fft.fftfreq(n_t, 3e8*100*2.11e-15)
        self.s_axis[0]=self.s_axis[0][:n_t/2]
        
        self.i_max=self.abs_array[0].argmax()
        
        print("Frequency, rough guess:", self.s_axis[0][self.i_max])
        #now refine this by weighted averaging???
        #this function is general, but it assumes that s[0] is the best interferogram
        w0=np.average(self.s_axis[0][self.i_max-2:self.i_max+3], weights=self.abs_array[0][self.i_max-2:self.i_max+3])
        print("Frequency, refined guess:", w0)	
        tau=1/(w0*3e8*100e-15)

        #now find the phases at the i_max and the point before and after
        i_fit=list(range(self.i_max-1, self.i_max+2)) #these are three points
        ph=np.zeros(n_i)
        for j in range(0, n_i):
            ph[j]=np.average(self.phase_array[j][i_fit])
        
        print(ph[0], ph[1])
	
        simple_phase= (ph[0] - ph[1])
	
        print(simple_phase)