{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Quickstart" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's imagine you're impatient, and all you want to do is make a pretty movie or two. Here's a good place to start. Odds are, you have a collection of `.fits` files somewhere, and you'd like to display them as a movie. To simulate your situation, let's make a directory full of files." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from playground.cartoons import create_directory_of_fits\n", "create_directory_of_fits('some-directory')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If we look in the `some-directory` directory, we see it contains four directories, each of which contain some images." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "some-directory/cam1:\r\n", "cam1-0000.fits cam1-0002.fits cam1-0004.fits cam1-0006.fits cam1-0008.fits\r\n", "cam1-0001.fits cam1-0003.fits cam1-0005.fits cam1-0007.fits cam1-0009.fits\r\n", "\r\n", "some-directory/cam2:\r\n", "cam2-0000.fits cam2-0002.fits cam2-0004.fits cam2-0006.fits cam2-0008.fits\r\n", "cam2-0001.fits cam2-0003.fits cam2-0005.fits cam2-0007.fits cam2-0009.fits\r\n", "\r\n", "some-directory/cam3:\r\n", "cam3-0000.fits cam3-0002.fits cam3-0004.fits cam3-0006.fits cam3-0008.fits\r\n", "cam3-0001.fits cam3-0003.fits cam3-0005.fits cam3-0007.fits cam3-0009.fits\r\n", "\r\n", "some-directory/cam4:\r\n", "cam4-0000.fits cam4-0002.fits cam4-0004.fits cam4-0006.fits cam4-0008.fits\r\n", "cam4-0001.fits cam4-0003.fits cam4-0005.fits cam4-0007.fits cam4-0009.fits\r\n" ] } ], "source": [ "!ls some-directory/*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Basic Animations\n", "Now, starting with these FITS, we can use the following commands to visualize those images." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from playground.tv import illustratefits, glob" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "i = illustratefits('some-directory/cam1/*.fits')\n", "i.animate('_static/a-snazzy-little-movie.mp4')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Neat! That makes us a little animation! \n", "\n", "The `illustratefits` function will make an animation out of all the files that matches the file pattern (with `glob`). It will try to find times inside the headers of those images, but if it doesn't, it will simply order images by filename. \n", "\n", "If you want, you can explicitly create a list of files to include. For example, you could feed in the same files, but in reverse, as follows." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "files = glob.glob('some-directory/cam1/*.fits')[::-1]\n", "i = illustratefits(files, title=\"now it's backwards!\")\n", "i.animate('_static/backwards-snazzy-little-movie.mp4', fps=3, dpi=200)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that we've also changed a few other things in here too. We added a `title` to the illustration, and we changed the frame per second (`fps`) and the dots per inch (`dpi`) to use when writing the animation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "