{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simulating Images\n", "\n", "In class, we talked about how a telescope's *optics* form an image at a focal plane and a telescope's *detector* records that image. We've added two cartoon functions to `henrietta` that help us understand the basics of this process: one that uses online star catalogs and your inputs to (very approximately) simulate a patch of the sky seen through the optics of a telescope, and one that simulates a detector recording that image." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt, numpy as np\n", "from henrietta import imaging" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate the Optics of Our Telescope\n", "The `simulate_optics` function produces a simulation of the image that would appear at the focal plane of a telescope, expressed in units of photons/s/pixel. These images are \"perfect\", in the sense that they are an expectation for the rate at which photons will be hitting a detector." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fluximage = imaging.simulate_optics(target='GJ 1132', \n", " collectingarea=1.0, \n", " pixelscale=21, \n", " fov=180, \n", " background=0.0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `plt.imshow` function (with its many options!) can display that image for us to peruse." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(fluximage)\n", "plt.colorbar(label='photons/s/pixel');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simulate the Detector Behind Our Telescope\n", "The `simulate_detector` function takes an image at the focal plane (in photons/s), and simulates the total number of photons the detector would record. These are noisy images, with the effects of photon noise included." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "photonimage = imaging.simulate_detector(fluximage, \n", " exptime=1.0, \n", " quantumefficiency=0.001, \n", " readnoise=10.0)\n", "plt.imshow(photonimage)\n", "plt.colorbar(label='photons/pixel');" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you run `simulate_detector` several times, you'll see you keep getting slightly different images. The function is simulating the actual detection of photons, and because we know photon-counting measurements always have uncertainties associated with them ($\\sigma = \\sqrt{N}$)ca" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Simulate Your Own Star, with your Own Telescope** \n", "\n", "Here are some ways you might think about playing with these tools: Pick a star and simulate some images. How does a flux image (photons/s/pixel) look different with Kepler, TESS, or a cell phone camera? How does the appearance of a photon image (photons/pixel) change if you change the exposure time? What challenges would be unique to each telescope? Play with the `background` keyword in `simulate_optics`; why is it difficult to see stars during the day (on Earth)?" ] } ], "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.6.5" } }, "nbformat": 4, "nbformat_minor": 2 }