Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

TRMM map layout and media export

Thomas Gumbricht bio photo By Thomas Gumbricht

Introduction

This post covers how to define layouts and export media files for precipitation data from the Tropical Rainfall Measurement Mission (TRMM) into Karttur´s GeoImagine Framework.

Prerequisites

You must have completed the data processing of TRMM data in the previous post.

TRMM

Project module

Other processing of TRMM data is done from within Karttur’s GeoImagine Framework. The project module file (projTRMM.py) is available in the project package projects.

Process chain

The project file links to an ASCII text file that contains a list of the xml files to execute. The layout and export processes are under the folder Layout.

projFN ='doc/Layout/TRMM-layout_YYYYMMDD.txt'

As the path to the project file does not start with a slash “\”, the path must be relative to the project module itself. The project package available on Karttur’s GitHub page contains the path and the files required for running the process chain. Both the text file and the xml files are available under the subfolder doc/TRMM.

Layout

If you want to create graphical outputs you need to define layouts for the TRMM data, including for scaling the data to Byte (0-255) range and define color palettes. if you want to produce an animated movie you can also define a movie clock and timeline for each composition you want animate (you can also use the default movie clock and timeline).

Scaling

Annual precipitation across the globe varies from 0 to over 8000 mm. Linearly scaling this range into the byte range of 0-255 is not useful. Some non-linear function is required. Either you can transform the data as a pre-process, or apply a power function on the fly when exporting the data. The scaling must be preset and defined in the database prior to export. The createscaling defined in the (hidden) xml file below defines a power function for rescaling the TRMM precipitation data on the fly when exporting layout maps.

Palettes

The default Karttur palette for precipitation comes in two versions, one for linear data, and one for logarithmic data. The former can, however, also be used after applying a power function as part of the layout export process as done in previous section.

Because of the relative complexity of the precipitation palettes, the default palettes for precipitation variation and error are defined separately, as is the palette for precipitation change. All the standard precipitation palettes are created from the xml below callingaddrasterpalette process:

Create Legend

The process createlegend defines the legend layout for compositions. When producing the legends the colors and denominations of the actual legend items are taken from the definition of palettes and scalings respectively.

Export legend

With the process exportlegend you can create stand alone legends. To work you mtust have defined the scaling, the palette and the legend in the previous steps. The process produces two or three legends: a Scalable Vector Graphics (.svg file) a .png file, and if requested also a compressed .jpg file. The svg is saved as a www compliant xml, and you can use it either for editing in a graphics program or inclusion in a web-page (or both).

Export overlay

When you export the actual data as maps in the next step, you can add a vector overlay. In the Framework you can convert any vector to an svg and then include it as an overlay. Only a single svg file can be used as overlay when exporting raster data to image maps. But you can manually compose an svg from multiple svg exported vectors, e.g. using a graphics editor.

For the TRMM data I have added the global shoreline to distinguish the outline of the continents.

Export color maps

Having defined a palette and the scaling for the different layers, you can export the layers as color maps (colored GeoTiff images). The process for doing that is exporttobyte.

Export monthly precipitaiton

Create Movie

Defining a movieclock

Details on defining and creating a movieclock within Karttur´s GeoImagine Framework is covered in the post on SMAP processing.

An animation requires a pre-defined movieclock (but usually the “default” movieclock is OK), and that the time series data is exported and then converted to movie frames.

A movieclock object defines the colors, types and sizes of the elements building the clock and timeline in the animation. Basically you do not need to define any of the elements, they are all defaulted. But if you want other widhts, margins, colors etc, all can be set using the process addmovieclock.

Movie frames

To create movie frames, you must first have exported the images, and then you can run the process movieframesancillary.

As default the script produces a shell script file that you must execute manually to produce the movie frames. The advantage with the script file is that you can edit the area of the map to appear in the movie as well as the embossed watermark text. The link to the script file is reported by the process. If you want to make the processing fully automated, you must set the parameter asscript to False.

Movie clock

The final step before producing the time series animation is to create the movie-clock that fits with your movie frames. You need to set the dimensions of the movie clock manually as parameters in the process movieclockancillary.

The process uses a combination of python image processing and ImageMagick commands.

The process also produces two shell script files. The first (in the subfolder frames) overlays the movieclock and the image frames, and the second (in the subfolder movie) produces the movie using ffmpeg. If you set the parameter asscript to True the module will execute the scripts internally.

Monthly rainfall estimated from TRMM and other sources