intro to gempak

Starting NMAP2

Log in to a linux machine and open a new terminal (right click and look for Open Terminal).

cd $HOME
source /export/project/a/ldm/NAWIPS/setup.csh
nmap2 &

Exiting NMAP2

It is always good to know how to exit a program, click “Exit” in the top grey bar in NMAP2 to quit.

NEVER exit N-AWIPS programs/windows by using the “X” box in the upper right corner

this will leave processes running and will eventually crash the machine (usually at 3am on the day a big project is due).

Working remotely

If you are working remotely (on a machine outside of HAMP 4247), bring up a web browser and enter the following URL

Log in with your career account. Then type:

ssh -Y

where NN is a number between 1 and 20. log in with your career account credentials.

Setting the date/time to plot archived surface obs

You can control the times that are plotted in the data selection window using the “Range/Int” button. Clicking on this button brings up another pop-up window, which controls the date/time, range, and time interval between separate data points in the timeline. Click on the blue “CAL” button to bring up a calendar, change the Year with the top up/down arrows, choose the month and date (select the day at the end of the timeline of interest), slide the "Hour" and “Minute” slider bars to the time of interest, then click Accept. Setting the “Interval” value to 1 under the HR column will limit the time ticks to one per hour. Click “Accept” in the Range/Interval window to accept the changes.

The following video explains how to control the variables plotting in the station model and how to draw contours using the product generation tool. This video was produced for an introductory lab course and goes into more detail than you'll need.

Setup your custom “my_restore” files

We can customize the variables that we plot in nmap2. Before we can do that, we need to setup some files that you will edit to produce customized plots.

This needs to be done once, not every time that you run nmap2.


cd  $HOME
tar -xvf /project/hypocenter/class/EAS434/restore.tar

List the files (ls $HOME/restore/) to make sure that you have files called “my_restore_01, my_restore_02”, etc.

Introduction to GEMPAK (GEneral Meteorological PAcKage)

GEMPAK is a software package that includes several programs useful for decoding, plotting, and displaying meteorological data. The N-AWIPS programs that we have been using are based upon the GEMPAK engine. Certain GEMPAK programs will work only with specific types of data or will perform only specific tasks. The first two letters of a GEMPAK program's name correspond with these data types or tasks:

  • SF-surface observation data
  • SN-sounding observation data
  • GD-gridded data
  • OA-objective analysis
  • GP-graphics capabilities

To begin using any of the GEMPAK programs, make sure that you have sourced the proper setup.csh.

source /export/project/a/ldm/NAWIPS/setup.csh

Then, simply type the name of the program at a linux/unix prompt. All of the GEMPAK programs work similarly through the use of parameter lists. Once in one of the GEMPAK programs, it is useful to get a listing of all of the parameters and their settings by typing “l” (lowercase L, for 'list') followed by ENTER. To change a parameter, just use the following syntax:

parameter_name = value

GEMPAK has a useful help library for each parameter and each program. This library can be accessed with the phelp or help commands. (phelp displays the help one page at a time). As an example, if you were interested in the MAP parameter, you would type phelp map, while the command phelp sfmap would provide information and examples illustrating the use of the sfmap program. You must be within a GEMPAK program to use these commands.

Once you have changed all the parameters to your liking, type r for run from the prompt to create your plot. To quit, type ex (or exit).

If you need more information regarding parameters, use the phelp command, ask your instructor, or visit the GEMPAK documentation online at the following URL

Remember that you must use gpend to close GEMPAK windows. (“gpend is your friend”) NEVER click on the corner of an open GEMPAK window to close it. You will leave behind ghost GEMPAK processes that will continue to run, slowing down and eventually crashing your machine! You must also use gpend before printing newly created PostScript files.

gdplot2 intro

We will be using the program gdplot2, at the linux command line type:


The program gdplot2 plots scalar and or vector variables (if they are available in or derivable from a GEMPAK file) such as wind, temperature, height, sea level pressure, etc. In addition, you can plot combinations of the available variables such as vorticity, temperature advection, thickness, and divergence. Here is a listing of some important GEMPAK parameters:

gdfile: Specifies file to plot
gdattim: Specifies date/time to plot
glevel: Vertical level to plot
gvcord: Vertical coordinate in which glevel is defined
gdpfun: Grid function/parameter (scalar or vector) to plot/contour
cint: Contour interval to use
fint: Color fill interval
fline: Colors for color fill
line: Defines line type, color, thickness, etc.
type: Defines whether to contour or use color filling or wind barbs/arrows
scale: Scaling factor to plot variables of order one

it is strongly recommended that you read up on the gparm parameter (phelp gparm) to get an idea of the variety of parameters that can be plotted using GEMPAK. Change the following parameters as outlined below. Once you have set a parameter, it will remain the same for future plots, unless you specifically change it.

gdfile = $MODEL/rap/2017021300_rap20km.gem
gdattim = f00
glevel = 800
gvcord = pres
gdpfun = tmpc ! wnd
type = c!b
garea = in-

Once you have changed these parameters, type r and press <Enter>.

Now let’s plot the temperature advection by the full wind. Change:


This should plot the temperature advection term in units of K/s * 104. In other words, the 2 contour represents temperature advection of 2 x 10-4 K/s. If we are interested in units of K/day we need to multiply these numbers by the factor of 86400 s/day. To do this, we’ll combine two functions at the same time, multiplication and advection. Change:


and run. (also try: type=cf to get a color fill) The “mul” function multiplies two fields, here the second “field” is a constant number = 86400 s/day.


For this example, we used device = xw to output plots to the computer monitor (xw = X-window). You may want to print paper copies of the plots you create in various GEMPAK programs. You can create files suitable for printouts by changing the device parameter. The file format most suitable for quality printing is postscript. To write your output to a postscript file, use the following syntax:

device = ps|

Then, run the GEMPAK program like you normally do by typing run and pressing ENTER. You will not see a window display on your screen as you do when the device is set to xw. Rather, the output is being stored to a postscript file named in the device statement. After the GEMPAK program has created the file, exit the program, then type gpend. You can also try to write your output to a gif file, use the following syntax:

device = gf|filename.gif

GIF files are easy to insert into documents, such as formal lab reports or webpages.

restore files in nmap2

Test your my_restore_01 file by loading up some model data in nmap2, bring up the data selection window:

Click: GRID
Click: NCEP_CONUS_Models
Click: nam40
Click: 170213_1200
Click: MY_RESTORE_01
Click: Accept

Examine the my_restore_01 file:

cd $HOME/restore
emacs my_restore_01

you will be modifying this (or any of the other files) to create your own unique plots.

Think about: “What do I want to display?” These could be color-filled plots of diagnostic quantities such as pressure advection. You’ll need to determine which variables are needed in order to compute the diagnostic field that you are interested in.

Use the text editor (emacs) to modify/edit a “my_restore” file in your $HOME/restore directory. Modify the GEMPAK variables so that they are set to the parameter settings that are found in the restore files you created in the previous step. The format of restore files is similar to how you type in and modify variables inside a GEMPAK program, except the “=” sign is not included. Many of the variables will not need to be modified in the “my_restore” file. For example, in your “my_restore” file, do not modify the GDFILE or GDATTIM variables (NMAP2 doesn’t need GDFILE, and leave GDATTIM set to “fall” so NMAP2 can plot all of the forecast times).

In programming, one of the best ways to learn how to do something new is to modify something that currently exists. All of the regular NMAP2 restore files are sitting in the $NMAP_RESTORE directory. You are welcome to look at those and see how other people have programmed restore files to plot the things that we currently have in NMAP2.

Let's begin by looking further into the my_restore_01 file. Some of the key parameters are listed below:

SKIP   0
SCALE  0 ! 0 !
GDPFUN hght ! tmpk ! kntv(wnd)
TYPE   c ! c ! b
CINT   30 ! 3
LINE   5/1/2 ! 21/2/2

Let’s change the GDPFUN line to modify the “tmpk” to “tmpc”. Save your my_restore_01 file, and reload the gridded data to see the effect of your change. You need to modify the “time line” in the data source window to get nmap2 to use the modified restore file. “tmpk” is temperature in Kelvin, “tmpc” is temperature in Celsius, so you’ve changed the units of the plotted temperature.

Now let’s have nmap2 do the work by calculating (and plotting) the temperature advection for us. The advection function is “adv(SCALAR,WIND)” where SCALAR could be temperature, vorticity, moisture and WIND is a wind variable which could be the geostrophic wind, thermal wind, or the regular wind. Try changing the following lines:

SCALE   5 ! 0 ! 0 !
GDPFUN  adv(tmpc,wnd) ! hght ! tmpk ! kntv(wnd)
TYPE    f ! c ! c ! b
CINT      ! 30 ! 3
LINE      ! 5/1/2 ! 21/2/2
TITLE   1/-1/~ _ 850 mb temp (K) wind (kt) advection (10-5 K/s) !0 !0

Note that the exclamation point separates variables and actions related to those variables. So, the contour interval for different variables will correspond to the same order that it is listed between “!” in the GDPFUN list.

This should color-fill the temperature advection in units of K/s * 10-5

Setting SCALE to 5 multiplies the grid by 105 before plotting

If we are interested in units of K/day we need to multiply these numbers by the factor of 86400 s/day. To do this, we’ll combine two functions at the same time, multiplication (mul) and advection (adv). Change:

SCALE   0 ! 0 ! 0 !
GDPFUN  mul(adv(tmpc,wnd),86400) ! hght ! tmpk ! kntv(wnd)
TITLE   1/-1/~ _ 850 mb temp (K) wind (kt) advection (K/day) !0 !0

At this point, it is a simple matter of examining the color fill and color bar to find numerical values for temperature advection

examine NCEP's restore files

You can look through all of the restore files that are a part of NMAP2. These are in the /export/project/a/ldm/NAWIPS/nts_current/nmap/restore

(or $NMAP_RESTORE) directory. You can open emacs and point to this directory to examine these files, use them as templates for your my_restore_XX files. I have copied 850 mb frontogenesis restore file (under WINTER_WX in nmap2) to the class directory, you can copy it into your own restore directory to make it easier to view. Try this:

cp /project/hypocenter/class/EAS434/restore/850_FGEN $HOME/restore/
emacs $HOME/restore/850_FGEN