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

Make a MODIS true color image using Satpy and Pyspectral

\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" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In order for the modis reader (hdf eos l1b), you need the pyhdf python package to be installed with:\n", "\n", "`pip install python-hdf4`\n", "\n", "or if running a conda environment:\n", "\n", "`conda install pyhdf`" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from satpy.scene import Scene\n", "from satpy import find_files_and_readers\n", "from datetime import datetime" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "DATA_DIR = \"/home/a000680/data/polar_in/direct_readout/eos/lvl1\"" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(0, ['/home/a000680/usr/src/satpy/satpy/etc/readers/hdfeos_l1b.yaml'], ['hdfeos_l1b'])\n" ] } ], "source": [ "myfiles = find_files_and_readers(base_dir=DATA_DIR,\n", " sensor=\"modis\",\n", " start_time=datetime(2016, 3, 30, 11, 40),\n", " end_time=datetime(2016, 3, 30, 12, 5),\n", " reader='modis_l1b')\n", "scn = Scene(filenames=myfiles)" ] }, { "cell_type": "code", "execution_count": 4, "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": [ "composite_name = 'true_color'\n", "scn.load([composite_name], resolution=1000)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "areaid = 'eurol'\n", "lcn = scn.resample(areaid, radius_of_influence=10000)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lcn.show(composite_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "code", "execution_count": 7, "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 log10\n", " return func(*args2)\n" ] } ], "source": [ "lcn.save_dataset(composite_name, './modis_%s_rgb_%s_%s.png' %\n", " (composite_name, lcn.attrs['start_time'].strftime('%Y%m%d%H%M'), areaid))" ] } ], "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }