{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Dependencies | Version\n", "--- | ---\n", "SatPy | 0.25.1\n", "PyResample | 1.17.0\n", "PySpectral | 0.10.4\n", "Trollimage | 1.14.0\n", "PyKdtree | 1.3.4\n", "XArray | 0.16.1\n", "Dask | 2.30.0\n", "ImageIO | 2.9.0\n", "ffmpeg | 4.3.1\n", "\n", "\n", "# GOES-16 ABI - True Color Animation - Hurricane Florence\n", "\n", "\n", "\n", "This example shows how to take multiple time steps of ABI data and combine them in to a single mp4 movie file as an animation. The example uses 100 frames of mesoscale images from the GOES-16 ABI instrument on September 11th, 2018 from 1300Z to 1440Z with one image every minute. The \"%%time\" magic command is used in jupyter notebook to time the entire cell's execution. This example took about 8 minutes and 30 seconds on a 2015 macbook using 8 dask threaded workers.\n", "\n", "The movie produced has been hosted on twitter: https://twitter.com/PyTrollOrg/status/1039555399433834497\n", "\n", "Full resolution video: https://www.ssec.wisc.edu/~davidh/satpy/true_color_20180911_130021.mp4\n", "\n", "The frames in the movie are 500m resolution true color images with solar zenith and rayleigh scattering corrections applied. A ratio sharpening technique was also used to bring out more detail from the lower resolution input bands. All of this is pre-configured for the ABI 'true_color' composite in satpy and is done from python." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%time\n", "import os\n", "import warnings\n", "import logging\n", "from satpy import Scene\n", "from glob import glob\n", "from satpy import MultiScene\n", "logging.basicConfig(level=logging.ERROR) # don't show warnings\n", "warnings.simplefilter('ignore') # don't show warnings\n", "\n", "BASE_DIR = '/data/satellite/abi/20180911_florence_100'\n", "\n", "mscn = MultiScene.from_files(glob(os.path.join(BASE_DIR, 'OR*-RadM1*.nc')), reader='abi_l1b')\n", "mscn.load(['true_color'])\n", "new_mscn = mscn.resample(resampler='native')\n", "new_mscn.save_animation('{name}_{start_time:%Y%m%d_%H%M%S}.mp4', fps=5)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import Video\n", "Video('true_color_20180911_130021.mp4', width=480, height=480)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Advanced Usage\n", "\n", "It is also possible to use dask in a multiprocess environment to compute multiple animation frames at once. We do this by first creating a dask `Client` object which will create external dask workers for us. We then pass this client object to `save_animation` along with a `batch_size`. This tells Satpy to compute `16` frames at a time by using the parallel multiprocess workers created by dask. Without this, Satpy will default to computing one frame at a time. Depending on your system, this can cut off minutes of processing time.\n", "\n", "Note: The creation of the `Client` below includes making a dashboard available for viewing tasks as they are worked on by dask." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from dask.distributed import Client\n", "client = Client()\n", "client" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%time\n", "import os\n", "import warnings\n", "import logging\n", "from satpy import Scene\n", "from glob import glob\n", "from satpy import MultiScene\n", "logging.basicConfig(level=logging.ERROR) # don't show warnings\n", "warnings.simplefilter('ignore') # don't show warnings\n", "\n", "BASE_DIR = '/data/satellite/abi/20180911_florence_100'\n", "\n", "mscn = MultiScene.from_files(glob(os.path.join(BASE_DIR, 'OR*-RadM1*.nc')), reader='abi_l1b')\n", "mscn.load(['true_color'])\n", "new_mscn = mscn.resample(resampler='native')\n", "new_mscn.save_animation('{name}_{start_time:%Y%m%d_%H%M%S}.mp4', fps=5, batch_size=16, client=client)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.7.8" } }, "nbformat": 4, "nbformat_minor": 4 }