{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "

Read VIIRS SDR and make a ratio sharpened true color RGB with I- and M-bands

\n", "\n", "Created with:\n", "\n", "Package | Version\n", "--- | ---\n", "SatPy | 0.9.0\n", "PyResample | 1.10.1\n", "Trollimage | 1.5.3\n", "PyKdtree | 1.3.1\n" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "from satpy.scene import Scene\n", "from satpy import find_files_and_readers\n", "from glob import glob\n", "from datetime import datetime" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Find all the SDR files for the scene

" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "myfiles = glob(\"/home/a000680/data/polar_in/direct_readout/npp/lvl1/npp_20150421_1143_18033/*h5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

...or select only a part of the scene

" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/a000680/.local/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", " from ._conv import register_converters as _register_converters\n" ] } ], "source": [ "DATA_DIR = \"/home/a000680/data/polar_in/direct_readout/npp/lvl1/npp_20150421_1143_18033\"\n", "myfiles = find_files_and_readers(base_dir=DATA_DIR,\n", " start_time=datetime(2015, 4, 21, 11, 45),\n", " end_time=datetime(2015, 4, 21, 11, 52),\n", " reader='viirs_sdr')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Create the scene object

" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "scene = Scene(filenames=myfiles, reader='viirs_sdr')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Load the data for the requested RGB

" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "scene.load(['true_color'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Make sure all data are on the same grid and resolution

" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "natscn = scene.resample(resampler='native')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is necessary since the True Color composite chosen use both I- and M-bands, with different resolutions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Display

" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "natscn.show('true_color')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you want to save the image to disk?" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/a000680/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in less\n", " return func(*args2)\n", "/home/a000680/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in greater_equal\n", " return func(*args2)\n", "/home/a000680/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in log10\n", " return func(*args2)\n" ] } ], "source": [ "natscn.save_dataset('true_color', filename='./viirs_true_color.png')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.5" } }, "nbformat": 4, "nbformat_minor": 2 }