{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Visualizing Metop and MSG data on the same grid\n", "## Summary\n", "In this tutorial, we well look at how we can put both Metop and MSG data on the same grid\n", "\n", "## First step, loading the data\n", "Loading the data is done in the same way as presented in earlier tutorial\n", "\n", "## Exercise 6.1: Getting the data on the same grid\n", "Create a `Scene` object for the Metop data and another one for the MSG data. Load the `day_microphysics` RGB composite from MSG and the 10.8µm channel from Metop. Resample both to the EastEurope area." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from satpy import Scene, find_files_and_readers\n", "from datetime import datetime\n", "\n", "metop_files = find_files_and_readers(base_dir='/tcenas/scratch/pytroll/ex6',\n", " reader='avhrr_l1b_eps',\n", " start_time=datetime(2018, 10, 7 ,9, 25),\n", " end_time=datetime(2018, 10, 7 ,9, 30))\n", "scn_metop = Scene(filenames=metop_files)\n", "scn_metop.load([10.8])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "msg_files = find_files_and_readers(base_dir='/tcenas/scratch/pytroll/ex6',\n", " reader='seviri_l1b_native')\n", "\n", "scn = Scene(filenames=msg_files)\n", "scn_msg = Scene(filenames=msg_files)\n", "scn_msg.load(['day_microphysics','IR_108'])\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "newscn_metop = scn_metop.resample('eurol')\n", "newscn_metop.show(10.8)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "newscn_msg = scn_msg.resample('eurol')\n", "newscn_msg.show('IR_108')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 6.2: Manipulating images\n", "Now we want to put both datasets onto one image." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from satpy.writers import get_enhanced_image\n", "import xarray as xr\n", "from trollimage.xrimage import XRImage\n", "\n", "# Lets compare MSG and METOP channel 10.8 data\n", "msg_image = get_enhanced_image(newscn_msg['IR_108'])\n", "\n", "metop_image = get_enhanced_image(newscn_metop[10.8])\n", "\n", "array1 = msg_image.data.where(metop_image.data.isnull(), metop_image.data)\n", "\n", "XRImage(array1)\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# No Using MSG composite\n", "msg_image = get_enhanced_image(newscn_msg['day_microphysics'])\n", "color_array = xr.concat((metop_image.data, metop_image.data, metop_image.data), 'bands')\n", "color_array['bands'] = ['R', 'G', 'B']\n", "final_array = msg_image.data.where(color_array.isnull(), color_array.data)\n", "XRImage(final_array)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The `Multiscene` class\n", "In order to manipulate multiple scenes at once, in some circumstances, it maybe advantageous to make use of satpy's `Multiscene` class. Let's create a multiscene instance, load some data and resample the data to the `EastEurope` area" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from satpy import MultiScene\n", "mscn = MultiScene([scn_msg, scn_metop])\n", "mscn.load(['overview'])\n", "new_mscn = mscn.resample('eurol')\n", "blended_scene = new_mscn.blend()\n", "blended_scene.show('overview', overlay={'coast_dir': '/tcenas/scratch/pytroll/shapes/', 'color': (255, 0, 0), 'resolution': 'i'})" ] }, { "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.6.7" } }, "nbformat": 4, "nbformat_minor": 2 }