MTFs¶
prysm
models often include analysis of Modulation Transfer Function (MTF) data. The MTF is formally defined as:
the normalized magnitude of the Fourier transform of the Point Spread Function
It is nothing more and nothing less. It may not be negative, complex-valued, or equal to any value other than unity at the origin.
Initializing an MTF model should feel similar to a PSF,
[1]:
import numpy as np
from prysm import MTF
x = y = 1/np.linspace(-1,1,128)
z = np.random.random((128,128))
mt = MTF(data=z, x=x, y=y)
%matplotlib inline
MTFs are usually created from a PSF instance
[2]:
from prysm import Pupil, PSF
pu = Pupil(dia=10, wavelength=0.5)
ps = PSF.from_pupil(pu, efl=20)
mt = MTF.from_psf(ps)
If modeling the MTF directly from a pupil plane, the intermediate PSF plane may be skipped;
[3]:
mt = MTF.from_pupil(pu, Q=2, efl=20) # Q, efl same as PSF.from_pupil
Much like a PSF or other Convolvable, MTFs have quick-access slices
[4]:
mt.slices().azavg
[4]:
(array([ 0. , 3.95244712, 7.90489424, 11.85734136,
15.80978848, 19.7622356 , 23.71468272, 27.66712984,
31.61957696, 35.57202409, 39.52447121, 43.47691833,
47.42936545, 51.38181257, 55.33425969, 59.28670681,
63.23915393, 67.19160105, 71.14404817, 75.09649529,
79.04894241, 83.00138953, 86.95383665, 90.90628377,
94.85873089, 98.81117801, 102.76362514, 106.71607226,
110.66851938, 114.6209665 , 118.57341362, 122.52586074,
126.47830786, 130.43075498, 134.3832021 , 138.33564922,
142.28809634, 146.24054346, 150.19299058, 154.1454377 ,
158.09788482, 162.05033194, 166.00277906, 169.95522618,
173.90767331, 177.86012043, 181.81256755, 185.76501467,
189.71746179, 193.66990891, 197.62235603, 201.57480315,
205.52725027, 209.47969739, 213.43214451, 217.38459163,
221.33703875, 225.28948587, 229.24193299, 233.19438011,
237.14682723, 241.09927436, 245.05172148, 249.0041686 ,
252.95661572, 256.90906284, 260.86150996, 264.81395708,
268.7664042 , 272.71885132, 276.67129844, 280.62374556,
284.57619268, 288.5286398 , 292.48108692, 296.43353404,
300.38598116, 304.33842828, 308.29087541, 312.24332253,
316.19576965, 320.14821677, 324.10066389, 328.05311101,
332.00555813, 335.95800525, 339.91045237, 343.86289949,
347.81534661, 351.76779373, 355.72024085, 359.67268797,
363.62513509, 367.57758221, 371.53002933, 375.48247646,
379.43492358, 383.3873707 , 387.33981782, 391.29226494,
395.24471206, 399.19715918, 403.1496063 , 407.10205342,
411.05450054, 415.00694766, 418.95939478, 422.9118419 ,
426.86428902, 430.81673614, 434.76918326, 438.72163038,
442.67407751, 446.62652463, 450.57897175, 454.53141887,
458.48386599, 462.43631311, 466.38876023, 470.34120735,
474.29365447, 478.24610159, 482.19854871, 486.15099583,
490.10344295, 494.05589007, 498.00833719, 501.96078431,
505.91323143, 509.86567855, 513.81812568, 517.7705728 ,
521.72301992, 525.67546704, 529.62791416, 533.58036128,
537.5328084 , 541.48525552, 545.43770264, 549.39014976,
553.34259688, 557.295044 , 561.24749112, 565.19993824,
569.15238536, 573.10483248, 577.0572796 , 581.00972673,
584.96217385, 588.91462097, 592.86706809, 596.81951521,
600.77196233, 604.72440945, 608.67685657, 612.62930369,
616.58175081, 620.53419793, 624.48664505, 628.43909217,
632.39153929, 636.34398641, 640.29643353, 644.24888065,
648.20132778, 652.1537749 , 656.10622202, 660.05866914,
664.01111626, 667.96356338, 671.9160105 , 675.86845762,
679.82090474, 683.77335186, 687.72579898, 691.6782461 ,
695.63069322, 699.58314034, 703.53558746, 707.48803458,
711.4404817 , 715.39292883, 719.34537595, 723.29782307,
727.25027019, 731.20271731, 735.15516443, 739.10761155,
743.06005867, 747.01250579, 750.96495291, 754.91740003,
758.86984715, 762.82229427, 766.77474139, 770.72718851,
774.67963563, 778.63208275, 782.58452987, 786.536977 ,
790.48942412, 794.44187124, 798.39431836, 802.34676548,
806.2992126 , 810.25165972, 814.20410684, 818.15655396,
822.10900108, 826.0614482 , 830.01389532, 833.96634244,
837.91878956, 841.87123668, 845.8236838 , 849.77613092,
853.72857805, 857.68102517, 861.63347229, 865.58591941,
869.53836653, 873.49081365, 877.44326077, 881.39570789,
885.34815501, 889.30060213, 893.25304925, 897.20549637,
901.15794349, 905.11039061, 909.06283773, 913.01528485,
916.96773197, 920.9201791 , 924.87262622, 928.82507334,
932.77752046, 936.72996758, 940.6824147 , 944.63486182,
948.58730894, 952.53975606, 956.49220318, 960.4446503 ,
964.39709742, 968.34954454, 972.30199166, 976.25443878,
980.2068859 , 984.15933302, 988.11178015, 992.06422727,
996.01667439, 999.96912151, 1003.92156863, 1007.87401575]),
array([1.00000000e+00, 9.94097672e-01, 9.89117775e-01, 9.84394062e-01,
9.79468091e-01, 9.74533237e-01, 9.69554731e-01, 9.64537867e-01,
9.59518878e-01, 9.54516791e-01, 9.49502751e-01, 9.44477472e-01,
9.39454415e-01, 9.34434579e-01, 9.29401831e-01, 9.24376615e-01,
9.19364085e-01, 9.14348856e-01, 9.09320218e-01, 9.04298404e-01,
8.99282529e-01, 8.94267461e-01, 8.89248258e-01, 8.84234552e-01,
8.79220956e-01, 8.74208979e-01, 8.69203917e-01, 8.64194357e-01,
8.59185056e-01, 8.54183405e-01, 8.49186128e-01, 8.44187920e-01,
8.39193622e-01, 8.34203302e-01, 8.29209927e-01, 8.24219107e-01,
8.19236823e-01, 8.14257203e-01, 8.09273672e-01, 8.04295010e-01,
7.99318832e-01, 7.94343789e-01, 7.89379369e-01, 7.84416408e-01,
7.79451894e-01, 7.74494137e-01, 7.69546532e-01, 7.64596888e-01,
7.59646666e-01, 7.54707842e-01, 7.49765201e-01, 7.44825233e-01,
7.39895274e-01, 7.34970446e-01, 7.30049636e-01, 7.25133566e-01,
7.20220883e-01, 7.15309874e-01, 7.10405126e-01, 7.05505623e-01,
7.00607625e-01, 6.95715998e-01, 6.90830789e-01, 6.85954190e-01,
6.81078508e-01, 6.76206527e-01, 6.71341934e-01, 6.66484731e-01,
6.61632226e-01, 6.56785163e-01, 6.51940424e-01, 6.47103533e-01,
6.42273726e-01, 6.37447202e-01, 6.32628424e-01, 6.27816824e-01,
6.23007959e-01, 6.18206676e-01, 6.13415736e-01, 6.08631311e-01,
6.03848881e-01, 5.99071723e-01, 5.94302599e-01, 5.89543145e-01,
5.84792036e-01, 5.80044287e-01, 5.75300942e-01, 5.70568877e-01,
5.65843977e-01, 5.61126589e-01, 5.56418258e-01, 5.51716796e-01,
5.47020136e-01, 5.42332176e-01, 5.37651986e-01, 5.32979405e-01,
5.28315311e-01, 5.23661656e-01, 5.19013280e-01, 5.14374843e-01,
5.09744291e-01, 5.05123412e-01, 5.00511532e-01, 4.95907921e-01,
4.91310716e-01, 4.86722250e-01, 4.82144788e-01, 4.77576895e-01,
4.73019490e-01, 4.68471614e-01, 4.63930082e-01, 4.59398541e-01,
4.54877284e-01, 4.50369272e-01, 4.45870546e-01, 4.41378062e-01,
4.36895035e-01, 4.32424506e-01, 4.27966429e-01, 4.23517322e-01,
4.19078479e-01, 4.14650812e-01, 4.10233055e-01, 4.05828310e-01,
4.01432912e-01, 3.97048867e-01, 3.92675648e-01, 3.88315303e-01,
3.83966532e-01, 3.79628667e-01, 3.75301673e-01, 3.70987952e-01,
3.66687484e-01, 3.62398632e-01, 3.58121194e-01, 3.53857260e-01,
3.49603985e-01, 3.45364346e-01, 3.41137264e-01, 3.36923497e-01,
3.32725321e-01, 3.28538754e-01, 3.24364049e-01, 3.20204869e-01,
3.16056006e-01, 3.11923649e-01, 3.07804928e-01, 3.03699414e-01,
2.99609345e-01, 2.95533915e-01, 2.91473758e-01, 2.87427491e-01,
2.83393985e-01, 2.79377793e-01, 2.75375682e-01, 2.71388716e-01,
2.67417516e-01, 2.63461535e-01, 2.59521815e-01, 2.55598722e-01,
2.51690560e-01, 2.47799978e-01, 2.43925890e-01, 2.40067463e-01,
2.36225899e-01, 2.32401768e-01, 2.28595197e-01, 2.24806141e-01,
2.21032365e-01, 2.17278597e-01, 2.13543080e-01, 2.09824809e-01,
2.06124392e-01, 2.02442820e-01, 1.98780451e-01, 1.95135878e-01,
1.91510899e-01, 1.87905024e-01, 1.84322539e-01, 1.80760141e-01,
1.77208957e-01, 1.73679822e-01, 1.70175047e-01, 1.66690830e-01,
1.63225380e-01, 1.59783080e-01, 1.56361937e-01, 1.52961344e-01,
1.49583185e-01, 1.46227033e-01, 1.42893653e-01, 1.39582578e-01,
1.36294968e-01, 1.33030917e-01, 1.29789136e-01, 1.26571872e-01,
1.23379492e-01, 1.20210416e-01, 1.17066050e-01, 1.13948136e-01,
1.10856557e-01, 1.07789271e-01, 1.04748263e-01, 1.01734357e-01,
9.87466982e-02, 9.57853254e-02, 9.28521643e-02, 8.99469365e-02,
8.70714189e-02, 8.42251481e-02, 8.14061743e-02, 7.86157006e-02,
7.58570607e-02, 7.31309690e-02, 7.04357261e-02, 6.77701487e-02,
6.51366438e-02, 6.25364639e-02, 5.99709775e-02, 5.74380672e-02,
5.49419492e-02, 5.24794077e-02, 5.00525932e-02, 4.76626808e-02,
4.53101660e-02, 4.29958038e-02, 4.07217572e-02, 3.84848060e-02,
3.62907841e-02, 3.41372565e-02, 3.20270905e-02, 2.99613776e-02,
2.79396095e-02, 2.59615107e-02, 2.40344828e-02, 2.21544009e-02,
2.03256361e-02, 1.85467348e-02, 1.68239297e-02, 1.51546317e-02,
1.35462449e-02, 1.19957012e-02, 1.05081388e-02, 9.08756489e-03,
7.73768814e-03, 6.46015940e-03, 5.26437329e-03, 4.14982861e-03,
3.13280144e-03, 2.21578487e-03, 1.41685604e-03, 7.51529327e-04,
2.99346589e-04, 7.04332525e-05, 6.10434825e-06, 1.24805758e-08]))
The MTF at exact frequencies may be queried through any of the following methods: exact_polar
, takes arguments of freqs and azimuths. If there is a single frequency and multiple azimuths, the MTF at each azimuth and and the specified radial spatial frequency will be returned. The reverse is true for a single azimuth and multiple frequencies. exact_xy
follows the same semantics, but with Cartesian coordinates instead of polar. exact_x
and exact_y
both take a single argument of
freq, which may be an int, float, or ndarray.
Finally, MTFs may be plotted:
[5]:
mt.slices().plot(['x', 'y'], xlim=(0,1000), fig=None, ax=None)
mt.plot2d(xlim=1000, power=1/2, fig=None, ax=None)
[5]:
(<Figure size 640x480 with 2 Axes>,
<matplotlib.axes._subplots.AxesSubplot at 0x1e7489045c8>)
all arguments have these default values. The axes of plot2d will span (-max_freq, max_freq) on both x and y.
This example should be familiar as the diffraction limited MTF of a circular aperture.