54
VISUALISATION COSMO-MODEL OUTPUT USING GRADS COSMIN BARBU BOGDAN MACO AMALIA IRIZA

Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

VISUALISATION COSMO-MODEL OUTPUT

USING GRADS

COSMIN BARBU

BOGDAN MACO

AMALIA IRIZA

Page 2: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Outline:

Page 3: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

What is GrADS?

Grid Analysis and Display System - developed at the Center for Ocean-Land-Atmosphere

Studies (COLA)

GrADS is a freely available package used for analysis, manipulation and plotting of

science data (e.g. data from meteorological models )

Key features of GrADS:

• available for multiple platforms as an executable (including Windows)

• accessible by both a command-line and scripting interface

• support for multiple common data formats (Binary, GRIB, NetCDF, HDF-SDS).

• significant support for user-defined plotting (Line and bar graphs, scatter plots, streamlines,

wind vectors).

• manipulation of large 4-D datasets.

• a rich set of built-in functions for data manipulation.

Page 4: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

The GrADS operating concept

Create a control file to describe a dataset for GrADS platform:vi filename.ctl

lStart GrADS session:

grads (enter in the command line)

lLaunch the data:open filename.ctl

Page 5: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

The GrADS display procedure:

lSet display dimension:

set lon West [East] sets longitudes [deg E], e.g. "set lon 17 23.5"

set lat South [North] sets latitudes [deg N], e.g. "set lat -10 15"

set lev p1 [p2] sets level [hPa], e.g. "set lev 500"

set time time [time2] , e.g. "set time 15Z19jul2011"

lDisplay the variable:

d expressiondisplay expression, e.g. T, or 0.01*pmsl, U;V, T-273.15

lSave the plot:

printim file.png create png-file

lClose the data:close 1

lQuit GrADS platform:quit

Page 6: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

GrADS is basically a set of three files that are required in order to read a data file:

The GRIB data file itself (*.grb, *.grib).

A GrADS control file (*.ctl).

A Gribmap file (or index file; *.idx or *.gmp).

How do I create these files?

The GrADS control file can be written using the grib2ctl utility

run the grib2ctl.pl utility at the command line (on a Unix/Linux operating system):

grib2ctl filename.grb > filename.ctl

This will have generated the control file filename.ctl.

The Gribmap file can be generated using the gribmap utility which comes freely

available as part of the GrADS package

gribmap -e -i filename.ctl

This will have generated the gribmap file filename.grb.idx.

Tips & tricks:

-using gme2ctl (available at DWD) will generate both file (*.ctl, *.idx)

Page 7: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Data description file (.ctl file)

lGrADS implements a 4-dimensional data model, where the dimensions are latitude, longitude, level and time. Each data set is

llocated within this 4-dimensional space by use of a data descriptor

The control file (extension .ctl) is used to explain the data structure of a data for GrADS platform to coordinate the metadata

information in data for plotting.DSET ^all_lfff_refdata

INDEX ^all_lfff_refdata.idx

undef 9.999E+20

TITLE File all_lfff_refdata

dtype grib 255

* Rotated LatLon grid: South pole lat -40.000000 lon 10.000000 rot angle 0.000000

ydef 161 linear -5.000000 0.0625

xdef 129 linear -4.000000 0.0625

tdef 13 linear 12Z13may2013 1hr

zdef 41 levels

41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

vars 14

T_G 0 11,1,0 ** surface temperature [K]

T_2m 0 11,105,2 ** 2 m temperature [K]

T 40 11,110,0 ** temperature [K]

TD_2m 0 17,105,2 ** 2 m dew-point temperature [K]

TDIVHUM 0 42,1,0 ** surface vert. integral of divergence of tot. water content [kg/(m**2)]

TKE 41 152,109,0 ** turbulent kinetic energy [(m/s)**2]

TMAX_2m 0 15,105,2 ** 2 m maximum temperature [K]

TMIN_2m 0 16,105,2 ** 2 m minimum temperature [K]

TOP_CON 0 73,1,0 ** surface convection top index [1]

TOT_PREC 0 61,1,0 ** surface total precipitation [kg/(m**2)]

U_10m 0 33,105,10 ** 10 m u-component (zonal) of wind [m/s]

U 40 33,110,0 ** u-component (zonal) of wind [m/s]

V_10m 0 34,105,10 ** 10 m v-component (merdional) of wind [m/s]

V 40 34,110,0 ** v-component (merdional) of wind [m/s]

ENDVARS

Here is an grid control file example:

Page 8: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Control file options:

DSET: The control file referred data.

absolute path: dset /export/home/training3/RUN/FOR00/filename.grb

relative path: dset ^filename.grb

TITLE: The title description of the data (optional)

title description

The name of the index file, e.g.

index filename.idx

UNDEF: The undefined or missing value in input data

undef value

The undefined value will not be plotted out when GrADS is plotting the value

dtype grib 255

The number of the grid that is used.

Coordinate definition:

xdef: Longitudinal direction coordinate

ydef: Latitudinal direction coordinate

zdef: Vertical direction coordinate

tdef Time progressive coordinate:

Page 9: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

VARS: declare how many variables in the input data

vars num (the number of variables)

Variable declaration:

Variable_name levels unit description

variable_name: the variable name, which is called in display command for plotting

levels: the number of vertical grids, which must not great than the zdef grid_number

unit: the unit corresponds the format in different type data (as grib or netCDF)

description: the description of the variable

ENDVARS: declare the variables in input declaration is ending

NLEV Number of vertical levels (0 stands for a two-dimensional field).

EE Element number in the Grib tables.

LEVTYP Leveltyp in the Grib tables.

LEVBOT Bottom level for Leveltyp 105.

A weakness of GrADS is, that it cannot distinguish between different Grib tables. Therefore, vari-ables from different Grib tables, but

with the same element number cannot be displayed properly. This holds for example for the wind speed U (in Grib Table 2, ee=33)

and cloud ice QI (in Grib Table 201, ee=33).

Page 10: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Let's practice:

Start

GrADS_executive <options>

In the command prompt type grads

options

-help: list available options for the version

- l/ -p: perform the display on real page as landscape(11inch x 8.5inch)/portrait(8.5inch x 11inch) mode

-b: enable to operate GrADS command without x-window

-c <command>: execute the command after startup GrADS system

training3: /export/home/training3 =>grads

Grid Analysis and Display System (GrADS) Version 2.0.a9

Copyright (c) 1988-2010 by Brian Doty and the

Institute for Global Environment and Society (IGES)

GrADS comes with ABSOLUTELY NO WARRANTY

See file COPYRIGHT for more information

Config: v2.0.a9 little-endian readline printim grib2 netcdf hdf4-sds hdf5 opendap-grids geotiff shapefile

Issue 'q config' command for more detailed configuration information

Landscape mode? ('n' for portrait):

GX Package Initialization: Size = 11 8.5

ga->

Page 11: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Important commands:

set lon West [East] sets longitudes [deg E], e.g. "set lon 17 23.5"

set lat South [North] sets latitudes [deg N], e.g. "set lat -10 15"

set lev p1 [p2] sets level [hPa], e.g. "set lev 500"

set time time [time2] sets time in format hhZddmmmyyyy, hh=hour, dd=day, mmm=month, yyyy=year, e.g. "set time 15Z19jul2011"

q XX query, i.e. get information XX

q file description of the file

q dims information about set dimensions

q time information about time settings

q ctlinfo show content of control-file

set gxout XXChoose display style, e.g. contour, shaded, grfill, barb

Page 12: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

set display color white white background of mapset mpdset hires use high-resolution coastlines/mapsdraw string Hello 2.5 1.2 write string Hello at position 2.5 inches, 1.2 inches

cbar draw the colour bar (Standard script cbar.gs)

set clevs 0.1 0.5 1 5 10 25 50 75 100 set contour levelsset cmin 25 show only values above 25set ccolor 2 set contour color

Basic commands are:setd (or display) drawqueryclose open c (or clear)

See grads.iges.org/grads/gadoc/gaddocindex.html, especially for set

More commands:

Page 13: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Graphic types: set gxout

shaded contour grfill 13

Page 14: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

set gxout barb draw WMO wind barbsd skip(u_10m*2,4);v_10m*2 draw every 4th wind grid point as barb (in knots)set gxout stream draw streamlinesd u_10m;v_10m draw wind at 10m as streamlinesd mag(u_10m,v_10m) draw wind speed (in m/s)d hdivg(u_10m,v_10m)*1.e4 draw divergence (10-4 s-1)d hcurl (u_10m,v_10m)*1.e4 draw vorticity (10-4 s-1)

set clevs 0.1 0.5 1 5 10 25 50 75 100 set contour levelsd tot_prec draw precipitation

condepth=(htop_con-hbas_con)/1000 compute convective cloud depth (in km)d maskout(condepth, condepth-0.5) draw condepth >= 0.5 km; alternative:set cmin 0.5d condepth

Some examples:

Page 15: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Graphics types: set gxout

15

Page 16: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Tutorial examples:

“COSMO tutorial 2015”

- page 33

We'll practice together

Page 17: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

COSMO Romanian domains:

Page 18: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

all_lfff_refdataThis grib files contains all output files from the COSMO-Model refference data set.

lfff00000000c, lfff00000000, . . . , lfff00120000

If you made the reference run, you can create it by typing

cat lfff00000000c lfff*00 > all_lfff_refdata

The GrADS data descriptor file for the reference data set.

grib2ctl.pl all_lfff_refdata > ref_model.ctlgribmap -i ref_model.ctl

GrADS Environment Variables

GrADS is working with scripts, that can be executed during a GrADS session. Also you haveto access special

data e.g. to display a map background. The directories, where data and scripts

are stored, have to be specified by special GrADS environment variables. GADDDIR specifies the

directory with special GrADS data and GASCRP defines the directory holding GrADS scripts. The

settings for this course are:

export GADDIR=${Path To}/grads/fonts

export GASCRP=${Path To}/grads/bin

Page 19: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Starting GrADS

GrADS can be started interactively by using the command grads. The user is prompted for specifying a landscape or

a portrait window. Normally, a landscape window is chosen, so just press ENTER.

options

-help: list available options for the version

- l/ -p: perform the display on real page as landscape(11inch x 8.5inch)/portrait(8.5inch x 11inch) mode

-b: enable to operate GrADS command without x-window

-c <command>: execute the command after startup GrADS system

In the text window (from where you started GrADS), you should now see the GrADS prompt

ga->.

Page 20: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

First, the data descriptor file has to be opened. For that you have to enter:ga-> open ref_model.ctl

You can take a look on the contents of this file by entering

ga-> query file

q XX query, i.e. get information XXq file description of the fileq dims information about set dimensionsq time information about time settingsq ctlinfo show content of control-file

Displaying Data

Data can be displayed by using the command display (or abbreviated: d):

ga-> d var_namewhere var name is the name of the variable as it was defined in the data descriptor file, e.g.:

ga-> d u10mga-> d t2m

Page 21: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Note that GrADS displays an x-y-plot at the first time and at the lowest level in the data set. Per

default, contour lines are plotted. This can be changed by entering

ga-> set gxout stylewhere style is one of the following:

• contour the default

• shaded coloured plots

• grfill the single grid cells can be seen in the coloured plot

• grid the values are written in the grid cell (not useful for bigger domains)

• vector for displaying special variables (see below)

• stream for displaying special variables (see below)

Display some variables in different styles, e.g.

ga-> d u10m (the default are contour lines)ga-> c (for clear: clears the display)ga-> set gxout shadedga-> d u10mga-> cga-> set gxout grfillga-> d u10m

For the styles shaded and grfill, you can draw a color-bar to see the range of the values of the displayed

variable by entering

ga-> run cbarNote that cbar also is a user defined grads script.

Page 22: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

You should get:

Page 23: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Using the styles vector or stream, you can visualize e.g. the wind:

ga-> cga-> set gxout vectorga-> d u10m;v10mga-> cga-> d skip(u10m,5,5);skip(v10m,5,5) (Note the difference!)ga-> cga-> set gxout streamga-> d u10m;v10mga-> c

By specifying a 3rd field, the vectors can also be colorized, e.g.

ga-> set gxout vectorga-> d u10m;v10m;t2mga-> c

Page 24: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Altering the dimensions:

You now will enter commands to alter the dimension environment. The display command (and,

implicitly, the access, operation, and output of the data) will do things with respect to the current

dimension environment. You control the dimension environment with the set command.ga-> cga-> set x 35ga-> set y 30ga-> d t2m

Result value = 281.26 (in Kelvin)

ga-> d t2m-273.15

Result value = 8.11025 (in Celsius)

ga-> d (t2m-273.15)*9/5+32

Result value = 46.5985 (in Fahrenheit)

In the above sequence, the x- and y-dimensions are set to a single value. Because the z- and t-dimensions

are also only a single value, all dimensions are now fixed and the result is just a singlevalue, in this case

the value for grid point (35,30), at the lowest level and the 1st time in the data set.

Page 25: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

If you now enter

ga-> cga-> set x 1 201ga-> d t2m

Now x (the longitude) is a varying dimension and displaying a variable will give a line graph.

Now enter

ga-> cga-> set y 1 177ga-> d t2m

and you will get a two-dimensional plot again. You can also choose a subdomain for plotting:

ga-> cga-> set x 31 43ga-> set y 25 45ga-> set gxout shadedga-> cbarga-> d t2m

And on such a subdomain you can take a look on the values of the grid cells:

ga-> cga-> set gxout gridga-> set mproj scaledga-> set mpdset gmt_l_rot_euga-> d t2m-273.15

Page 26: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table
Page 27: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Mapping with gme2ctl:

Try some commands with your own data.

Make a ctl-file with

gme2ctl.pl <GRIB-file>

For more information about gme2ctl usage type: gme2ctl.pl -h

Debug information with option -D (repeat -D for more debug information)

gme2ctl.pl -D

Mapping all COSMO7 ouputgme2ctl.pl -n cosmo7 lfff00*0

You'll get on your screen:grib1map: opening GRIB file: cosmo7_000 grib1map: opening GRIB file: cosmo7_003 grib1map: opening GRIB file: cosmo7_006 grib1map: opening GRIB file: cosmo7_009 grib1map: opening GRIB file: cosmo7_012 grib1map: reached end of filesgrib1map: writing the map...

Control file: cosmo7.ctlIndex file: cosmo7.idx

27

Page 28: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

If also a third dimension is varied, you will get an animation sequence, which can be done e.g.

through time:

ga-> open cosmo7.ctlga-> cga-> set gxout shadedga-> set x 1 129ga-> set y 1 161ga-> set t 1 13ga->d t_2m 1 13

Page 29: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Operations on data:

GrADS offers the possibility to perform operations or several built in funtions on the data.

Any expression may be entered that involves the standard operators of +, -, * and /, and which

involves operands which may be constants, variables, or functions. Here is an example involving

functions to calculate the magnitude of the wind. The sequencega-> cga-> d sqrt(u_10m*u_10m+v_10m*v_10m)can be replaced by the functionga-> d mag(u_10m,v_10m)Another built in function is the averaging function:ga-> d ave(ps,t=1,t=7)

In this case the mean surface pressure over 7 values (from 00 UTC to 06 UTC!) is calculated.

You can also perform time differencingga-> cga-> d ps(t=2) – ps(t=1)

If there are two files open, perhaps one with model output, the other with analyses, you can also

take the difference between two fields by enteringga-> d ps.2 - ps.1

Page 30: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table
Page 31: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Printing dataNewer version of GrADS have a comfortable way of printing data to a gif-file:

ga-> printim file namewhere file name is the name that is given to the file. You can take a look on the contents of file name by using display.

Ending GrADS

The command to end the GrADS session is

ga-> quit

Drawing a Map Background:

To draw a map background is an advanced feature when visualizing COSMO-Model output with GrADS,

because of the rotated latitude-longitude grid the predefined GrADS maps cannot be used.

We have some special maps for rotated grids that are used for the reference run. The maps are provided in

a low, medium and high resolution over Europe for the rotation with pollat=32.5:

gmt_l_rot_eu_low resolution map

gmt_m_rot_eu medium resolution map

gmt_h_rot_eu high resolution map

and for the rotation with pollat=40.0:

gmt_l_rot_40.0 low resolution map

gmt_m_rot_40.0 medium resolution map

Page 32: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Start GrADS, open the data descriptor file and run the initialization script.ga-> open cosmo7.ctlga-> run map.gs

The script pin.gs (.gs stands for grads script) just specifies the plotting area and defines some

COSMO-Model specific features. It can be accessed from the GrADS scripts-directory, which is set

by an environment variable (see above). You can take a look to see how this script looks like.

To control the map drawing, you have to set

ga-> set mproj latlon (sets the map projection to a lat-lon grid where the aspect ration

is maintained)ga-> set mpdset < gmtl_rot_40.0 | gmt_m_rot_40.0 >

If you now display a variable, the political borders and the coastlines are drawn by default in

addition to the variable.d t_2m-273.15

Page 33: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table
Page 34: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

We can also display the data in other projections using the set mproj command:

•latlon •(lat/lon—maintains aspect

ratio)

•lambert •(Lambert conformal

conic)

•scaled •(lat/lon—does not

maintain aspect ratio)

•mollweide •(Mollweide)

•nps •(North polar

stereographic)

•orthogr •(Orthographic)

•sps •(South polar

stereographic)

•robinson •(Robinson—requires set

lon -180 180 and set lat

-90 90)

Default is latlon

set mproj off turns off the map projection

Page 35: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table
Page 36: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

To switch off the borders and / or the coastlines you can use the set mpt command. The syntax is

set mpt type < off | <color>,<style>,<thickness>>where type, color, style and thickness can be chosen from the following table:

To also switch on the main rivers in a black dotted line, you can enter

ga-> set mpt 3 1 5and then display a variable. To switch all maps off, you can type

ga-> set mpt * off

Page 37: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Use of GrADS in Batch mode

You have already used the scripts pin.gs or cbar.gs above. You can easily generate your own scripts by embracing

the most commands by an apostrophe (exceptions are variable definitions,...).

A short example is shown here

’open cosmo7.ctl’’run map.gs’’set gxout grfill’’d t_2m-273.16’’printim my_plot.png’

Let us name this script ’myscript.gs’. You can of course call this script during your grads session, but you can call it

by a shell command, too:

grads -b -c ’myscript.gs’

To automatically quit grads you should finish the above script by a line ’quit’. Using scripts in

this way allows to use GrADS as a graphic production tool.

Page 38: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Why we need Scripting Language?

To avoid setting a number of plot setting every time, the GrADS script (.gs) file is recorded the display steps for modifying easily.

Run GrADS script

run <script_file> run the script file

script_file: the script file can be either the route or the file name if at the same directory, even without extension.

ex: ga-> run /home/user/cmap.gs absolute route

ga-> run ../cmap.gs related route

ga-> run cmap.gs run the file at the same directory

ga-> camp.gs omitting the run commander

ga-> cmap omitting the .gs extension

Assignment: variable = expressionOperators: | & ! - = != > >= < <= % + - * /Intrinsic script functions:sublin(string,n) Get single line from string containing several linessubwrd(string,n) Get the nth single word from a string. substr(string,start,length) Get sub-string of string starting at location start for length length

Comment

Put an asterisk * at the first column of the line and GrADS system doesn’t run the line.

Ex: *”set ccolor 2”

Page 39: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

If block

if(condition)

executed command if condition is true

else

executed command if condition is false

endif

Ex: if( t_2m-273 > 30 )

say ‘hot time’

else

say ‘nice time’

endif

there is no ‘else if’ command in GrADS

While loop

while(condition)

Executed command repetitive until condition is not true

endwhile

Ex: t = 1

while(t<=30)

say t

t = t + 1

endwhile

t=t+1

Page 40: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Example 1:

set display color whitecopen cosmo07.ctlq dimsset t 1 13set lat -10set lon 9set ccolor 2set cthick 10d t_2m-273.15draw title title T_2m evolution in time printim T_2m-evolution.png

Page 41: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Example 2:

open cosmo07.ctlSet display color whitecrun map.gsset gxout shadedset clab forcedd pmsl/100set gxout contourd pmsl/100run cbar.gsdraw title pressure reduced to MSL [hPa]set strsiz 0.14draw string 1.4 8.3 COSMO-7kmprintim pmsl.png png x1024 y768quit

Page 42: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Example 3: Cross section

open lfff00120000p.ctlSet display color whitecq dimsset y 100set x 20 100set lev 1000 450set gxout contourset grads offd t-273.15d u;v;mag(u,v)draw title Cross section on latitudineprintim lat.png png x1024 y768

cset lon 12set lat -14 -9 set lev 1000 450d t-273.15draw title Cross section on longitudeprintim lon.png png x1024 y768

quit

Page 43: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Example 4: Total cloud cover

open open all_lfff_refdata.ctlset display color whitecset mproj latlonset mpdset gmt_l_rot_eu

set gxout shadedset rgb 41 225 255 255set rgb 42 180 240 250set rgb 43 150 210 250set rgb 44 120 185 250set rgb 45 80 165 245set rgb 46 60 150 245set rgb 47 40 130 240set rgb 48 30 110 235set rgb 49 20 100 210set rbcols 0 41 42 43 44 45 46 47 48 49

set csmooth ond clctcbar.gsdraw title Total cloud coverprintim clct.png

quit

Page 44: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Example 5: 10m wind

open all_lfff_refdata.ctlSet display color whitecset mproj latlonset mpdset gmt_l_rot_euset gxout shadedset rgb 31 230 255 225set rgb 33 180 250 170set rgb 35 120 245 115set rgb 43 150 210 250set rgb 46 60 150 245set rgb 48 30 110 235set rgb 26 255 50 0set rgb 28 192 0 0set rbcols 31 33 35 43 46 48 26 28 93

d skip(u_10m,2,2);v_10m;mag(u_10m,v_10m)draw mapcbar.gsdraw title Wind 10mprintim w_10m.png x1024 y768quit

Page 45: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Helpful Tools: wgrib

As already mentioned above, GrADS has problems when two variables should be visualized thathave the same

element number but are from different Grib tables. Another problem is the visualization of threedimensional

variables, that have different vertical locations. In the COSMO-Model, most atmospheric variables are defined

on main levels, while the vertical velocity W (and some related variables) are defined on half levels.

There are tools whcih offer now convenient solutions for these problems. With wgrib it is possible to

extract certain variables out of a Grib file into a new Grib file. And if only one type of atmospheric

variable is present, it is no problem for GrADS.

A list of contents of a Grib file:

To see a list of all variables in a Grib file <name> type:

wgrib <name>

The listing gives you (among others) information about

d=09122112: the date

U: the name used in the COSMO-Model

kpds5=33: the element number (here defined by kpds5)

kpds6=110: the leveltyp (110 are variables on main levels, 109 variables on half levels)

Page 46: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Extracting variables out of a Grib file:

The output of the listing above can be piped into wgrib again to extract certain variables, which

you have to specify by the element number (or kpds5):

wgrib <name> | egrep -i <string> | wgrib -grib -i <name> -o <name> suffix

where <string> is e.g.

":U:kpds5=33:kpds6=110:" to extract U

":V:kpds5=34:kpds6=110:" to extract V

":W:kpds5=40:kpds6=109:" to extract W

":T:kpds5=11:kpds6=110:" to extract T

":P:kpds5=1:kpds6=110:" to extract P

":PP:kpds5=139:kpds6=110:" to extract PP

":QI:kpds5=33:kpds6=110:" to extract QI

You can also add several entries with the | in between:

":U:kpds5=33:kpds6=110:|:V:kpds5=34:kpds6=110:"

Example:wgrib lfff00010000 | egrep -i ":V:kpds5=34:kpds6=110:|:U:kpds5=33:kpds6=110:" | wgrib -grib -i lfff00010000 -o lfff00010000_uv

Exercise: play with U,V variables.

Page 47: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Meteographs with meteo_plot.pl

Requirements

ASCII output of COSMO perl typically in /usr/bin/perlgnuplot http://gnuplot.sourforge.netDate-Pcalc - a package consists of a Perl module for all kinds of date calculations basedon the Gregorian calendar

Explanation with option –h:meteo_plot.pl –h

Problems? Use option –D (repeat –D for more debug information)meteo_plot.pl –D …

Information on content of a meteograph file:meteo_plot.pl –i M_*

Page 48: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Simple usage

meteo_plot.pl M_Bandung -e pmsl,ff10m,dd10m,t2m,td2m,clch,clcm,clcl,rain_con,precipmeteo_plot.pl M_Bandung -e pmsl,ff10m,dd10m,t2m,td2m,clch,clcm,clcl,rain_con,precip -o meteo_Bandung.png

48

Page 49: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

meteo_plot.pl M_bandung -e pmsl,ff10m,dd10m,t2m,td2m,clch,clcm,clcl,rain_con,precip –o meteo_bandung_1.png -time '*:+52'

Page 50: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

meteo_plot.pl M_bandung -e pmsl,t2m,tmin2m,tmax2m,precip -o meteo_bandung_2.png -time '2012101712 : 2012101906'

Page 51: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Visualization of NetCDF files ( GRIBOUT: yform_write='ncdf')

lfff00000000c.nc lfff00000000p.nc lfff00030000p.nc lfff00060000p.nc lfff00090000p.nc lfff00120000p.nc

lfff00000000.nc lfff00030000.nc lfff00060000.nc lfff00090000.nc lfff00120000.nc

NetCDF (Network Common Data Form) is a set of software libraries and self-describing,

machine-independent data formats that support the creation, access, and sharing of

array-oriented scientific data. The project homepage is hosted by the Unidata program

at the University Corporation for Atmospheric Research (UCAR).

Ncdump may be used as a simple browser for NetCDF data files,

to display the dimension names and sizes; variable names, types and shapes; attribute names and

values; and optionally, the data values themselves for all or selected variables in ASCII format.

ncdump -c data-file.nc

Dimension names and sizes, variable names, dependencies and values of dimensions will be displayed.

ncdump

Page 52: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

To get only header information (same as -c option but without the values of dimensions) use

ncdump -h data-file.nc

To display the values of a specified variable which is contained in the NetCDF file type

ncdump -v <Variable> data-file.nc

To send data to a text file use

ncdump -b c data-file.nc > data-file.cdlto produce an annotated CDL version of the structure and the data in the NetCDF-file data-file.nc.

You can also save data for specified variables for example in *.txt-files just using:

ncdump -v <Variable> data-file.nc > data-file.txt

ncview

Ncview is a visual browser for NetCDF format files developed by David W. Pierce. Using ncview

you can get a quick and easy look at your NetCDF files. It is possible to view simple movies of

data, view along different dimensions, to have a look at actual data values at specific coordinates,

change colormaps, invert data, etc

You can run the program by typing:

ncview data-file.ncwhich will open a new window with the display options..

Page 53: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table

Useful links for GrADS

Name Link

GrADS Home Page grads.iges.org/grads/gadoc

GrADS User's Guide grads.iges.org/grads/gadoc/users.html

GrADS Documentation Index grads.iges.org/grads/gadoc/gaddocindex.html

GrADS Script Library grads.iges.org/grads/gadoc/library.html

GrADS Tutorial grads.iges.org/grads/gadoc/tutorial.html

OpenGrADS opengrads.org/index.php

Page 54: Visualisation COSMO-Model output using GrADS · Key features of GrADS: • available for multiple platforms as an executable (including Windows) ... and cloud ice QI (in Grib Table