下記Pythonコードのax.plotのグラフが表示できません。

実現したいこと

下記リンク先のPythonコードをVS codeで実行したのですが、ax.plotのグラフが表示されません。
aperture図はplt.imshow()の下行にplt.show()を追記して表示できるようになりました。

https://prysm.readthedocs.io/en/stable/tutorials/Lens-MTF-Model.html

上記リンク先のスクロールして下の方にあるグラフはどうしたら表示できるでしょうか。
どなたか教えてください。
何卒よろしくお願いいたします。

発生している問題・分からないこと

下記Pythonコードのax.plotが表示できません。

該当のソースコード

from prysm.coordinates import make_xy_grid, cart_to_polar from prysm.geometry import regular_polygon from matplotlib import pyplot as plt efl = 50 fno = 8 x, y = make_xy_grid(256, diameter=efl/fno) dx = x[0,1]-x[0,0] r, t = cart_to_polar(x, y) radius = efl/fno/2 rho = r / radius n_sides = 14 aperture = regular_polygon(n_sides, radius, x, y) plt.imshow(aperture, origin='lower') plt.show() from prysm.polynomials import zernike_nm from prysm.propagation import Wavefront wvl = 0.55 # mid visible band, um wfe_nm_rms = wvl/14*1e3 # nm, 3/4 of a wave, 1e3 = um to nm mode = zernike_nm(4, 0, rho, t) opd = mode * wfe_nm_rms pup = Wavefront.from_amp_and_phase(aperture, opd, wvl, dx) coherent_psf = pup.focus(efl, Q=2) from prysm.otf import mtf_from_psf, diffraction_limited_mtf psf = coherent_psf.intensity mtf = mtf_from_psf(psf) fx, _ = mtf.slices().x fig, ax = mtf.slices().plot(['x', 'y', 'azavg'], xlim=(0,200)) difflim = diffraction_limited_mtf(fno, wvl, fx) ax.plot(fx, difflim, ls=':', c='k', alpha=0.75, zorder=1) ax.set(xlabel='Spatial frequency, cy/mm', ylabel='MTF') wfe_nm_rms = wvl/14*1e3 mode = zernike_nm(3, 1, rho, t) # only this line changed opd = mode * wfe_nm_rms pup = Wavefront.from_amp_and_phase(aperture, opd, wvl, dx) coherent_psf = pup.focus(efl, Q=2) psf = coherent_psf.intensity mtf = mtf_from_psf(psf, psf.dx) fig, ax = mtf.slices().plot(['x', 'y', 'azavg'], xlim=(0,200)) ax.plot(fx, difflim, ls=':', c='k', alpha=0.75, zorder=1) ax.set(xlabel='Spatial frequency, cy/mm', ylabel='MTF')

試したこと・調べたこと

上記の詳細・結果

plt.imshow()は表示できました。

補足

Python3, VS CODE

コメントを投稿

0 コメント