{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Load Himawari-8 AHI data and generate true color RGB" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading the data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from satpy import Scene, find_files_and_readers\n", "from satpy.resample import get_area_def\n", "from datetime import datetime" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

We start by locating and specifying the AHI data to read:

" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "files = find_files_and_readers(start_time=datetime(2015, 2, 7, 3, 0),\n", " end_time=datetime(2015, 2, 7, 3, 10),\n", " base_dir=\"/data/satellite/Himawari-8/HSD\",\n", " reader='ahi_hsd')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example is loading the Himawari data in the Himawari Standard Data (HSD) format. But you can load HRIT formatted data as well with the same code, except specifying the adequate reader (`ahi_hrit`) in the argument list above.\n", "\n", "

We create the scene object

" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "scn = Scene(sensor='ahi', filenames=files)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we load the `true_color` composite" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "rgbname = 'true_color'" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/a001673/.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": [ "scn.load([rgbname])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate a full disk image\n", "\n", "Beware that this step might need more than 10 GB memory available on the processing machine (depending on the number of cpu cores)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "new_scn = scn.resample(scn.min_area(), resampler='native')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The above line lowers the resolution to the coarser channel. If you want instead to generate a full resolution image, use instead: `scn.max_area()` in the resample call. This will however need quite a lot of resources." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "new_scn.save_dataset(rgbname, filename='himawari_ahi_truecolor_{datetime}.png'.format(datetime=scn.start_time.strftime('%Y%m%d%H%M')))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate the composite on a Region of Interest\n", "Now let us define a map-projection and a sub area, and project the data on this area. We use Pyresample to define the area. This definition can also be put in the area.yaml configuration file" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "from pyresample.utils import get_area_def\n", "area_id = 'japan'\n", "x_size = 2407\n", "y_size = 1655\n", "area_extent = (-1203877.326193321, -754860.2505908236, 1203877.3261933187, 900373.6358697552)\n", "projection = '+proj=laea +lat_0=37.5 +lon_0=137.5 +ellps=WGS84'\n", "description = \"Japan\"\n", "proj_id = 'laea_137.5_37.5'\n", "areadef = get_area_def(area_id, description, proj_id, projection,x_size, y_size, area_extent)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "local_scene = scn.resample(areadef)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/a001673/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in greater\n", " return func(*args2)\n", "/home/a001673/.local/lib/python2.7/site-packages/dask/local.py:271: RuntimeWarning: invalid value encountered in log10\n", " return func(*args2)\n" ] }, { "data": { "text/plain": [ "" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "local_scene.show(rgbname)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] } ], "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 }