Beispiel #1
0
    def find_actuator_defocus(self):

        i_ref = np.argwhere(self.wave_range == self.wave_ref)[0][0]
        PSF_nom = psf.PointSpreadFunction(self.raw_matrices[i_ref],
                                          N_pix=self.N_PIX,
                                          crop_pix=self.pix,
                                          diversity_coef=np.zeros(self.N_act))

        # Create a Zernike model so we can mimic the defocus
        zernike_matrix, pupil_mask_zernike, flat_zernike = psf.zernike_matrix(
            N_levels=5,
            rho_aper=self.rho_aper,
            rho_obsc=self.rho_obsc,
            N_PIX=self.N_PIX,
            radial_oversize=1.0)
        zernike_matrices = [zernike_matrix, pupil_mask_zernike, flat_zernike]
        plt.figure()
        plt.imshow(pupil_mask_zernike)
        PSF_zernike = psf.PointSpreadFunction(matrices=zernike_matrices,
                                              N_pix=self.N_PIX,
                                              crop_pix=self.pix,
                                              diversity_coef=np.zeros(
                                                  zernike_matrix.shape[-1]))

        # Use Least Squares to find the actuator commands that mimic a Zernike defocus
        zernike_fit = calibration.Zernike_fit(PSF_zernike,
                                              PSF_nom,
                                              wavelength=self.wave_ref,
                                              rho_aper=self.rho_aper)
        defocus_zernike = np.zeros((1, zernike_matrix.shape[-1]))
        defocus_zernike[0, 1] = 1.0
        defocus_actuators = zernike_fit.fit_zernike_wave_to_actuators(
            defocus_zernike, plot=True, cmap='bwr')[:, 0]

        # Update the Diversity Map on the actuator model so that it matches Defocus
        return defocus_actuators
Beispiel #2
0
        rho_obsc=RHO_OBSC,
        N_PIX=N_PIX)

    actuator_matrices = [actuator_matrix, pupil_mask, flat_actuator]

    diversity_actuators = np.zeros(N_act)
    PSF_actuators = psf.PointSpreadFunction(matrices=actuator_matrices,
                                            N_pix=N_PIX,
                                            crop_pix=pix,
                                            diversity_coef=diversity_actuators)

    plt.show()

    # Use Least Squares to find the actuator commands that mimic the Zernike defocus
    zernike_fit = calibration.Zernike_fit(PSF_zernike,
                                          PSF_actuators,
                                          wavelength=WAVE,
                                          rho_aper=RHO_APER)
    defocus_zernike = np.zeros((1, zernike_matrix.shape[-1]))
    defocus_zernike[0, 1] = 1.0
    defocus_actuators = zernike_fit.fit_zernike_wave_to_actuators(
        defocus_zernike, plot=True, cmap='Reds')[:, 0]

    # Loop over the strength of defocus to see what is the optimum value
    rms_before, rms_after = [], []
    diversities, rms_div = [], []
    mean_peak_foc = []

    # Noise RMS
    N_cases = 30
    noiseSNR = np.array([500, 250, 100])
    N_noise = noiseSNR.shape[0]
Beispiel #3
0
    plt.show()

    ###

    # Temporarily use a single wavelength PSF to calculate the Zernike defocus coefficients
    _PSF = psf.PointSpreadFunction(actuator_matrices[0], N_pix=N_PIX, crop_pix=pix, diversity_coef=np.zeros(N_act))

    # Create a Zernike model so we can mimic the defocus
    zernike_matrix, pupil_mask_zernike, flat_zernike = psf.zernike_matrix(N_levels=5, rho_aper=RHO_APER,
                                                                          rho_obsc=RHO_OBSC,
                                                                          N_PIX=N_PIX, radial_oversize=1.0)
    zernike_matrices = [zernike_matrix, pupil_mask_zernike, flat_zernike]
    PSF_zernike = psf.PointSpreadFunction(matrices=zernike_matrices, N_pix=N_PIX,
                                          crop_pix=pix, diversity_coef=np.zeros(zernike_matrix.shape[-1]))
    # Use Least Squares to find the actuator commands that mimic a Zernike defocus
    zernike_fit = calibration.Zernike_fit(PSF_zernike, _PSF, wavelength=WAVE, rho_aper=RHO_APER)
    defocus_zernike = np.zeros((1, zernike_matrix.shape[-1]))
    defocus_zernike[0, 1] = 1.0
    defocus_actuators = zernike_fit.fit_zernike_wave_to_actuators(defocus_zernike, plot=True, cmap='bwr')[:, 0]
    diversity_defocus = diversity / (2 * np.pi) * defocus_actuators

    ###

    PSFs = psf.PointSpreadFunctionMultiwave(matrices=actuator_matrices, N_waves=N_WAVES, wave0=WAVE0, waveN=WAVEN,
                                            wave_ref=WAVE, N_pix=N_PIX, crop_pix=pix, diversity_coef=diversity_defocus)

    # Show the PSF as a function of wavelength
    c_act = 0.3 * np.random.uniform(-1, 1, size=N_act)
    cmap = 'hot'
    fig, axes = plt.subplots(1, N_WAVES)
    for k in range(N_WAVES):