def process_diffraction(self, dz, n_jobs=MAX_NUMBER_OF_CPUS): """ :param dz: current step along evolutionary coordinate z :param n_jobs: number of threads for parallelization :return: None """ # calculation of current linear phase shift current_lin_phase = 0.5j * dz / self._beam.medium.k_0 # forward parallel fast Fourier transform fft_obj = fft2(self._beam._field, threads=n_jobs) # linear phase increment field_fft = self.__phase_increment(fft_obj(), self._beam.n_x, self._beam.n_y, array(self._beam.k_xs), array(self._beam.k_ys), current_lin_phase) # backward parallel fast Fourier transform ifft_obj = ifft2(field_fft, threads=n_jobs) # field initialization with updated values self._beam._field = ifft_obj()
def eval_ifft2(data, num_threads=12): ''' Evaluate rfft2 ''' ift = ifft2(data, threads=num_threads, planner_effort="FFTW_ESTIMATE", auto_align_input=True, auto_contiguous=True) # Return rfft2 result return ift(data.copy(), np.zeros(ift.output_shape, dtype=ift.output_dtype)).copy()
def process(self): """Noise and autocorr functions generation""" # noise field generation proto = self.__generate_protoarray(self._n_x, self._n_y, self._variance_expected, self._r_corr_in_points) proto_shifted = fftshift(proto, axes=(0, 1)) proto_fft_obj = ifft2(proto_shifted) proto_fft_normalized = self.__normalize_after_fft(proto_fft_obj()) self._noise_field = proto_fft_normalized # initialization of arrays for real and imaginary parts self._noise_field_real, self._noise_field_imag = \ self._initialize_noise_arrays(self._noise_field, self._n_x, self._n_y) # autocorrelation functions calculation self._calculate_autocorrelations()