{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# How to cut out Target Pixel Files from Kepler Superstamps or TESS FFIs?\n", "\n", "You can use `lightkurve` to cut Target Pixel Files (TPFs) out of a series of standard astronomical images, such as [K2 Superstamp Mosaics](https://archive.stsci.edu/prepds/k2superstamp/) or TESS Full-Frame-Images (FFIs).\n", "This brief tutorial will demonstrate how!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's assume you have downloaded a set [simulated TESS FFI images](http://archive.stsci.edu/tess/ete-6.html) to a local directory called `data`. `lightkurve` will assume that the files are given in *time order*. So we'll sort the filenames first:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from glob import glob\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we use the `KeplerTargetPixelFile` class and its function `from_fits_images()` to create the new TPF. This will cut out around the position keyword. You can pass a pixel position in units of the original image or RA and Dec coordinates." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from lightkurve import KeplerTargetPixelFile\n", "from astropy.coordinates import SkyCoord" ] }, { "cell_type": "markdown", "metadata": { "scrolled": false }, "source": [ "```python\n", "fnames = np.sort(glob('data/*.fits'))\n", "tpf = KeplerTargetPixelFile.from_fits_images(images=fnames, \n", " position=SkyCoord(257.13700, 24.48958, unit='deg'), \n", " size=(9,9),\n", " target_id='MyCutOut')\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We then have a fully functioning `KeplerTargetPixelFile` object! You can read more about such objects in the [tutorial on their use](https://docs.lightkurve.org/tutorials/1.02-target-pixel-files.html)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "#tpf.plot();" ] } ], "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.7" } }, "nbformat": 4, "nbformat_minor": 2 }