コード例 #1
0
ファイル: hpc-checkpoint.py プロジェクト: Mo-Rice/hpc_sim
    def generate_amplitude_map(self, x_array, y_array, x_offset=0, y_offset=0, max_val=None):
        "Given an x and y array will produce an amplitude map of the beam as defined. x/y offsets will displace the beam in the respective axis."

        if self.spatial == "gauss":
            import pykat.optics.gaussian_beams as gb
            q = gb.BeamParam(w0=self.w0, z=self.z)
            HG00 = gb.HG_mode(q,n=0, m=0)
            u00 = np.sqrt(self.power)*HG00.Unm(y_array-y_offset, x_array-x_offset)
            self.amplitude_map = u00
            return u00
        
        elif self.spatial == "user":
            #applies user array to custimize beam shape
            name = input(print("Please enter file path to numpy beam array: ")) #allow .jpeg? 
            pixel_pitch = 6.9e-6
            array = np.load(name)
            xx, yy = np.meshgrid(x_array,y_array)
            ampIntArr = np.zeros(np.shape(yy))#(ROWS, COLUMNS)
            
            if array.shape != (xx.shape): #numpy array is (ROWS, COLUMNS) #need to generalize, why doesnt xx work
                print('Entered array is not the correct size. Please enter an array with ' 
                    + str(np.shape(yy)) + ' Rows and Columns.')
            else: 
                Inten = self.power / (array.size * pixel_pitch**2) 
                ampIntArr = np.sqrt( array * Inten / np.sum(array))
                return ampIntArr

        else:
            xx, yy = np.meshgrid(x_array,y_array)
            tophat = np.zeros(np.shape(xx))
            r = 1e-3
            mask = xx**2 + yy**2 < r**2
            tophat[mask] = np.sqrt(self.power)/(np.sqrt(np.pi)*r)
            self.amplitude_map = tophat
            return tophat
コード例 #2
0
ファイル: hpc-checkpoint.py プロジェクト: Mo-Rice/hpc_sim
def gauss_amp(x_array, y_array, w0, z, x_offset, y_offset):
    import pykat.optics.gaussian_beams as gb
    q = gb.BeamParam(w0=w0, z=z)
    HG00 = gb.HG_mode(q,n=0, m=0)
    u00 = HG00.Unm(y_array-y_offset, x_array-x_offset)
    return u00