{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Calculating a PSF for WFIRST Wide Field Instrument\n", "\n", "This demonstration notebook offers a graphical interface to the basic functionality of WebbPSF-WFIRST, as well an example of performing a calculation with the Python scripting interface suited for more advanced calculations.\n", "\n", "## Background and boilerplate\n", "\n", "Before we can do a calculation, we must set up the notebook by importing the packages we use and setting up logging output so we can follow the progress of the calculations. The cell below imports WebbPSF and standard scientific Python tools, and configures some options to make plots prettier.\n", "\n", "**You shouldn't need to edit anything in the next cell, just go ahead and run it.**\n", "\n", "*(Note: click in a cell and use **Shift + Enter** or click the play button above to run it)*" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib\n", "matplotlib.rcParams['figure.figsize'] = (16, 7) # make the default figure size larger\n", "matplotlib.rcParams['image.interpolation'] = 'nearest' # don't blur/smooth image plots\n", "from matplotlib import pyplot as plt\n", "import webbpsf\n", "import webbpsf.wfirst" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The next cell tells WebbPSF to log information about what it is doing so that we can watch the progress of the calculation:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "WebbPSF log messages of level INFO and above will be shown.\n", "WebbPSF log outputs will be directed to the screen.\n" ] } ], "source": [ "webbpsf.setup_logging()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note:** As you explore in this notebook, you may see certain warnings that look like this:\n", "\n", "
\n", "\n", "For the most part, warnings are safe to ignore. In particular, warnings referencing the matplotlib plotting library or the FITS library in Astropy don't indicate anything that could affect the accuracy of the calculations." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Using the WFI model in WebbPSF\n", "\n", "Each instrument in WebbPSF is represented as a Python `class`, and the Wide Field Instrument model is in `webbpsf.wfirst.WFI`. We can to instantiate one to work with, in the same was as any of the JWST instruments." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "wfi = webbpsf.wfirst.WFI()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Using the notebook interface\n", "\n", "There's a notebook-friendly interface for the Wide Field Instrument PSF model. Bring it up in your notebook by running the following cell, then experiment with the different options, or read on for more explanation. \n", "\n", "Note that the calculations will typically take several seconds to run. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "scrolled": false }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "e019a47f5a3b405883b11436ae713a3e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "ToggleButtons(description='Filter:', options=('Z087', 'Y106', 'J129', 'H158', 'F184', 'W149', 'R062'), value='…" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b4406dea522445f7a68b053c33a78a18", "version_major": 2, "version_minor": 0 }, "text/plain": [ "HTML(value='\\n \\n Monochroma…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ccdee2ffd0974ab1bc77f57e559f924d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Checkbox(value=False, description='Monochromatic calculation?'), HTML(value='')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "96ebfdd5d2cd406d9590913684c2a30d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Select(description='Source spectrum', index=43, options=('Power law F_nu ~ nu^(3)', 'Power law F_nu ~ nu^(2)',…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ac79c708c93543bb8cb622ab0dcc49cf",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='
')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f5b9878971e9414494c3d83155c4e72c",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Dropdown(description='Detector:', options=('SCA01', 'SCA02', 'SCA03', 'SCA04', 'SCA05', 'SCA06', 'SCA07', 'SCA…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "f25c8cad5ed94d7d89cdb84b3fcc99f7",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"ToggleButtons(description='Detector field point:', index=2, options=('Top left', 'Bottom left', 'Center', 'Top…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "acb4b6c872ea495cb3b0624f15872eb6",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='
')"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "0938cfb5cc2f4f0c980a6b92ac9f7186",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='Calculate PSF', style=ButtonStyle()), Button(description='Display Optical S…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "23e427a553bc45a7b3f60aa09c427ad3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='