def measure_at_defocus(self, fi): """Apply the fi-th defocus with the DM and perform the measurements. Returns (PSF, SH, alpha_residual, u_real, ts). PSF: measured / simulated PSF sub image SH: measured full SH image / zero alpha_residual: SH estimated residual aberration / alpha_ab + alpha_dm u_real: DM control signal including offset / zero ts: timestamp """ self.alpha_dm[:] = 0 self.alpha_dm[3] = enz.get_defocus(self.cfg.focus_positions[fi])
def plot_beta(self, beta): psfplot = self.psfplot # pick the PSF and Zernike objects cpsf = psfplot.cpsf czern = cpsf.czern nn, mm = 2, math.ceil(psfplot.fspace.size // 2) p.figure(1) p.clf() for fi, f in enumerate(psfplot.fspace): p.subplot(nn, mm, fi + 1) # plot the PSF psfplot.plot_beta_f(beta, fi) p.colorbar() # defocus in rad p.title('d={:.1f}'.format(enz.get_defocus(f))) p.figure(2) p.clf() # Zernike coefficients of alpha_true and alpha_hat p.subplot(3, 1, 1) p.plot(range(1, czern.nk + 1), beta.real, marker='o') p.ylabel('[rad]') p.legend([r'$\beta$ real']) p.subplot(3, 1, 2) p.plot(range(1, czern.nk + 1), beta.imag, marker='o') p.ylabel('[rad]') p.legend([r'$\beta$ imag']) p.subplot(3, 1, 3) p.bar(range(1, czern.nk + 1), np.abs(beta)) p.xlabel('Noll index') p.ylabel('[rad]') p.legend([r'$|\beta|$'])
def plot_beta(self, beta): psfplot = self.psfplot # pick the PSF and Zernike objects cpsf = psfplot.cpsf czern = cpsf.czern nn, mm = 2, math.ceil(psfplot.fspace.size//2) p.figure(1) p.clf() for fi, f in enumerate(psfplot.fspace): p.subplot(nn, mm, fi + 1) # plot the PSF psfplot.plot_beta_f(beta, fi) p.colorbar() # defocus in rad p.title('d={:.1f}'.format(enz.get_defocus(f))) p.figure(2) p.clf() # Zernike coefficients of alpha_true and alpha_hat p.subplot(3, 1, 1) p.plot(range(1, czern.nk + 1), beta.real, marker='o') p.ylabel('[rad]') p.legend([r'$\beta$ real']) p.subplot(3, 1, 2) p.plot(range(1, czern.nk + 1), beta.imag, marker='o') p.ylabel('[rad]') p.legend([r'$\beta$ imag']) p.subplot(3, 1, 3) p.bar(range(1, czern.nk + 1), np.abs(beta)) p.xlabel('Noll index') p.ylabel('[rad]') p.legend([r'$|\beta|$'])
self.plot_psf(U) if __name__ == '__main__': # handy object for plotting the PSF psfplot = PSFPlot() # beta (diffraction-limited), N_beta = cpsf.czern.nk beta = np.zeros(psfplot.cpsf.czern.nk, dtype=np.complex) beta[0] = 1.0 beta[5] = 1j * 0.3 beta[6] = -1j * 0.3 # plot the results nn, mm = 2, math.ceil(psfplot.fspace.size // 2) p.figure(1) for fi, f in enumerate(psfplot.fspace): ax = p.subplot(nn, mm, fi + 1) # plot the psf psfplot.plot_beta_f(beta, fi) p.colorbar() # defocus in rad p.title('d={:.1f}'.format(enz.get_defocus(f))) p.tight_layout() p.show()
self.plot_psf(U) if __name__ == '__main__': # handy object for plotting the PSF psfplot = PSFPlot() # beta (diffraction-limited), N_beta = cpsf.czern.nk beta = np.zeros(psfplot.cpsf.czern.nk, dtype=np.complex) beta[0] = 1.0 beta[5] = 1j*0.3 beta[6] = -1j*0.3 # plot the results nn, mm = 2, math.ceil(psfplot.fspace.size//2) p.figure(1) for fi, f in enumerate(psfplot.fspace): ax = p.subplot(nn, mm, fi + 1) # plot the psf psfplot.plot_beta_f(beta, fi) p.colorbar() # defocus in rad p.title('d={:.1f}'.format(enz.get_defocus(f))) p.tight_layout() p.show()