{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial for POPPY: Physical Optics Propagation in PYthon" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "This document is not intended as comprehensive documentation for the ``poppy`` package. Please see [the documentation](http://pythonhosted.org/poppy/) for full details in the API, and the SPIE papers by Perrin et al. ([2012](http://adsabs.harvard.edu/abs/2012SPIE.8442E..3DP), 2014) for further background information and discussion of algorithms. However this notebook should be enough to get you started. \n", "\n", "Poppy implements an object-oriented system for modeling physical optics propagation with diffraction, particularly for telescopic and coronagraphic imaging. This tutorial covers the Fraunhofer (far-field) diffraction mode of ``poppy``, which new users should start with. Fresnel modeling is covered in a separate tutorial." ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Getting Started" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "You should be able to install poppy directly from PyPI in the usual manner: \n", "\n", "
\n", " pip install poppy --upgrade\n", "" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'1.0.4.dev122+ge08f148'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "%matplotlib inline\n", "import poppy\n", "import numpy as np\n", "import matplotlib\n", "import matplotlib.pyplot as plt\n", "\n", "matplotlib.rcParams['image.origin'] = 'lower'\n", "poppy.__version__" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "For all of the following examples, you will have more informative text output when running the code if you first enable Python’s logging mechanism to display log messages to screen. This can sometimes be more verbose than is desired, so feel free to turn this on or off as desired. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import logging\n", "logging.getLogger('poppy').setLevel(logging.WARN) \n", "#Can be logging.CRITICAL, logging.WARN, logging.INFO, logging.DEBUG for increasingly verbose output" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "## Working with OpticalElements" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "OpticalElements can be instantiated from FITS files, or created by one of a large number of analytic function definitions implemented as AnalyticOpticalElement subclasses. Typically these classes take some number of arguments to set their properties. Once instantiated, any analytic function can be displayed on screen, sampled onto a numerical grid, and/or saved to disk.:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(