{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# MTFs\n", "\n", "`prysm` models often include analysis of Modulation Transfer Function (MTF) data. The MTF is formally defined as:\n", "\n", "> the normalized magnitude of the Fourier transform of the Point Spread Function\n", "\n", "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.\n", "\n", "Initializing an MTF model should feel similar to a [PSF](./PSFs.ipynb)," ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from prysm import MTF\n", "x = y = 1/np.linspace(-1,1,128)\n", "z = np.random.random((128,128))\n", "mt = MTF(data=z, x=x, y=y)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "MTFs are usually created from a PSF instance" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from prysm import Pupil, PSF\n", "pu = Pupil(dia=10, wavelength=0.5)\n", "ps = PSF.from_pupil(pu, efl=20)\n", "mt = MTF.from_psf(ps)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If modeling the MTF directly from a pupil plane, the intermediate PSF plane may be skipped;" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mt = MTF.from_pupil(pu, Q=2, efl=20) # Q, efl same as PSF.from_pupil" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Much like a PSF or other Convolvable, MTFs have quick-access slices" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mt.tan, mt.sag" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The tangential MTF is a slice through the x=0 axis, and assumes the usual optics sign convention of an object extended in y. The sagittal MTF is a slice through the y=0 axis.\n", "\n", "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_tan` and `exact_sag` both take a single argument of freq, which may be an int, float, or ndarray.\n", "\n", "Finally, MTFs may be plotted:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "mt.plot_tan_sag(max_freq=1000, fig=None, ax=None, labels=('Tangential', 'Sagittal'))\n", "mt.plot2d(max_freq=1000, power=2, fig=None, ax=None)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "all arguments have these default values. The axes of plot2d will span (-max_freq, max_freq) on both x and y.\n", "\n", "This example should be familiar as the diffraction limited MTF of a circular aperture." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }