def __init__(self, unparsed): super().__init__() args = self.do_cmdline(unparsed) # plot objects phaseplot = PhasePlot(n=args.n_alpha) # to plot beta and the PSF betaplot = BetaPlot(args) # to plot the phase # complex-valued Zernike polynomials for the GPF ip = FitZern(CZern(args.n_beta), args.fit_L, args.fit_K) # real-valued Zernike polynomials for the phase phase_pol = RZern(args.n_alpha) phase_pol.make_pol_grid(ip.rho_j, ip.theta_i) # make a polar grid # real-valued Zernike coefficients alpha = np.zeros(phase_pol.nk) # set the alpha coefficients randomly if args.random: alpha1 = normal(size=alpha.size - 1) alpha1 = (args.rms / norm(alpha1)) * alpha1 alpha[1:] = alpha1 del alpha1 self.rms = args.rms self.alpha = alpha self.phase_pol = phase_pol self.ip = ip self.betaplot = betaplot self.phaseplot = phaseplot # fit beta coefficients from alpha coefficients self.alpha2beta() # make gui self.make_gui()
alpha1 = normal(size=alpha.size-1) alpha1 = (args.rms/norm(alpha1))*alpha1 alpha[1:] = alpha1 del alpha1 # evaluate the phase corresponding to alpha Phi = phase_pol.eval_grid(alpha) # evaluate the generalised pupil function P corresponding to alpha P = np.exp(1j*Phi) # estimate the beta coefficients from P beta_hat = ip.fit(P) # plot the results phaseplot = PhasePlot(n=args.n_alpha) # to plot beta and the PSF betaplot = BetaPlot(args) # to plot the phase # plot alpha p.figure(10) p.subplot2grid((1, 3), (0, 0), colspan=2) h1 = p.plot(range(1, phase_pol.nk + 1), alpha, marker='o') p.legend(h1, [r'$\alpha$']) p.ylabel('[rad]') p.xlabel('$k$') p.subplot2grid((1, 3), (0, 2)) phaseplot.plot_alpha(alpha) p.title(r'$\alpha$') p.colorbar() # plot beta
Estimate a vector of real-valued Zernike coefficients from a phase grid by taking inner products. References ---------- .. [A2015] Jacopo Antonello and Michel Verhaegen, "Modal-based phase retrieval for adaptive optics," J. Opt. Soc. Am. A 32, 1160-1170 (2015) . `url <http://dx.doi.org/10.1364/JOSAA.32.001160>`__. """ if __name__ == '__main__': # plotting stuff phaseplot = PhasePlot() # grid sizes L, K = 95, 105 # real-valued Zernike polynomials up to the 6-th radial order phase_pol = RZern(6) # FitZern computes the approximate inner products, see Eq. (B2) in [A2015] ip = FitZern(phase_pol, L, K) phase_pol.make_pol_grid(ip.rho_j, ip.theta_i) # make a polar grid # random vector of Zernike coefficients to be estimated alpha_true = normal(size=phase_pol.nk) # phase grid
from sage.all_cmdline import * from phi4 import Simulation from phase_plot import PhasePlot plt = PhasePlot(32, 32, equilibrate=1512, iterations=1512, observable=Simulation.abs_phi) plt.mass_squared = srange(-1.5, 0, 0.1) plt.coupling_constant = srange(0.1, 1, 0.1) gfx = \ plt.plot3d() + \ text3d(r'lambda', [0, 0.75, 1]) + \ text3d(r'mu squared', [-0.5, 0, 0.2]) + \ text3d(r'abs(phi)', [-1.5, 0, 2]) gfx.show()