{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Dependencies | Version\n", "--- | ---\n", "SatPy | 0.9.0\n", "PyResample | 1.10.1\n", "Trollimage | 1.5.3\n", "PyKdtree | 1.3.1\n", "\n", "\n", "# Quickstart with EARS-NWC" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

In December 2012 EUMETSAT extended the EARS services to include a new service with the purpose of supporting European users with cloud information\n", "from polar orbiting satellites in near real time.

\n", "

This EARS-NWC service provides the parameters Cloud Mask, Cloud Type and\n", "Cloud Top Temperature and Height (CTTH) as derived using the Polar Platform\n", "System (PPS) software package from the NWC SAF. The products are derived\n", "from AVHRR data received at the EARS core stations with a reception coverage including Europe and the North Atlantic. Products are disseminated on EUMETCast (EUMETSAT data channel 1) with a timeliness better than 30\n", "minutes, and available in netCDF4 format. The geolocation information is available on a tie-point grid and stored in each product.\n", "

At the moment the satellites contributing to the service are Metop-B and NOAA-19.

" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Loading and concatenating the cloud type granules" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(0, ['/home/a000680/usr/src/satpy/satpy/etc/readers/nc_nwcsaf_pps.yaml'], ['nc_nwcsaf_pps'])\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/lib64/python2.7/_abcoll.py:391: FutureWarning: iteration over an xarray.Dataset will change in xarray v0.11 to only include data variables, not coordinates. Iterate over the Dataset.variables property instead to preserve existing behavior in a forwards compatible manner.\n", " return list(self)\n", "/usr/lib64/python2.7/_abcoll.py:391: FutureWarning: calling len() on an xarray.Dataset will change in xarray v0.11 to only include data variables, not coordinates. Call len() on the Dataset.variables property instead, like ``len(ds.variables)``, to preserve existing behavior in a forwards compatible manner.\n", " return list(self)\n", "/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": [ "from satpy import Scene\n", "from satpy import find_files_and_readers\n", "from datetime import datetime\n", "\n", "DATA_DIR = \"/home/a000680/laptop/Nordisk/EARS_NWC/data/case_20180314/ears\"\n", "\n", "myfiles = find_files_and_readers(base_dir=DATA_DIR,\n", " start_time=datetime(2018, 3, 14, 10, 5),\n", " end_time=datetime(2018, 3, 14, 10, 11),\n", " reader='nc_nwcsaf_pps')\n", "scene = Scene(filenames=myfiles)\n", "scene.load(['ct'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we have loaded and concatenated the ct field of the Cloudtype product granules in the time window given by the start amd end times above" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(4320, 2048)\n", "[[ 2 2 2 ... 6 6 6]\n", " [ 2 2 2 ... 6 6 6]\n", " [ 2 2 2 ... 10 6 6]\n", " ...\n", " [ 7 6 6 ... 2 2 2]\n", " [ 7 6 6 ... 2 2 2]\n", " [ 7 6 6 ... 2 2 2]]\n" ] } ], "source": [ "print(scene['ct'].data.shape)\n", "print(scene['ct'].data.compute())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Also the geolocation has been unpacked. That is the the full resolution\n", "geolocation information has been recreated from the tie point grid by\n", "interpolating and extrapolating the longitudes and latitudes on the tie point\n", "grid. This is accomplished using the python-geotiepoints tool, but this is\n", "transparent to the user:

" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(4320, 2048)\n" ] } ], "source": [ "print(scene['ct'].area.lats.shape)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now let’s visualise the cloudtype data using the Nowcasting SAF palette read from the file:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "scene.load(['cloudtype'])\n", "scene.show('cloudtype')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Load all CTTH granules, concatenate, reproject, generate composite image, and save to disk" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "from glob import glob\n", "import os.path" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "DATA_DIR = \"/home/a000680/laptop/Nordisk/EARS_NWC/data/case_20180314/ears\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Make a list of all CTTH files in the directory, both bzipped and unpacked ones:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "myfiles = glob(os.path.join(DATA_DIR, \"*CTTH_C*.nc.bz2\"))\n", "myfiles = myfiles + glob(os.path.join(DATA_DIR, \"*CTTH_C*.nc\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Generate the scene object" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "scene = Scene(filenames=myfiles, reader='nc_nwcsaf_pps')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load the cloud height composite image" ] }, { "cell_type": "code", "execution_count": 9, "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_equal\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" ] } ], "source": [ "scene.load(['cloud_top_height'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Resample the data to the pre-defined \"euron1\" area" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "No handlers could be found for logger \"pyresample.kd_tree\"\n" ] } ], "source": [ "lscn = scene.resample('euron1', radius_of_influence=5000)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lscn.show('cloud_top_height')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Save the image to file" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "dt_start = lscn.attrs['start_time'].strftime('%Y%m%dT%H%MZ')\n", "dt_end = lscn.attrs['end_time'].strftime('%Y%m%dT%H%MZ')\n", "lscn.save_dataset(\n", " 'cloud_top_height', filename='./ears_nwc_ctth_{starttime}_{endtime}.png'.format(starttime=dt_start, endtime=dt_end))" ] } ], "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 }