Example #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
Example #2
0
    pix,
    pix,
    2,
)
epochs = 10  # Training epochs
SNR = 500

if __name__ == """__main__""":

    plt.rc('font', family='serif')
    plt.rc('text', usetex=False)

    # (1) We begin by creating a Zernike PSF model with Defocus as diversity
    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.1)
    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]))

    # Calculate the Actuator Centres
    centers = psf.actuator_centres(N_actuators,
                                   rho_aper=RHO_APER,
                                   rho_obsc=RHO_OBSC,
                                   radial=True)
    N_act = len(centers[0])
import importlib
importlib.reload(calibration)


if __name__ == """__main__""":

    plt.rc('font', family='serif')
    plt.rc('text', usetex=False)


    ### (0) Show the impact of ellipticity variations

    # Define a nominal PSF Zernike model with no anamorphic errors. Perfectly circular pupil
    zernike_matrix, pupil_mask_zernike, flat_zernike = psf.zernike_matrix(N_levels=N_levels, rho_aper=RHO_APER,
                                                                          rho_obsc=RHO_OBSC, N_PIX=N_PIX,
                                                                          radial_oversize=1.0, anamorphic_ratio=1.0)

    N_zern = zernike_matrix.shape[-1]
    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]))

    defocus_zernike = np.zeros(zernike_matrix.shape[-1])
    defocus_zernike[1] = diversity / (2 * np.pi)
    PSF_zernike.define_diversity(defocus_zernike)

    # Define a model with some anamorphic error
    ratio = 1.10        # a / b for the ellipse. > 1.0 elongated PSF along Y
    zernike_matrix_anam, pupil_mask_zernike_anam, flat_zernike_anam = psf.zernike_matrix(N_levels=N_levels, rho_aper=RHO_APER,
                                                                                         rho_obsc=RHO_OBSC, N_PIX=N_PIX,
Example #4
0
readout_copies = 2  # How many copies with Readout Noise to use
N_iter = 3  # How many iterations to run the calibration (testing)

import importlib
importlib.reload(calibration)

if __name__ == """__main__""":

    plt.rc('font', family='serif')
    plt.rc('text', usetex=False)

    ### (0) Define a nominal PSF Zernike model with no anamorphic mag. Perfectly circular pupil
    zernike_matrix, pupil_mask_zernike, flat_zernike = psf.zernike_matrix(
        N_levels=N_levels,
        rho_aper=RHO_APER,
        rho_obsc=RHO_OBSC,
        N_PIX=N_PIX,
        radial_oversize=1.0,
        anamorphic_ratio=1.0)

    N_zern = zernike_matrix.shape[-1]
    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]))

    defocus_zernike = np.zeros(zernike_matrix.shape[-1])
    defocus_zernike[1] = diversity / (2 * np.pi)
    PSF_zernike.define_diversity(defocus_zernike)
Example #5
0

if __name__ == """__main__""":

    plt.rc('font', family='serif')
    plt.rc('text', usetex=False)

    ### (0) Define a model with a sampling of 2.0 mas Spaxels

    ### PSF sampled with 2.0 mas spaxels
    SPAX2 = 2.0  # mas | spaxel scale
    RHO_APER2 = utils.rho_spaxel_scale(spaxel_scale=SPAX2, wavelength=WAVE)
    RHO_OBSC2 = 0.30 * RHO_APER2  # ELT central obscuration

    zernike_matrix2, pupil_mask_zernike2, flat_zernike2 = psf.zernike_matrix(N_levels=N_levels, rho_aper=RHO_APER2,
                                                                          rho_obsc=RHO_OBSC2, N_PIX=N_PIX,
                                                                          radial_oversize=1.0, anamorphic_ratio=1.0)
    N_zern = zernike_matrix2.shape[-1]

    zernike_matrices2 = [zernike_matrix2, pupil_mask_zernike2, flat_zernike2]
    PSF_zernike = psf.PointSpreadFunction(matrices=zernike_matrices2, N_pix=N_PIX,
                                          crop_pix=pix, diversity_coef=np.zeros(N_zern))

    defocus_zernike = np.zeros(N_zern)
    defocus_zernike[1] = diversity / (2 * np.pi)
    PSF_zernike.define_diversity(defocus_zernike)

    train_PSF, train_coef, test_PSF, test_coef = calibration.generate_dataset(PSF_zernike, N_train, N_test,
                                                                              coef_strength=coef_strength, rescale=rescale)

    # plt.figure()