{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 9: Analysing data for an area of interest\n", "\n", "In previous exercises we've learned how to load and display satellite data using a `Scene`-object. In this exercise we will extract a piece of data from that scene and do simple analysis on it. Here we learn how to play with `dask`-arrays. Furthermore, we will touch some Python basics, i.e., string formatting, use of `glob`-module, and using slices." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 9.1: Find the file\n", "\n", "Use string formatting and `glob`-module ot get get a list of files in directory `/tcenas/scratch/pytroll/ex9`. Example of string formatting is given below" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import glob\n", "from satpy import Scene\n", "\n", "# String formatting example\n", "str = '{} world!'\n", "print (str.format('Hello'))\n", "\n", "# Using glob, find *.nat files in the given directory\n", "base_dir = '/tcenas/scratch/pytroll/ex9'\n", "files = \n", "\n", "# print found files\n", "print (files)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 9.2: Create a `Scene`-object and load some data\n", "\n", "The resulting `files`-variable should only contain one file. Use the variable as a list to initiate a `Scene`-object and load `day_microphysics`-composite and channel data for 0.6um and 1.6um. _Hint:_ `Scene`-object has a convenience method `available_dataset_names` to check how the different channels are named in the reader." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "# Create a Scene-object\n", "scn = \n", "# Let's define a composite variable for convenience\n", "composite = 'day_microphysics'\n", "# Make a list with the composite, and 0.6um and 1.6um channel data\n", "datasets = \n", "# Load datasets to the Scene-object\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 9.3: Resampling the `Scene`\n", "\n", "Resample the created `Scene`-object to `EastEurope` area. Show the `day_microphysics`-composite." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Resample the scene to the new area\n", "ee = \n", "# Show composite\n", "ee.show(composite)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 9.4: Data slicing and statistics\n", "\n", "Ńow we're goint to work with the resampled image. The left hand side shows a big thunderstorm system over East Europe. Take a data slice of `[245:275, 80:120]` from both 0.6um and 1.6um channels and calculate the mean reflectance. _Hint_: The extracted data slice is a `dask`-array. These arrays are _lazy_. Also, we're using `slice`-objects here for convenient ROI definition." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Area of interest\n", "rows = slice()\n", "cols = slice()\n", "# Slice the area of interest to a variable\n", "vis06 = \n", "ir16 = \n", "# Compute and print the mean reflectances\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Exercise 9.5: Utilizing the data loaded for the composite\n", "\n", "The `day_microphysics` composite is a three component data array. Here's how the composite is build: http://www.eumetrain.org/rgb_quick_guides/quick_guides/DaymicroRGB.pdf\n", "Calculate and print the mean of the 0.8um channel using the data loaded for the `day_microphysics` composite. Furthermore, calculate and print the minimum, maximum, and standard deviation of the 10.8um channel." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Slice the area of interest to variables\n", "vis08 = \n", "ir108 =\n", "# Compute and print the required statistics\n" ] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 2 }