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.
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
import glob
from satpy import Scene
# String formatting example
str = '{} world!'
print (str.format('Hello'))
# Using glob, find *.nat files in the given directory
base_dir = '/tcenas/scratch/pytroll/ex9'
files =
# print found files
print (files)
Scene
-object and load some data¶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.
# Create a Scene-object
scn =
# Let's define a composite variable for convenience
composite = 'day_microphysics'
# Make a list with the composite, and 0.6um and 1.6um channel data
datasets =
# Load datasets to the Scene-object
Scene
¶Resample the created Scene
-object to EastEurope
area. Show the day_microphysics
-composite.
# Resample the scene to the new area
ee =
# Show composite
ee.show(composite)
Ń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.
# Area of interest
rows = slice()
cols = slice()
# Slice the area of interest to a variable
vis06 =
ir16 =
# Compute and print the mean reflectances
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
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.
# Slice the area of interest to variables
vis08 =
ir108 =
# Compute and print the required statistics